ILOG CPLEX 11.0 User's Manual > Advanced Programming Techniques > Using Goals > Aggregating Goals

Since And goals and Or goals take other goals as arguments, goals can be combined into aggregate goals. In fact, this is how goals are typically used for specifying a branching strategy. A typical return goal of a user-written execute method for C++ looks like this:

return AndGoal(OrGoal(var <= IloFloor(val), var >= IloFloor(val)+1), this);

and for Java, it looks like this:

return cplex.and(cplex.or(cplex.leGoal(var, Math.floor(val)),
                          cplex.geGoal(var, Math.floor(val)+1)), this);

and for C#.NET, it looks like this:

return cplex.And(
            cplex.Or(cplex.GeGoal(_vars[bestj], System.Math.Floor(x[bestj])+1),
                     cplex.LeGoal(_vars[bestj], System.Math.Floor(x[bestj]))), 
            this);

For the C++ case, note that since this statement would be called from the execute method of a subclass of IloCplex::GoalI, the full name IloCplex::GoalI::OrGoal can be abbreviated to OrGoal. Likewise, the full name IloCplex::GoalI::AndGoal can be abbreviated to AndGoal.

This return statement returns an And goal that first executes the Or goal and then the current goal itself specified by the this argument. When the Or goal is executed next, it will create two subnodes. In the first subnode, the first local cut goal representing images/goalsa.gif (where images/goalsa2.gif denotes the floor of val) will be executed, thus adding the constraint images/goalsa3.gif for the subtree of this node. Similarly, the second subnode will be created, and when executing its constraint goal the constraint var images/goalsa4.gif will be added for the subtree. this is then executed on each of the nodes that have just been created; the same goal is used for both subtrees. Further details about how goals are processed are available in The Goal Stack, Controlling Goal-Defined Search, and Search Limits.