LazyOACallback_cplex
(class from pyomo.contrib.mindtpy.single_tree)
- class pyomo.contrib.mindtpy.single_tree.LazyOACallback_cplex[source]
Bases:
objectInherent class in CPLEX to call Lazy callback.
- __init__()
Methods
__init__()add_lazy_affine_cuts(mindtpy_solver, config, opt)Adds affine cuts using MCPP.
add_lazy_no_good_cuts(var_values, ...[, ...])Adds no-good cuts.
add_lazy_oa_cuts(target_model, dual_values, ...)Linearizes nonlinear constraints; add the OA cuts through CPLEX inherent function self.add() For nonconvex problems, turn on 'config.add_slack'.
copy_lazy_var_list_values(opt, from_list, ...)This function copies variable values from one list to another.
handle_lazy_main_feasible_solution(main_mip, ...)This function is called during the branch and bound of main mip, more exactly when a feasible solution is found and LazyCallback is activated.
handle_lazy_subproblem_infeasible(fixed_nlp, ...)Solves feasibility NLP subproblem and adds cuts according to the specified strategy.
handle_lazy_subproblem_optimal(fixed_nlp, ...)This function copies the optimal solution of the fixed NLP subproblem to the MIP main problem(explanation see below), updates bound, adds OA and no-good cuts, stores incumbent solution if it has been improved.
Handles the result of the latest iteration of solving the NLP subproblem given a solution that is neither optimal nor infeasible.
Member Documentation
- add_lazy_affine_cuts(mindtpy_solver, config, opt)[source]
Adds affine cuts using MCPP.
Add affine cuts through CPLEX inherent function self.add().
- Parameters:
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
- add_lazy_no_good_cuts(var_values, mindtpy_solver, config, opt, feasible=False)[source]
Adds no-good cuts.
Add the no-good cuts through Cplex inherent function self.add().
- Parameters:
var_values (list) – The variable values of the incumbent solution, used to generate the cut.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
feasible (bool, optional) – Whether the integer combination yields a feasible or infeasible NLP, by default False.
- Raises:
ValueError – The value of binary variable is not 0 or 1.
- add_lazy_oa_cuts(target_model, dual_values, mindtpy_solver, config, opt, linearize_active=True, linearize_violated=True)[source]
Linearizes nonlinear constraints; add the OA cuts through CPLEX inherent function self.add() For nonconvex problems, turn on ‘config.add_slack’. Slack variables will always be used for nonlinear equality constraints.
- Parameters:
target_model (Pyomo model) – The MIP main problem.
dual_values (list) – The value of the duals for each constraint.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
linearize_active (bool, optional) – Whether to linearize the active nonlinear constraints, by default True.
linearize_violated (bool, optional) – Whether to linearize the violated nonlinear constraints, by default True.
- copy_lazy_var_list_values(opt, from_list, to_list, config, skip_stale=False, skip_fixed=True)[source]
This function copies variable values from one list to another. Rounds to Binary/Integer if necessary. Sets to zero for NonNegativeReals if necessary.
- Parameters:
opt (SolverFactory) – The cplex_persistent solver.
from_list (list) – The variable list that provides the values to copy from.
to_list (list) – The variable list that needs to set value.
config (ConfigBlock) – The specific configurations for MindtPy.
skip_stale (bool, optional) – Whether to skip the stale variables, by default False.
skip_fixed (bool, optional) – Whether to skip the fixed variables, by default True.
- handle_lazy_main_feasible_solution(main_mip, mindtpy_solver, config, opt)[source]
This function is called during the branch and bound of main mip, more exactly when a feasible solution is found and LazyCallback is activated. Copy the result to working model and update upper or lower bound. In LP-NLP, upper or lower bound are updated during solving the main problem.
- Parameters:
main_mip (Pyomo model) – The MIP main problem.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
- handle_lazy_subproblem_infeasible(fixed_nlp, mindtpy_solver, config, opt)[source]
Solves feasibility NLP subproblem and adds cuts according to the specified strategy.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
- handle_lazy_subproblem_optimal(fixed_nlp, mindtpy_solver, config, opt)[source]
This function copies the optimal solution of the fixed NLP subproblem to the MIP main problem(explanation see below), updates bound, adds OA and no-good cuts, stores incumbent solution if it has been improved.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
opt (SolverFactory) – The cplex_persistent solver.
- handle_lazy_subproblem_other_termination(fixed_nlp, termination_condition, mindtpy_solver, config)[source]
Handles the result of the latest iteration of solving the NLP subproblem given a solution that is neither optimal nor infeasible.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
termination_condition (Pyomo TerminationCondition) – The termination condition of the fixed NLP subproblem.
mindtpy_solver (object) – The mindtpy solver class.
config (ConfigBlock) – The specific configurations for MindtPy.
- Raises:
ValueError – MindtPy unable to handle the termination condition of the fixed NLP subproblem.