-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimetableMPI.cpp
More file actions
34 lines (27 loc) · 862 Bytes
/
Copy pathTimetableMPI.cpp
File metadata and controls
34 lines (27 loc) · 862 Bytes
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
#include "TimetableMPI.h"
using namespace std;
void
TimetableMPI::pack(const Timetable* timetable)
{
_genes.clear();
_descriptor.clear();
for (int i = 0; i < timetable->getPeriodsCount(); ++i) {
const vector<int>& ids = (*timetable)[i].getTuplesIDs();
_genes.insert(_genes.end(), ids.begin(), ids.end());
_descriptor.push_back(ids.size());
}
_fitness = timetable->getFitness();
}
void
TimetableMPI::unpack(Timetable* dest)
{
vector<int>::const_iterator itd;
vector<int>::const_iterator start = _genes.begin(), end = _genes.begin();
Periods::iterator itp = dest->getPeriods().begin();
for (itd = _descriptor.begin(); itd != _descriptor.end(); ++itd, ++itp) {
end += *itd;
itp->getTuplesIDs() = vector<int>(start, end);
start = end;
}
dest->setFitness(_fitness);
}