12.07.2015 Views

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

ILOG CPLEX 11.0 User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

As this example is an extension of the example ilogoalex1.cpp, this exposition of itconcentrates only on their differences. Also, the example is discussed only in terms of theC++ implementation; the Java implementation has identical structure and design and differsonly in syntax, as does the .NET as well.The first is the definition of class DepthEvaluatorI as a subclass ofIloCplex::NodeEvaluatorI. It implement the methods evaluate andduplicateEvaluator. The method evaluate simply returns the negative depth valuequeried for the current node by calling method getDepth. Since <strong>ILOG</strong> <strong>CPLEX</strong> by defaultchooses nodes with the lowest evaluation value, this evaluator will favor nodes deep in thetree. The method duplicateEvaluator simply returns a copy of the invoking object bycalling the (default) copy constructor. Along with the class, the function DepthEvaluatoris also defined to create an instance of class DepthEvaluatorI and returns a handle to it.Similarly, the class IISumEvaluatorI and function IISumEvaluator are also defined.The evaluate method returns the negation of the sum of integer infeasibilities of the nodebeing evaluated. This number is obtained by calling method getInfeasibilitySum.Thus, this evaluator favors nodes with larger sums of integer infeasibilities.This example uses the same search strategy as ilogoalex1.cpp, implemented in goalMyBranchGoal. However, it applies first the IISumEvaluator to select nodes with highinteger infeasibility sum, to choose between nodes with the same integer infeasibility sum itapplies the DepthEvaluator. Applying the IISumEvaluator is done withIloCplex::Goal iiSumGoal = IloCplex::Apply(cplex,MyBranchGoal(env, var),IISumEvaluator());The goal created by calling MyBranchGoal is merged with the evaluator created by callingIISumEvaluator into a new goal iiSumGoal. Similarly, the iiSumGoal is merged withthe node evaluator created by calling DepthEvaluator into a new goal depthGoal:IloCplex::Goal depthGoal = IloCplex::Apply(cplex,iiSumGoal,DepthEvaluator());Thus, depthGoal represents a goal implementing the branching strategy defined byMyBranchGoal, but using IISumEvaluator as a primary node selection strategy andDepthEvaluator as a secondary node selection strategy for breaking ties. This goal isfinally used for the branch & cut search by passing it to the solve method.Node evaluators are only active while the search is controlled by goals. That is, if the goalstack becomes empty at a node and <strong>ILOG</strong> <strong>CPLEX</strong> continues searching with its built-insearch strategy, that search is no longer controlled by any node evaluator. In order tomaintain control over the node selection strategy while using the <strong>ILOG</strong> <strong>CPLEX</strong> branchstrategy, you can use the goal returned by the methodIloCplex::GoalI::BranchAsCplexGoal (IloCplex.branchAsCplex). A goal that<strong>ILOG</strong> <strong>CPLEX</strong> <strong>11.0</strong> — USER’ S MANUAL 443

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!