edaPopulation& edaPopulation::operator = (const edaPopulation &pop) { easer(); for(unsigned int i = 0; i < size(); i++) { push_back(pop[i]->clone()); } return *this; }
void mtspSolution::serialize(edaBuffer& buf, bool pack) { if (pack) { buf.pack(&_size); buf.pack(_come, _size); buf.pack(_wait, _size); buf.pack(_late, _size); buf.pack(_route, _size); buf.pack(_move, _size); buf.pack(&_fitness); } else { easer(); buf.unpack(&_size); _come = new unsigned int[_size]; _wait = new unsigned int[_size]; _late = new unsigned int[_size]; _route = new unsigned int[_size]; _move = new unsigned int[_size]; buf.unpack(_come, _size); buf.unpack(_wait, _size); buf.unpack(_late, _size); buf.unpack(_route, _size); buf.unpack(_move, _size); buf.unpack(&_fitness); } }
edaChromosome& edaChromosome::operator = (const edaChromosome &chro) { easer(); for(unsigned int i = 0; i < chro.list.size(); i++) list.push_back(chro.list[i]->clone()); fitness = chro.fitness; return *this; }
void edaRankSelection::Serialize( edaBuffer &buf, bool pack ) { if(pack) { buf.Pack(&rate,1); } else { easer(); buf.UnPack(&rate,1); } }
edaSolution& tspSolution::operator = (const edaSolution &sol) { easer(); tspSolution& tspSol = (tspSolution&) sol; vector<unsigned int>::operator = (tspSol); graph = tspSol.graph->clone(); cost = tspSol.cost; return (*this); }
void tspRepresentation::Serialize( edaBuffer &buf, bool pack ) { if(pack) { gra->doSerialize(buf,pack); } else { easer(); gra = (Graph*) classGenerateFromBuffer(buf); } }
void edaRankSelection::computeRankWeight(const edaPopulation& pop) { easer(); unsigned int size = pop.size(); rank = new double[size]; double sum = 0; for(unsigned int i = 1; i <= size; ++i) { sum += i; } rank[0] = 1.0 * size / sum; for(unsigned int i = 1; i < size; ++i) { rank[i] = rank[i-1] + (1.0*size - i)/sum; } }
void vrpGroupConflict::Serialize(edaBuffer &buf, bool pack) { if ( pack ) { buf.Pack( &_size, 1 ); buf.Pack( _matrix, _size * _size ); } else { easer(); buf.UnPack( &_size, 1 ); _matrix = new bool[_size * _size]; buf.UnPack( _matrix, _size * _size ); } }
void tspTwoOptNext::Serialize(edaBuffer &buf, bool pack) { edaMoveGen::Serialize(buf, pack); if (pack) { graph->doSerialize(buf, pack); } else { easer(); graph = (Graph *)classGenerateFromBuffer(buf); } }
void vrpProblem::load(const char* filename) { easer(); ifstream file(filename); cout << ">> Loading [" << filename << "]" << endl; double buffer; if (file) { file >> _num_stops; //read the number of stops file >> _capacity_veh; //read the capacity of vehicle file >> _speed; //speed of vehicle file >> _max_total_dist; //get maximum total dist of a vehicle _list_stops = new vrpStop[_num_stops]; //read all property of stops for (unsigned int i = 0; i < _num_stops; i++) { file >> buffer; _list_stops[i].ID = (unsigned int)buffer; file >> buffer; _list_stops[i].X = buffer; file >> buffer; _list_stops[i].Y = buffer; file >> buffer; _list_stops[i].EarlyTime = getMinutes(buffer); file >> buffer; _list_stops[i].LateTime = getMinutes(buffer); file >> buffer; _list_stops[i].ServiceTime = buffer/60; file >> buffer; _list_stops[i].Load = buffer; file >> buffer; _list_stops[i].Type = (unsigned int)buffer; } //get information about conflict stops unsigned int count_group; file >> count_group; //number of the group customer for(unsigned int i = 0 ; i < _num_stops ; i++) { if(_list_stops[i].Type != REGULAR_STOP) _list_stops[i].Group = NON_GROUP; else _list_stops[i].Group = _list_stops[i].ID % count_group; } _conflict_group = new vrpGroupConflict(count_group); unsigned int group_A, group_B; while(file >> group_A >> group_B ) _conflict_group->pushConflictGroup(group_A, group_B); file.close(); computeDistances(); } else {
void edaPopulation::Serialize( edaBuffer &buf, bool pack ) { if(pack) { unsigned int _size = size(); buf.Pack(&_size, 1); for(unsigned int i = 0; i < _size; i++) { at(i)->doSerialize(buf,pack); } } else { easer(); unsigned int _size; buf.UnPack(&_size,1); resize(_size); for(unsigned int i = 0; i < _size; i++) { at(i) = (edaChromosome*)classGenerateFromBuffer(buf); } } }
void edaChromosome::Serialize( edaBuffer &buf, bool pack ) { if (pack) { unsigned int size = list.size(); buf.Pack(&size, 1); for(unsigned int i = 0; i < size; i++) { edaGenne *genne = list[i]; genne->doSerialize(buf,pack); } buf.Pack(&fitness,1); } else { easer(); unsigned int size; buf.UnPack(&size, 1); list.resize(size); for (unsigned int i = 0; i < size; i++) list[i] = (edaGenne*)classGenerateFromBuffer(buf); buf.UnPack(&fitness,1); } }
mtspSolution& mtspSolution::operator=(const edaSolution& sol) { easer(); const mtspSolution& route = (mtspSolution&) sol; _fitness = route._fitness; _graph = route._graph; _size = route._size; _route = new unsigned int[_size]; _come = new unsigned int[_size]; _wait = new unsigned int[_size]; _late = new unsigned int[_size]; _move = new unsigned int[_size]; for (unsigned int i = 0; i < _size; i++) { _route[i] = route._route[i]; _come[i] = route._come[i]; _wait[i] = route._wait[i]; _late[i] = route._late[i]; _move[i] = route._move[i]; } return *this; }
void schedSolution::serialize(edaBuffer& buf, bool pack) { unsigned int n = size(); unsigned int value; if (pack) { buf.pack(&n); for (unsigned int i = 0; i < n; i++) { value = at(i); buf.pack(&value); } buf.pack(&_fitness); } else { easer(); buf.unpack(&n); for (unsigned int i = 0; i < n; i++) { buf.unpack(&value); push_back(value); } buf.unpack(&_fitness); } }
void tspSolution::Serialize( edaBuffer &buf, bool pack ) { if (pack) { // Pack the Graph graph->doSerialize(buf, pack); // then pack the vector unsigned _size = this->size(); buf.Pack(&_size, 1); vector<unsigned int>::iterator iter; for (iter = this->begin(); iter != this->end(); iter++) { buf.Pack((unsigned int *) &(*iter), 1); } //Pack the Cost buf.Pack(&cost, 1); } else { easer(); // Unpack the Graph graph = (Graph*) classGenerateFromBuffer(buf); // then unpack the vector unsigned int _size; buf.UnPack(&_size, 1); this->resize(_size); for (unsigned int i = 0; i < _size; i++) { int atom; buf.UnPack((int *) &atom, 1); (*this)[i] = atom; } //UnPack the Cost buf.UnPack(&cost, 1); } }
schedSwapArea::~schedSwapArea() { easer(); }
vrpProblem::~vrpProblem() { easer(); }
edaChromosome::~edaChromosome() { easer(); }
vrpGroupConflict::~vrpGroupConflict() { easer(); }
edaPopulation::~edaPopulation() { easer(); }
schedSolution::~schedSolution() { easer(); }
edaRankSelection::~edaRankSelection() { easer(); }
tspRepresentation::~tspRepresentation() { easer(); }
mtspSolution::~mtspSolution() { easer(); }