2#include "FlowshopEvalOp.h"
7 state->getRegistry()->registerEntry(
"flowshop.infile", (voidP) (
new std::string), ECF::STRING);
15 if(!state->getRegistry()->isModified(
"flowshop.infile")) {
16 state->getLogger()->log(1,
"Error: no input file defined! (parameter 'flowshop.infile'");
20 voidP sptr = state->getRegistry()->getEntry(
"flowshop.infile");
21 std::string filePath = *((std::string*) sptr.get());
24 problemInstance = ::newProblem(filePath.c_str());
25 solutionInstance = ::allocSolution(problemInstance);
26 ::randomSolution(solutionInstance);
27 solutionInstance2 = ::allocSolution(problemInstance);
28 ::randomSolution(solutionInstance2);
29 moveInstance = ::allocMove(problemInstance);
30 psInstance = ::allocPathState(problemInstance);
33 state->getRegistry()->modifyEntry(
"Permutation.size", (voidP)
new uint(problemInstance->n));
36 state->getPopulation()->initialize(state);
42void FlowshopEvalOp::populateSolutionInstance(IndividualP ind,
struct solution* s)
48 for(uint i = 0; i < perm->getSize(); i++)
49 s->data[i] = perm->variables[i];
53void FlowshopEvalOp::readSolutionInstance(IndividualP ind,
struct solution* s)
59 for(uint i = 0; i < perm->getSize(); i++)
60 perm->variables[i] = s->data[i];
64MoveP FlowshopEvalOp::randomMove(IndividualP ind)
66 populateSolutionInstance(ind, solutionInstance);
68 ::randomMove(m->v, solutionInstance);
73bool FlowshopEvalOp::applyMove(IndividualP& ind, MoveP
move)
76 populateSolutionInstance(ind, solutionInstance);
77 ::applyMove(solutionInstance, m->v);
78 readSolutionInstance(ind, solutionInstance);
83PathP FlowshopEvalOp::initPathTo(IndividualP ind1, IndividualP ind2)
85 populateSolutionInstance(ind1, solutionInstance);
86 populateSolutionInstance(ind2, solutionInstance2);
87 ::initPathTo(psInstance, solutionInstance, solutionInstance2);
93int FlowshopEvalOp::getPathLength(PathP path)
96 return ::getPathLength(p->ps);
100MoveP FlowshopEvalOp::nextRandomMove(PathP path)
103 ::nextRandomMove(m->v, psInstance);
113 populateSolutionInstance(individual, solutionInstance);
116 double value = ::getObjectiveValue(solutionInstance);
118 fitness->setValue(value);
Fitness for minimization problems.
bool initialize(StateP)
Initialize the evaluator. Called before first evaluation occurs.
void registerParameters(StateP)
Register evaluator parameters. Called before EvaluateOp::initialize method.
FitnessP evaluate(IndividualP individual)
Evaluate a single individual. Method must create and return a Fitness object.
Permutation class - implements genotype as a vector of indices 0..(n-1) (permutation of indices)