NO FRAMES

Class IloCplex::HeuristicCallbackI

Definition file: ilocplexi.h
Include files: ilcplex/ilocplex.h

An instance of the class IloCplex::HeuristicCallbackI represents a user-written callback in an application that uses an instance of IloCplex to solve a mixed integer programming problem (a MIP). When you derive a user-defined class of callbacks, this class offers protected methods for you to:

In short, this callback allows you to attempt to construct an integer feasible solution at a node and pass it to the invoking instance of IloCplex to use as its new incumbent. The API supports you in finding such a solution by allowing you iteratively to change bounds of the variables and re-solve the node relaxation. Changing the bounds in the heuristic callback has no effect on the search beyond the termination of the callback.

The heuristic callback is called after the node relaxation has been solved (including all cuts that may have been generated).

If an attempt is made to access information not available at the node for the invoking instance of IloCplex, an exception is thrown.

See Also:

Method Summary
protected IloCplex::CplexStatusgetCplexStatus()
protected IloAlgorithm::StatusgetStatus()
protected IloBoolisDualFeasible()
protected IloBoolisPrimalFeasible()
protected voidsetBounds(const IloIntVarArray, const IloNumArray, const IloNumArray)
protected voidsetBounds(const IloNumVarArray, const IloNumArray, const IloNumArray)
protected voidsetBounds(const IloIntVar, IloNum, IloNum)
protected voidsetBounds(const IloNumVar, IloNum, IloNum)
protected voidsetSolution(const IloIntVarArray, const IloNumArray, IloNum)
protected voidsetSolution(const IloIntVarArray, const IloNumArray)
protected voidsetSolution(const IloNumVarArray, const IloNumArray, IloNum)
protected voidsetSolution(const IloNumVarArray, const IloNumArray)
protected IloBoolsolve(IloCplex::Algorithm)
Inherited Methods from ControlCallbackI
getDownPseudoCost, getDownPseudoCost, getFeasibilities, getFeasibilities, getFeasibility, getFeasibility, getFeasibility, getFeasibility, getLB, getLB, getLBs, getLBs, getNodeData, getObjValue, getSlack, getSlacks, getUB, getUB, getUBs, getUBs, getUpPseudoCost, getUpPseudoCost, getValue, getValue, getValue, getValues, getValues, isSOSFeasible, isSOSFeasible
Inherited Methods from MIPCallbackI
getBestObjValue, getCutoff, getDirection, getDirection, getIncumbentObjValue, getIncumbentValue, getIncumbentValue, getIncumbentValues, getIncumbentValues, getMyThreadNum, getNcliques, getNcovers, getNdisjunctiveCuts, getNflowCovers, getNflowPaths, getNfractionalCuts, getNGUBcovers, getNimpliedBounds, getNiterations, getNMIRs, getNnodes, getNremainingNodes, getObjCoef, getObjCoef, getObjCoefs, getObjCoefs, getPriority, getPriority, getUserThreads, hasIncumbent
Inherited Methods from CallbackI
abort, duplicateCallback, getEnv, getModel, getNcols, getNQCs, getNrows, main
Method Detail

getCplexStatus

protected IloCplex::CplexStatus getCplexStatus()

This method returns the ILOG CPLEX status of the instance of IloCplex at the current node (that is, the state of the optimizer at the node) during the last call to HeuristicCallbackI::solve (which may have been called directly in the callback or by IloCplex when processing the node).

The enumeration IloCplex::CplexStatus lists the possible status values.


getStatus

protected IloAlgorithm::Status getStatus()

This method returns the status of the solution found by the instance of IloCplex at the current node during the last call to HeuristicCallbackI::solve (which may have been called directly in the callback or by IloCplex when processing the node).

The enumeration IloAlgorithm::Status lists the possible status values.


isDualFeasible

protected IloBool isDualFeasible()

This method returns IloTrue if the solution provided by the last solve call is dual feasible. Note that an IloFalse return value does not necessarily mean that the solution is not dual feasible. It simply means that the relevant algorithm was not able to conclude it was dual feasible when it terminated.


isPrimalFeasible

protected IloBool isPrimalFeasible()

This method returns IloTrue if the solution provided by the last solve call is primal feasible. Note that an IloFalse return value does not necessarily mean that the solution is not primal feasible. It simply means that the relevant algorithm was not able to conclude it was primal feasible when it terminated.


setBounds

protected void setBounds(const IloIntVarArray var, const IloNumArray lb, const IloNumArray ub)

For each variable in the array var, this method sets its upper bound to the corresponding value in the array ub and its lower bound to the corresponding value in the array lb. Setting bounds has no effect beyond the scope of the current invocation of the callback.


setBounds

protected void setBounds(const IloNumVarArray var, const IloNumArray lb, const IloNumArray ub)

For each variable in the array var, this method sets its upper bound to the corresponding value in the array ub and its lower bound to the corresponding value in the array lb. Setting bounds has no effect beyond the scope of the current invocation of the callback.


setBounds

protected void setBounds(const IloIntVar var, IloNum lb, IloNum ub)

This method sets the lower bound to lb and the upper bound to ub for the variable var at the current node. Setting bounds has no effect beyond the scope of the current invocation of the callback.


setBounds

protected void setBounds(const IloNumVar var, IloNum lb, IloNum ub)

This method sets the lower bound to lb and the upper bound to ub for the variable var at the current node. Setting bounds has no effect beyond the scope of the current invocation of the callback.


setSolution

protected void setSolution(const IloIntVarArray vars, const IloNumArray vals, IloNum obj)

For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].

The parameter obj is used to tell IloCplex the objective value of the injected solution. This allows IloCplex to skip the computation of that value, but care must be taken not to provide an incorrect value.


setSolution

protected void setSolution(const IloIntVarArray vars, const IloNumArray vals)

For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].


setSolution

protected void setSolution(const IloNumVarArray vars, const IloNumArray vals, IloNum obj)

For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].

The parameter obj is used to tell IloCplex the objective value of the injected solution. This allows IloCplex to skip the computation of that value, but care must be taken not to provide an incorrect value.


setSolution

protected void setSolution(const IloNumVarArray vars, const IloNumArray vals)

For each variable in the array vars, this method uses the value in the corresponding element of the array vals to define a heuristic solution to be considered as a new incumbent.

If the user heuristic was successful in finding a new candidate for an incumbent, setSolution can be used to pass it over to IloCplex. IloCplex then analyses the solution and, if it is both feasible and better than the current incumbent, uses it as the new incumbent. A solution is specified using arrays vars and vals, where vals[i] specifies the solution value for vars[i].


solve

protected IloBool solve(IloCplex::Algorithm alg)

This method can be used to solve the current node relaxation, usually after some bounds have been changed using HeuristicCallbackI::setBounds. By default it uses the dual simplex algorithm, but this can be overwritten using the optional parameter alg. See the enumeration IloCplex::Algorithm for a list of the available optimizers.