-
Notifications
You must be signed in to change notification settings - Fork 0
/
routeSet.h
137 lines (115 loc) · 2.85 KB
/
routeSet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* File: routeSet.h
* Author: MAN
*
* Created on September 6, 2013, 7:03 PM
*/
#ifndef _ROUTESET_H
#define _ROUTESET_H
#include<EO.h>
#include <vector>
#include "route.h"
using namespace std;
template< class FitT>
class RouteSet : public EO<FitT>
{
public:
/** Ctor: you MUST provide a default ctor.
* though such individuals will generally be processed
* by some eoInit object
*/
RouteSet()
{
// START Code of default Ctor of an RouteSet object
// END Code of default Ctor of an RouteSet object
}
virtual ~RouteSet()
{
// START Code of Destructor of an eoEASEAGenome object
// END Code of Destructor of an eoEASEAGenome object
}
virtual string className() const
{
return "RouteSet";
}
/** printing... */
void printOn(ostream& _os) const
{
// First write the fitness
EO<FitT>::printOn(_os);
_os << ' ';
// START Code of default output
/** HINTS
* in EO we systematically write the sizes of things before the things
* so readFrom is easier to code (see below)
*/
// _os << rS.size() << ' ' ;
for (unsigned i = 0; i < rS.size(); i++)
_os << rS[i] << " , ";
_os << endl;
// END Code of default output
}
/** reading...
* of course, your readFrom must be able to read what printOn writes!!!
*/
void readFrom(istream& _is)
{
// of course you should read the fitness first!
// EO<FitT>::readFrom(_is);
// START Code of input
/** HINTS
* remember the RouteSet object will come from the default ctor
* this is why having the sizes written out is useful
*/
unsigned s;
_is >> s;
rS.resize(s);
for (unsigned i = 0; i < s; i++)
{
Route<double> bTmp;
_is >> bTmp;
rS[i] = bTmp;
}
// END Code of input
}
// accessing and setting values
void setRs(vector< Route<double> > & _rS)
{
rS = _rS;
}
const vector< Route<double> > & Rs()
{
return rS;
}
vector< Route<double> > & mutableRs()
{
return rS;
}
Route<double>& operator[](int i)
{
return rS[i];
}
int size()
{
rS.size();
}
// bool isTrouble()
// {
// for (unsigned i = 0; i < rS.size(); i++)
// {
// if (rS[i].size() == 0)
// {
// cout << "here\n";
// return true;
// }
// }
// return false;
// }
private: // put all data here
// START Private data of an RouteSet object
vector< Route<double> > rS;
// END Private data of an RouteSet object
public:
mutable double D[3], Dun, ATT, actualFitness;
};
#endif /* _ROUTESET_H */