Originally posted by: ol
Hello,
from what I understand, you want to implement your own search mechanism. You can do it by writing non determistic procedures, the way to do this in CP optimizer is to define "goals" IlcGoal. Goals can be combined with IlcAnd (left is executed first) and IlcOr (the non determinism primitive).
your questions:
> 1-if i add a constraint with cp.add(IlcConstraint), how can i remove it ?.
by backtracking
> Also internally i can use cp.startingPoint(IloSolution) , can i use it inside a goal ?.
cp.startingPoint(IloSolution) is a high level primitive to be used with the high level automatic search of CP Optimizer. You want to define your own search with low level primitives. You cannot merge different levels.
> 2-Instead to get the thirst solution with cp.solve(IlcGoal,IlcTrue), how can i optimize the objective function ?.
> You give an alternative withe IlcGoal IlcMinimizeGoal(IlcGoal g, IlcIntVar v, IlcInt s = 1).but i don't know how to use it .
it is a goal, You can just call it in a goal. It was not clear to me what you wanted. I think now that you only need to use IlcGoal. If this is not enough we may later return to this function, but probably it is better you focus first on how to express the search you have in mind in terms of and/or search.
> 3-Can i control the search by making myself the backtracking after found a solution ?. I read that it's possible to use " IlcOr(goal1,goal2, label1) " or " cp.solve(IlcAnd(goal,IlcGoalFail(cp)) " to force a backtracking but i don't know how to use them because the IBM users manual is not explicit.
Inside an IlcGoal, you can call
void fail();
void fail(IlcAny label);
the first one forces the solver to backtrack to the most recent "open" IlcOr, the second one forces the solver to backtrack to the most recent "open" IlcOr with "label" as label (thus you can jump over open IlcOr)
The goals and subgoals define the search tree the solver will explore. Basically you call cp.solve() only once with an IloGoal, this iloGoal is transformed into an IlcGoal (which involves IlcVariables instead of IloVariables). The IlcGoal combines subgoals with IlcAnd and IlcOr. You can always avoid calling internal cp.solve(IlcGoal) inside an IlcGoal, this may be convenient sometimes, but try to avoid it at first in order to fully understand the goal mechanism.
Regards,
Olivier
#CPOptimizer#DecisionOptimization