Skip to main content
FRAMES NO FRAMES

IlcAnd

public IlcGoal IlcAnd(const IlcGoal g1, const IlcGoal g2)
public IlcGoal IlcAnd(const IlcGoal g1, const IlcGoal g2, const IlcGoal g3)
public IlcGoal IlcAnd(const IlcGoal g1, const IlcGoal g2, const IlcGoal g3, const IlcGoal g4)
public IlcGoal IlcAnd(const IlcGoal g1, const IlcGoal g2, const IlcGoal g3, const IlcGoal g4, const IlcGoal g5)
Definition file: ilcp/cpext.h
Include file: <ilcp/cpext.h>
Returns a goal that is a conjunction of goals.

A goal can be defined in terms of other goals, called its subgoals. The function IlcAnd creates a goal composed of a sequence of other goals (between two and five subgoals). Executing this goal executes the subgoals from left to right. That apparent limitation of five subgoals can be overcome by several calls to the function, since IlcAnd is associative.

If a goal is null (that is, if its implementation is null), it will be silently ignored.

Examples:

First we'll define a goal, PrintX, like this:

 ILCGOAL1(PrintX, IlcInt, value){
   IlcCPEngine cp = getCPEngine();
   cp.out() << "PrintX: a goal with one data member" << std::endl;
   cp.out() << value << std::endl;
   return 0;
 }
 

Then the following statements:

 cp.solve(IlcAnd(PrintX(cp, 1), PrintX(cp, 2), PrintX(cp, 3));
 

produce the following output:

 PrintX: executing a goal with one data member
 1
 PrintX: executing a goal with one data member
 2
 PrintX: executing a goal with one data member
 3
 

Here's how to define a choice point with eight subgoals:

 IlcAnd(IlcAnd(g1, g2, g3, g4, g5),
        IlcAnd(g6, g7, g8));
 

For more information, see the concept Goals in CP Optimizer.

See Also: