IBM ILOG Solver User's Manual > More on Solving > Searching for Optimal Solutions: Replanning Warehouses > Multiphase search |
Multiphase search |
INDEX
![]() |
The member functions IloSolver::startNewSearch
and IloSolver::next
, in conjunction with the classes IloSolution
and IloRestoreSolution
, enable you to search for solutions of a given problem, to edit that problem, and to search for solutions to this new problem. You can even search for solutions of the new problem that are close to solutions of the old one.
Let's assume that you want to search for all solutions of a problem provided you do not change the values of the last four variables. In order to do this, you create two solution objects, one for the variables you do not want to change, and the other for the variables that can be changed. You add the last four variables of the problem to the IloSolution
object frozen
and declare a goal restoreFrozen
, which uses the function IloRestoreSolution
to restore the values of the solution frozen
. You add the first four variables of the problem to the IloSolution
object free
and declare a goal storeFree
, which uses the function IloStoreSolution
to store the values of the solution free
.
You use the following code to search for our new solutions. The member function IloSolver::startNewSearch
calls the goals restoreFrozen
, goal
, and storeFree
in the search. The solver adds the frozen variables, searches for a solution using goal
as its objective, and stores the values of the free variables:
solver.out() << "repeat last solution" << endl; IloGoal restoreFree = IloRestoreSolution(env, free); solver.solve(restoreFrozen && restoreFree); Print(solver, x); |
If you want, for example, to obtain a solution that keeps the same values for the last four variables and that respects an additional constraint, it is sufficient to restore the variables you want to keep, add the additional constraint, and search again for a solution, like this:
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |