Skip to content

Callbacks

CallbackModel

The callback model to interact with the algorithm during the callback function.

Use setCallback to set a callback function. The callback function will be invoked with an initialized callback model.

convexDual: float property

The convex dual value for a subproblem.

Returns:

Type Description
float

A list with values for all variables.

Note

Only valid in PathMIPSubproblem.

dominanceType: DominanceType property

The current graph index.

Returns:

Type Description
DominanceType

The graph id.

edge: int property

The current edge in the graph on which extension of state is happening.

Returns:

Type Description
int

The edge id.

Note

Only valid in DPExtend.

haveArtificialCost: bool property

Verify if the edge costs are artifical. This happens when the path MIP attempts to restore feasibility. Correct costs are recalculated when feasiblity is restored.

If the path cost have non-edge components, like resource dependent non-linear costs, those must be skipped when calculating artificial reduced costs.

Returns:

Type Description
bool

A boolean flag indicating if edge cost is artificial.

Note

Only applicable in the dynamic programming algorithm when solving a path MIP.

k: int property

The current graph index.

Returns:

Type Description
int

The graph id.

reducedCost: List[float] property

The current reduced cost for a subproblem.

Access k to get information of the current subproblem and use convexDual to get the current convex dual value.

Returns:

Type Description
List[float]

A list with values for all variables.

Note

Only valid in PathMIPSubproblem.

vertex: int property

The current vertex in the graph.

Returns:

Type Description
int

The vertex id.

Note

Only applicable in the dynamic programming algorithm.

x: List[float] property

The current variable values.

Returns:

Type Description
List[float]

A list with values for all variables.

Note

Only valid in PathMIPCuts,

PathMIPHeuristic, or PathMIPSolution.

zeroEdges: List[int] property

The current list of edges with values fixed to zero.

Returns:

Type Description
List[int]

A list of edge indices.

Note

Only valid in PathMIPSubproblem.

addCut(equa)

Add a cut to the model.

Parameters:

Name Type Description Default
equa LinEqua

The cut as a linear equation.

required
Note

Only valid in PathMIPCuts

addPath(cost, eids)

Add a path to a subproblem during initialization.

Parameters:

Name Type Description Default
cost float

The cost of the path.

required
eids List[int]

A list of edge indices.

required
Note

Only valid in PathMIPInit.

addPathReducedCost(reducedCost, cost, eids)

Add a path to a subproblem if using a custom subproblem algorithm.

Parameters:

Name Type Description Default
reducedCost float

The reduced cost of the path.

required
cost float

The cost of the path.

required
eids List[int]

A list of edge indices.

required
Note

Only valid in PathMIPSubproblem.

addSolution(cost, x)

Add a solution to the problem.

Parameters:

Name Type Description Default
cost float

The objective value of the solution.

required
x List[float]

A list of variable values.

required
Note

Only valid in PathMIPHeuristic.

getResource(name)

Get the current resource value.

Parameters:

Name Type Description Default
name str

The name of the resource.

required

Returns:

Type Description
float

The resource value.

Note

Only applicable in the dynamic programming algorithm.

getResourceOther(name)

Get the current resource of another label in dominance.

Parameters:

Name Type Description Default
name str

The name of the resource.

required

Returns:

Type Description
float

The resource value of the other label.

Note

Only valid in DPDominate.

keep()

Indicate that the label under consideration to be dominated should be kept. That is, if the other label is not dominated then this function should be invoked.

Note

Only valid in DPDominate

setResource(name, value)

Set the current resource value.

Parameters:

Name Type Description Default
name str

The name of the resource.

required
value float

The new value to set.

required
Note

Only applicable in the dynamic programming algorithm.

setStatus(status)

Set the optimization status if using a custom subproblem algorithm.

Parameters:

Name Type Description Default
status OptimizationStatus

The optimization status

required
Note

Only valid in PathMIPSubproblem.

skip()

Invoking this function has different meanings depending on Where:

In the dynamic programming algorithm

  • For DPExtend then discard a label if it is infeasible.

In the path MIP algorithm

  • For PathMIPSolution then skip a solution if is infeasible.
  • For PathMIPSubproblem then skip calls to the internal dynamic programming algorithm. Only paths added with addPath are then present in the path MIP.
Note

Only valid in DPExtend, PathMIPSolution, or PathMIPSubproblem.