| IBM ILOG Scheduler User's Manual > Local Search in Scheduler > Tabu Search for the Jobshop Problem with Alternatives > Solving the Problem > Creating the RelocateRC Move |
Creating the RelocateRC Move |
INDEX
PREVIOUS
NEXT
|
The RelocateRC move represents the movement of a resource constraint from one resource in its alternative resource set to another and the insertion of the resource constraint between two other resource constraints on the latter resource. The class represents the resource constraint that is relocated (_relocated), the resource to which it is moved to (_to), and the resource constraint that it is next to on the new resource (_beforeInsertion).
Accessors are defined for the data members and the class as a whole inherits from LSMove.
The isReverseMove method returns IloTrue if the delta solution places the _relocated resource constraint on a resource other than _to.
Two additional functions are defined:
Recall that the createDelta function creates an IloSchedulerSolution object that represents the changes necessary to implement a move. In detail, we do the following in the createDelta method.
First, we reassign the selected resource of the _relocated resource constraint and unset its next pointer if it has one in the current solution.
We then set the next pointer of _relocated to be either the setup resource constraint on the _to resource or to the resource constraint that is next after _beforeInsertion in the current solution.
It is possible that _relocated will have no next resource constraint in the case where it is inserted as the last resource constraint on the _to resource.
We then add the _beforeInsertion resource constraint to the delta solution and set its next to be _relocated. Again, it is possible that _beforeInsertion does not exist when _relocated is inserted as the first resource constraint on the _to resource.
The final step is to change the resource constraint that comes before _relocated in the current solution. If it exists, we need to change its next pointer to point to the resource constraint that comes after _relocated in the current solution.
The RelocateRC::findRelocateFromDelta creates an instance of RelocateRC from a corresponding IloSchedulerSolution. If the IloSchedulerSolution does not actually represent a RelocateRC a NULL pointer is returned.
This method first finds a resource constraint whose assigned resource has been changed in the delta solution and then finds the resource constraint that is not next to any of the resource constraints in the delta. By comparing these two resource constraints, it is possible to recreate the RelocateRC move.
RelocateRC* RelocateRC::findRelocateFromDelta(IloSolver solver,
IloSolution delta,
IloSchedulerSolution current) {
// Try to generate a RelocateRC move from the information in delta.
// This may fail as delta does not necessarily represent a SwapRC
// move
IloSchedulerSolution solution(delta);
IloResourceConstraint resChange;
for(IloSchedulerSolution::ResourceConstraintIterator iter2(solution);
iter2.ok() && (resChange.getImpl() == 0); ++iter2) {
resChange = *iter2;
if (solution.getSelected(resChange).getImpl() ==
current.getSelected(resChange).getImpl())
resChange = 0;
}
if (0 == resChange.getImpl())
return 0;
// find the element that is not next of any element in the delta
IloResourceConstraint first;
for(IloSchedulerSolution::ResourceConstraintIterator iter(solution);
iter.ok() && (0 == first.getImpl()); ++iter) {
first = *iter;
for(IloSchedulerSolution::ResourceConstraintIterator iter3(solution);
iter3.ok() && (0 != first.getImpl()); ++iter3) {
IloResourceConstraint rc = *iter3;
if (rc.getImpl() != first.getImpl()) {
if (solution.hasNextRC(rc) &&
(solution.getNextRC(rc).getImpl() == first.getImpl()))
first = 0;
}
}
}
assert(0 != first.getImpl());
if (first.getImpl() == resChange.getImpl())
return new (solver.getEnv()) RelocateRC(first,
solution.getSelected(first),
0);
else
return new (solver.getEnv()) RelocateRC(resChange,
solution.getSelected(resChange),
first);
}
| © Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |