ILOG CPLEX .NET Reference Manual

Cplex.Goal Class

Base class of user-written implementation classes of goals.

For a list of all members of this type, see Cplex.Goal Members.

System.Object
   ILOG.CPLEX.Cplex.Goal

public abstract class Cplex.Goal

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This is an advanced class.

Important:

Advanced classes typically demand a profound understanding of the algorithms used by ILOG CPLEX. Thus they incur a higher risk of incorrect behavior in your application, behavior that can be difficult to debug. Therefore, ILOG encourages you to consider carefully whether you can accomplish the same task by means of other classes instead.

Goals can be used to control the branch-and-cut search in Cplex. In some respects, goals are an alternative to callbacks for controlling branch-and-cut search. Goals are implemented in subclasses of class Cplex.Goal. Thus, this is the base class for user-written implementation classes of CPLEX goals. To implement your own goal, you need to create a subclass of Cplex.Goal and implement its pure virtual method execute. After implementing your goal class, you use it by calling the method Cplex.Solve(goal) instead of the standard Cplex.Solve without parameter.

The execute method is called by Cplex at each branch-and-cut node (referred to as the current node) after the node relaxation has been solved. Every node maintains a stack of goals, and the top goal from this stack is popped and executed until the stack becomes empty or some special goal is encountered as described below. When the goal stack of a node becomes empty, CPLEX continues with its built-in search for that subtree. When Cplex.Solve(goal) is called, goal is simply pushed on the goal stack of the root node before the branch-and-cut search begins.

The method Cplex.Goal.Execute is where you can control the branch-and-cut search of Cplex. Class Cplex.Goal provides several methods for querying information about the current node. It is, however, the goal returned by the execute method that determines how to proceed with the search. CPLEX provides several methods that create special goals that can be used to define the ongoing search in addition to any user-written goal:

Goals returned by Cplex.Or and Cplex.And allow you to combine goals. Cplex.And allows you to execute different goals at one node, while Cplex.Or allows you to execute different goals on different newly, created nodes. A typical use of these two goals in a return statement of a user written goal is:

return cplex.And ( cplex.Or (branch1, branch2), this);

The Cplex.And goal first pushes this, that is, the goal currently being executed, on the goal stack and then it pushes the Cplex.Or goal. Thus the Cplex.Or goal is on top of the stack and will be executed next. When the Cplex.Or is executed, it creates two new nodes and copies the remaining goal stack to both of them. Thus both new nodes will have this goal on top of the goal stack at this point. Then the Cplex.Or proceeds to push branch1 on the goal stack of the first child node and branch2 on the goal stack of the second goal child node. Typically, branch1 and branch2 would eventually contain constraint goals so by executing branch1 and branch2 at the respective child nodes, the child nodes will be restricted to represent smaller subproblems than their parent. After branch1 and branch2 have been executed this is on top of the node stack of both child nodes, that is, both child nodes will continue branching according to the same rule. In summary, the above example creates branches described branch1 and branch2 and continues in both branches to control the same search strategy this.

If the default implementation of method clone is not adequate and the goal is to be used for parallel optimization, this method also needs to be implemented by the user. Recall that the default clone method performs a shallow copy, so typically a user implementation would perform a deep copy for objects that should be local to threads or use the synchronize keyword where synchronization is required.

For more information about goals see the chapter in the ILOG CPLEX User's Manual.

Requirements

Namespace: ILOG.CPLEX

Assembly: ILOG.CPLEX (in ILOG.CPLEX.dll)

See Also

Cplex.Goal Members | ILOG.CPLEX Namespace