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

Class LazyConstraintCallback


Subclassable class for lazy constraint callback classes.

This callback will be used when CPLEX finds a new integer feasible solution and when CPLEX finds that the LP relaxation at the current node is unbounded.

Note:

The lazy constraint callback may be invoked during MIP start processing. In that case get_solution_source returns mip_start_solution. When this value is returned some special considerations apply:

  • MIP start processing occurs very early in the solution process. At this point no search tree is setup yet and there are no search tree nodes yet. Consequently, a lot of the callback methods that require a node context will fail in this situation.
  • Lazy constraints separated when processing a MIP start will be discarded after that MIP start has been processed. This means that the callback may have to separate the same constraint again for the next MIP start or for a solution that is found later in the solution process.
Instance Methods
 
add(self, constraint, sense, rhs, use=0)
Adds a linear constraint to the current subproblem.
 
add_local(self, constraint, sense, rhs)
Adds a linear local constraint to the current subproblem.
 
is_unbounded_node(self)
Returns True if the current LP relaxation is unbounded, False otherwise.
 
get_solution_source(self)
Returns the source of the solution for which the lazy constraint callback was invoked.

Inherited from ControlCallback: get_SOS_feasibilities, get_feasibilities, get_linear_slacks, get_lower_bounds, get_node_ID, get_node_data, get_objective_value, get_pseudo_costs, get_quadratic_slacks, get_upper_bounds, get_values, set_node_data

Inherited from MIPCallback: get_current_node_depth, 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, get_thread_num, has_incumbent

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

Class Variables
  use_constraint = UseConstraint()
See UseConstraint()

Inherited from ControlCallback: feasibility_status

Inherited from MIPInfoCallback: cut_type, quality_metric

Method Details

add(self, constraint, sense, rhs, use=0)

 

Adds a linear constraint to the current subproblem.

constraint must be either a SparsePair instance or a list of two lists, the first of which specifies variables, the second of which specifies the values of the constraint.

sense must be a single-character string; ("L", "G", "E")

rhs is a float, specifying the righthand side of the constraint.

use indicates under what circumstances the constraint should be used. It can take the following values:

self.use_constraint.force (default) : force CPLEX to use the constraint self.use_constraint.purge : allow CPLEX to purge the constraint

When you add a lazy constraint with the nondefault value purge, you authorize CPLEX to purge (that is, to eliminate) the lazy constraint under certain circumstances, for example, if the lazy constraint becomes slack. Consequently, in view of such purging, you must not assume that any previously added constraints are still in current relaxation. In other words, the purged lazy constraint may be violated in subsequent relaxations.

add_local(self, constraint, sense, rhs)

 

Adds a linear local constraint to the current subproblem.

A local constraint is a constraint that will only be added to the problem at the current node and the subtree rooted by the current node. It will not be added to the constraint matrix of the original model.

constraint must be either a SparsePair instance or a list of two lists, the first of which specifies variables, the second of which specifies the values of the constraint.

sense must be a single-character string; ("L", "G", "E")

rhs is a float, specifying the righthand side of the constraint.

get_solution_source(self)

 

Returns the source of the solution for which the lazy constraint callback was invoked.

The possible return values are:

IncumbentCallback.solution_source.node_solution: The integral solution is the solution to the LP relaxation of a node in the MIP search tree.

IncumbentCallback.solution_source.heuristic_solution: The integral solution has been found by a CPLEX internal heuristic.

IncumbentCallback.solution_source.mipstart_solution: The integral solution has been found during MIP start processing.