ILOG CPLEX .NET Reference Manual

Cplex.NodeEvaluator Class

Node evaluators can be used to control the node selection strategy during the branch-and-cut search.

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

System.Object
   ILOG.CPLEX.Cplex.NodeEvaluator

public abstract class Cplex.NodeEvaluator

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

When Cplex finishes processing a node during branch-and-cut search it chooses a new active node from the tree to process. Node evaluators allow you to implement your own node selection strategy within any subtree controlled by goals.

Node evaluators are represented by objects of type Cplex.NodeEvaluator. To create your own node evaluator, you must subclass class Cplex.NodeEvaluator and implement the abstract method evaluate.

The evaluate method is called by Cplex to compute a value for a given node. Given two nodes being evaluated by the same evaluator, by default Cplex chooses the node with the lower value. However, this default behavior can be changed by overriding the method subsume.

If the default implementation of the 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.

The method Cplex.Apply is used to impose a node selection strategy defined by a node evaluator on the search controlled by a goal, as shown in this example:

 Cplex.Goal evalGoal = cplex.Apply(goal, nodeEval); 

In this example nodeEval is of type Cplex.NodeEvaluator and goal is of type Cplex.Goal. The method apply creates and returns a new goal that follows the node selection rule defined by nodeEval while performing branch-and-cut search as specified by goal. In doing so, the node selection strategy defined by nodeEval is active only for the search subtree generated by goal.

This also means that as soon as the goal stack becomes empty and Cplex proceeds with built-in search strategies, the node selection control via node evaluators is deactivated, and the built-in strategy controlled by parameter Cplex.IntParam.NodeSel is used instead. In order to maintain control over the node selection via node evaluators while using the Cplex branch strategy, a goal such as:

 class DefaultSearchGoal extends Cplex.Goal { public Cplex.Goal execute(Cplex cplex) throws ILOG.Concert.Exception { if (!isIntegerFeasible()) return cplex.And(cplex.BranchAsCplex(), this); return null; } } 

can be used.

An interesting implication of the correspondence between node evaluators and goals is that you can specify different node selection strategies for different subtrees. If goal1 and goal2 define the search in two subtrees of a branch-and-cut search tree, and eval1 and eval2 define two different node selection schemes, the goal

cplex.Or(cplex.Apply(goal1, eval1), cplex.Apply(goal2, eval2));

will put the subtree defined by goal1 under the node selection strategy of eval1 and the subtree defined by goal2 under the node selection strategy of eval2.

To better understand how multiple node evaluators are handled, consider this additional information about the management of evaluators. When an evaluator is applied to a goal, the evaluator is attached to every node that will be created by that goal. This not only includes the nodes created by the execute method of the goal itself, but also those created by the goal returned by the execute method and so on. Since the execute method of a goal may create and return goals with other evaluators applied to them, every node may have a list of evaluators attached to it. The order of evaluators is the order in which the evaluators have been applied.

Each evaluator computes a value for every node it is attached to by calling the method evaluate. This method is called only once for a node and the result is stored. If a node evaluates to Double.MAX_VALUE (by means of an evaluator's method evaluate), the node is pruned from the tree, or, in other words, the node is removed from the tree along with the entire subtree that otherwise might have been generated from it.

When Cplex chooses the next node to be processed it starts out with a candidate proposed by the built-in node selection strategy. There is a variety of such strategies that can be chosen with parameter Cplex.IntParam.NodeSel.

After choosing an initial candidate node, Cplex goes through the list of remaining nodes in the branch-and-cut tree to see if a node evaluator overrules this decision. Thus, for each active node Cplex checks all the evaluators it has in common with the current candidate. By default, if a common evaluator computed a lower number for a node than for the current candidate, that node is used as a new candidate. However, by overriding the subsume method, a different overruling criterion can be implemented. The evaluators are checked in the order they are listed in the candidate node. This operation is repeated until all nodes have been checked. The candidate that survives this process will be chosen as the node to be processed for branch-and-cut search.

Requirements

Namespace: ILOG.CPLEX

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

See Also

Cplex.NodeEvaluator Members | ILOG.CPLEX Namespace