Package cplex :: Module callbacks :: Class HeuristicCallback
 

Class HeuristicCallback


Subclassable class for heuristic callback classes.

This callback will be used after solving each subproblem and at the root node before each round of cuts is added to the problem and resolved.

Instance Methods
 
set_bounds(self, *args)
Sets the bounds for a set of variables.
 
set_solution(self, solution, objective_value=None)
Sets a solution to be used as the incumbent.

Inherited from HSCallback: get_cplex_status, is_dual_feasible, is_primal_feasible, solve

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

Inherited from HSCallback: method, status

Inherited from ControlCallback: feasibility_status

Inherited from MIPInfoCallback: cut_type, quality_metric

Method Details

set_bounds(self, *args)

 

Sets the bounds for a set of variables.

Can be called by two forms.

self.set_bounds(i, lb, ub)
i must be a variable name or index and lb and ub must be real numbers. Sets the lower bound and upper bound of the variable whose index or name is i to lb and ub, respectively.
self.set_lower_bounds(seq_of_triples)
seq_of_triples must be a list or tuple of tuples (i, lb, ub), each of which consists of a variable name or index and two real numbers. Sets the bounds of the specified variables to the corresponding values. Equivalent to [self.set_lower_bounds(triple[0], triple[1], triple[2]) for triple in seq_of_triples].
Note
The variables specified must not have been removed by presolve.
Note
These bound changes affect only the problem at the current node.

set_solution(self, solution, objective_value=None)

 

Sets a solution to be used as the incumbent.

solution is either an instance of SparsePair or a sequence of length two. If it is a sequence, the first entry is a sequence of variable indices or names whose values are to be changed and the second entry is a sequence of floats with the corresponding new solution values. Variables whose indices are not specified remain unchanged.

If objective_value is specified, it is taken as the objective value of the new solution. Otherwise, the objective value is computed.

Do not call this method multiple times. Calling it again will overwrite any previously specified solution.