Package cplex :: Module callbacks :: Class ControlCallback
[frames] | no frames]
 

Class ControlCallback


Base class for Cplex MIP control callback classes.
Nested Classes
  feasibility_status

Inherited from MIPInfoCallback: cut_type, quality_metric

Instance Methods
 
get_pseudo_costs(self, *args)
Returns the current pseudo costs.
 
get_feasibilities(self, *args)
Returns the current integer feasibility status.
 
get_lower_bounds(self, *args)
Returns the lower bounds at the current node.
 
get_upper_bounds(self, *args)
Returns the upper bounds at the current node.
 
get_node_data(self)
Returns the user handle for the current node.
 
set_node_data(self, data)
Set the user handle for the current node.
 
get_node_ID(self)
Return the sequence number of this node.
 
get_objective_value(self)
Returns the value of the objective function at the current node.
 
get_linear_slacks(self, *args)
Returns a set of linear slacks for the solution at the current node.
 
get_quadratic_slacks(self, *args)
Returns a set of quadratic slacks for the solution at the current node.
 
get_values(self, *args)
Returns the solution values at the current node.
 
get_SOS_feasibilities(self, *args)
Returns the current special ordered set feasibility status.

Inherited from MIPCallback: get_objective_coefficients

Inherited from MIPInfoCallback: get_MIP_relative_gap, get_best_objective_value, get_cutoff, get_float_quality, get_incumbent_linear_slacks, get_incumbent_objective_value, get_incumbent_quadratic_slacks, get_incumbent_values, get_num_cols, get_num_cuts, get_num_iterations, get_num_nodes, get_num_quadratic_constraints, get_num_remaining_nodes, get_num_rows, has_incumbent

Inherited from Callback: abort, get_dettime, get_end_dettime, get_end_time, get_start_dettime, get_start_time, get_time

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

get_pseudo_costs(self, *args)

 

Returns the current pseudo costs.

There are four forms by which get_pseudo_costs may be called.

self.get_pseudo_costs()
returns a list of pairs with the pseudo costs for all the
variables.
self.get_pseudo_costs(i)
i must be a variable index or name. Returns a pair (up, down), where up is the up pseudo cost and down is the down pseudo cost of branching on the variable i.
self.get_pseudo_costs(s)
s must be a sequence of variable indices or names. Returns a list of pairs (up, down) of pseudo costs of branching on the variables with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_pseudo_costs(i) for i in s]
self.get_pseudo_costs(begin, end)
begin and end must be variable indices or variable names. Returns a list of pairs (up, down) of pseudo costs of branching on the variables with indices between begin and end, inclusive of end. Equivalent to self.get_pseudo_costs(range(begin, end + 1))

get_feasibilities(self, *args)

 

Returns the current integer feasibility status.

There are four forms by which get_feasibilities may be called.

The return values are attributes of self.feasibility_status.

self.get_feasibilities()
returns a list with the feasibility status for all the variables.
self.get_feasibilities(i)
i must be a variable index or name. Returns the feasibility status of the variable with index i.
self.get_feasibilities(s)
s must be a sequence of variable indices or names. Returns a list of the feasibility statuses of the variables with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_feasibilities(i) for i in s]
self.get_feasibilities(begin, end)
begin and end must be variable indices or variable names. Returns a list of the feasibility statuses of the variables with indices between begin and end, inclusive of end. Equivalent to self.get_feasibilities(range(begin, end + 1))
Note
Before you call this method from a solve callback, a solution must exist. That is, you must first create the solution by calling a CPLEX optimization method, and then you must verify that this optimization method generated a solution by checking its return value before you call the method get_feasibilities.

get_lower_bounds(self, *args)

 

Returns the lower bounds at the current node.

There are four forms by which get_lower_bounds may be called.

self.get_lower_bounds()
returns a list with the lower bounds for all the variables.
self.get_lower_bounds(i)
i must be a variable index or name. Returns the lower bound of the variable with index i.
self.get_lower_bounds(s)
s must be a sequence of variable indices or names. Returns a list of the lower bounds of the variables with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_lower_bounds(i) for i in s]
self.get_lower_bounds(begin, end)
begin and end must be variable indices or variable names. Returns a list of the lower bounds of the variables with indices between begin and end, inclusive of end. Equivalent to self.get_lower_bounds(range(begin, end + 1))

get_upper_bounds(self, *args)

 

Returns the upper bounds at the current node.

There are four forms by which get_upper_bounds may be called.

self.get_upper_bounds()
returns a list with the upper bounds for all the variables.
self.get_upper_bounds(i)
i must be a variable index or name. Returns the upper bound of the variable with index i.
self.get_upper_bounds(s)
s must be a sequence of variable indices or names. Returns a list of the upper bounds of the variables with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_upper_bounds(i) for i in s]
self.get_upper_bounds(begin, end)
begin and end must be variable indices or variable names. Returns a list of the upper bounds of the variables with indices between begin and end, inclusive of end. Equivalent to self.get_upper_bounds(range(begin, end + 1))

get_node_data(self)

 

Returns the user handle for the current node.

Returns None if no handle is set for the node.

set_node_data(self, data)

 

Set the user handle for the current node.

Returns the user handle previously set for this node (or None if no handle was set).

get_linear_slacks(self, *args)

 

Returns a set of linear slacks for the solution at the current node.

Can be called by four forms.

self.get_linear_slacks()
return all linear slack values from the problem at the current node.
self.get_linear_slacks(i)
i must be a linear constraint name or index. Returns the slack values associated with the linear constraint whose index or name is i.
self.get_linear_slacks(s)
s must be a sequence of linear constraint names or indices. Returns the slack values associated with the linear constraints with indices the members of s. Equivalent to [self.get_linear_slacks(i) for i in s]
self.get_linear_slacks(begin, end)
begin and end must be linear constraint indices with begin <= end or linear constraint names whose indices respect this order. Returns the slack values associated with the linear constraints with indices between begin and end, inclusive of end. Equivalent to self.get_linear_slacks(range(begin, end + 1)).

get_quadratic_slacks(self, *args)

 

Returns a set of quadratic slacks for the solution at the current node.

Can be called by four forms.

self.get_quadratic_slacks()
return all quadratic slack values from the problem at the current node.
self.get_quadratic_slacks(i)
i must be a quadratic constraint name or index. Returns the slack values associated with the quadratic constraint whose index or name is i.
self.get_quadratic_slacks(s)
s must be a sequence of quadratic constraint names or indices. Returns the slack values associated with the quadratic constraints with indices the members of s. Equivalent to [self.get_quadratic_slacks(i) for i in s]
self.get_quadratic_slacks(begin, end)
begin and end must be quadratic constraint indices or quadratic constraint names. Returns the slack values associated with the quadratic constraints with indices between begin and end, inclusive of end. Equivalent to self.get_quadratic_slacks(range(begin, end + 1)).

get_values(self, *args)

 

Returns the solution values at the current node.

In the case that the node LP is unbounded, this method returns a vector that corresponds to an unbounded direction, scaled so that at least one of its elements has magnitude cplex.infinity. Thus, often the vector can be used directly, for example to separate a lazy constraint. However, due to the presence of large values in the vector care must be taken to avoid potential numerical errors. If in doubt, rescale the vector, and use it as an unbounded ray rather than a primal vector.

There are four forms by which get_values may be called.

self.get_values()
returns the entire primal solution vector.
self.get_values(i)
i must be a variable index or name. Returns the solution value of the variable with index i.
self.get_values(s)
s must be a sequence of variable indices or names. Returns a list of the solution values of the variables with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_values(i) for i in s]
self.get_values(begin, end)
begin and end must be variable indices or variable names. Returns a list of the solution values of variables with indices between begin and end, inclusive of end. Equivalent to self.get_values(range(begin, end + 1))

get_SOS_feasibilities(self, *args)

 

Returns the current special ordered set feasibility status.

There are four forms by which get_SOS_feasibilities may be called.

Returns 1 if the SOS is feasible and 0 if it is not.

self.get_SOS_feasibilties()
Returns the feasibility statuses of all the special ordered sets.
self.get_SOS_feasibilities(i)
i must be a SOS index or name. Returns the feasibility status of the special ordered set with index i.
self.get_SOS_feasibilities(s)
s must be a sequence of SOS indices or names. Returns a list of the feasibility statuses of the special ordered sets with indices the members of s, in the same order as they appear in s. Equivalent to [self.get_SOS_feasibilities(i) for i in s]
self.get_SOS_feasibilities(begin, end)
begin and end must be SOS indices or SOS names. Returns a list of the feasibility statuses of the special ordered sets with indices between begin and end, inclusive of end. Equivalent to self.get_SOS_feasibilities(range(begin, end + 1))
Note
Before you call this method from a solve callback, a solution must exist. That is, you must first create the solution by calling a CPLEX optimization method, and then you must verify that this optimization method generated a solution by checking its return value before you call the method get_SOS_feasibilities.