MindtPy_FP_Solver
(class from pyomo.contrib.mindtpy.feasibility_pump
)
- class pyomo.contrib.mindtpy.feasibility_pump.MindtPy_FP_Solver(**kwds)[source]
Bases:
_MindtPyAlgorithm
Decomposition solver for Mixed-Integer Nonlinear Programming (MINLP) problems.
The MindtPy (Mixed-Integer Nonlinear Decomposition Toolbox in Pyomo) solver applies a variety of decomposition-based approaches to solve Mixed-Integer Nonlinear Programming (MINLP) problems. This class includes:
Feasibility pump (FP)
- __init__(**kwds)
This is a common init method for all the MindtPy algorithms, so that we correctly set up the config arguments and initialize the generic parts of the algorithm state.
Methods
Initializes the decomposition algorithm.
Main loop for MindtPy Algorithms.
__init__
(**kwds)This is a common init method for all the MindtPy algorithms, so that we correctly set up the config arguments and initialize the generic parts of the algorithm state.
add_cuts
(dual_values[, linearize_active, ...])add_cuts_components
(model)add_regularization
()algorithm_should_terminate
(check_cycling)Checks if the algorithm should terminate at the given point.
available
([exception_flag])Solver is always available.
bounds_converged
()Define lists used for future data transfer.
Checks if the configuration options make sense.
Check if the subsolvers are available and licensed.
create_utility_block
(model, name)fix_dual_bound
(last_iter_cuts)Fix the dual bound when no-good cuts or tabu list is activated.
fp_loop
()Feasibility pump loop.
Calculate the dual integral.
Obtain primal integral, dual integral and primal dual gap integral.
Calculate the primal integral.
get_solution_name_obj
(main_mip_results)Handles the result of the latest iteration of solving the feasibility NLP subproblem.
handle_fp_main_tc
(fp_main_results)Handle the termination condition of the feasibility pump main problem.
handle_fp_subproblem_optimal
(fp_nlp)Copies the solution to the working model, updates bound, adds OA cuts / no-good cuts / increasing objective cut, calculates the duals and stores incumbent solution if it has been improved.
This function handles the result of the latest iteration of solving the MIP problem given an infeasible solution.
handle_main_max_timelimit
(main_mip, ...)This function handles the result of the latest iteration of solving the MIP problem given that solving the MIP takes too long.
handle_main_mip_termination
(main_mip, ...)handle_main_optimal
(main_mip[, update_bound])This function copies the results from 'solve_main' to the working model and updates the upper/lower bound.
handle_main_unbounded
(main_mip)This function handles the result of the latest iteration of solving the MIP problem given an unbounded solution due to the relaxation.
handle_nlp_subproblem_tc
(fixed_nlp, result)This function handles different terminaton conditions of the fixed-NLP subproblem.
handle_regularization_main_tc
(main_mip, ...)Handles the result of the regularization main problem.
handle_subproblem_infeasible
(fixed_nlp[, cb_opt])Solves feasibility problem and adds cut according to the specified strategy.
handle_subproblem_optimal
(fixed_nlp[, ...])This function copies the result of the NLP solver function ('solve_subproblem') to the working model, updates the bounds, adds OA and no-good cuts, and then stores the new solution if it is the new best solution.
handle_subproblem_other_termination
(...[, ...])Handles the result of the latest iteration of solving the fixed NLP subproblem given a solution that is neither optimal nor infeasible.
Modifies model by maximizing the number of activated binary variables.
init_rNLP
([add_oa_cuts])Initialize the problem by solving the relaxed NLP and then store the optimal variable values obtained from solving the rNLP.
Deactivate the nonlinear constraints to create the MIP problem.
Initialize and set options for MIP and NLP subsolvers.
iteration_cycling
()license_is_valid
()load_solution
()Determines whether the model is solvable by MindtPy.
objective_reformulation
()process_objective
([update_var_con_list])Process model objective function.
reached_iteration_limit
()reached_stalling_limit
()reached_time_limit
()Set update config for APPSI solvers.
Sets up the lazy OA using LazyConstraintCallback.
Set up the formatter and handler for logger.
Set up the MIP solver.
set_up_solve_data
(model)Set up the solve data.
Sets up the tabulist using IncumbentCallback.
Set up main problem for Feasibility Pump method.
Set up main problem/main regularization problem for OA, ECP, Feasibility Pump and ROA methods.
Set up main regularization problem for ROA method.
solve
(model, **kwds)Solve the model.
Solves a feasibility NLP if the fixed_nlp problem is infeasible.
This function solves the MIP main problem.
Solves the feasibility pump NLP subproblem.
This function solves the MIP main problem.
This function solves the MIP main problem.
Solves the Fixed-NLP (with fixed integers).
update_dual_bound
(bound_value)Update the dual bound.
Update the relative gap and the absolute gap.
update_primal_bound
(bound_value)Update the primal bound.
update_result
()update_suboptimal_dual_bound
(results)If the relaxed problem is not solved to optimality, the dual bound is updated according to the dual bound of relaxed problem.
version
()Return a 3-tuple describing the solver version.
Attributes
CONFIG
Member Documentation
- MindtPy_initialization()
Initializes the decomposition algorithm.
This function initializes the decomposition algorithm, which includes generating the initial cuts required to build the main MIP.
- MindtPy_iteration_loop()[source]
Main loop for MindtPy Algorithms.
This is the outermost function for the Outer Approximation algorithm in this package; this function controls the progress of solving the model.
- Raises:
ValueError – The strategy value is not correct or not included.
- algorithm_should_terminate(check_cycling)
Checks if the algorithm should terminate at the given point.
This function determines whether the algorithm should terminate based on the solver options and progress. (Sets the self.results.solver.termination_condition to the appropriate condition, i.e. optimal, maxIterations, maxTimeLimit).
- available(exception_flag=True)
Solver is always available. Though subsolvers may not be, they will raise an error when the time comes.
- build_ordered_component_lists(model)
Define lists used for future data transfer.
Also attaches ordered lists of the variables, constraints to the model so that they can be used for mapping back and forth.
- check_subsolver_validity()
Check if the subsolvers are available and licensed.
- fix_dual_bound(last_iter_cuts)
Fix the dual bound when no-good cuts or tabu list is activated.
- Parameters:
last_iter_cuts (bool) – Whether the cuts in the last iteration have been added.
- fp_loop()
Feasibility pump loop.
This is the outermost function for the Feasibility Pump algorithm in this package; this function controls the progress of solving the model.
- Raises:
ValueError – MindtPy unable to handle the termination condition of the FP-NLP subproblem.
- get_dual_integral()
Calculate the dual integral. Ref: The confined primal integral. [http://www.optimization-online.org/DB_FILE/2020/07/7910.pdf]
- Returns:
The dual integral.
- Return type:
- get_integral_info()
Obtain primal integral, dual integral and primal dual gap integral.
- get_primal_integral()
Calculate the primal integral. Ref: The confined primal integral. [http://www.optimization-online.org/DB_FILE/2020/07/7910.pdf]
- Returns:
The primal integral.
- Return type:
- handle_feasibility_subproblem_tc(subprob_terminate_cond, MindtPy)
Handles the result of the latest iteration of solving the feasibility NLP subproblem.
- Parameters:
subprob_terminate_cond (Pyomo TerminationCondition) – The termination condition of the feasibility NLP subproblem.
MindtPy (Pyomo Block) – The MindtPy_utils block.
- handle_fp_main_tc(fp_main_results)
Handle the termination condition of the feasibility pump main problem.
- Parameters:
fp_main_results (SolverResults) – The results from solving the FP main problem.
- Returns:
True if FP loop should terminate, False otherwise.
- Return type:
- handle_fp_subproblem_optimal(fp_nlp)
Copies the solution to the working model, updates bound, adds OA cuts / no-good cuts / increasing objective cut, calculates the duals and stores incumbent solution if it has been improved.
- Parameters:
fp_nlp (Pyomo model) – The feasibility pump NLP subproblem.
- handle_main_infeasible()
This function handles the result of the latest iteration of solving the MIP problem given an infeasible solution.
- handle_main_max_timelimit(main_mip, main_mip_results)
This function handles the result of the latest iteration of solving the MIP problem given that solving the MIP takes too long.
- Parameters:
main_mip (Pyomo model) – The MIP main problem.
main_mip_results ([type]) – Results from solving the MIP main subproblem.
- handle_main_optimal(main_mip, update_bound=True)
This function copies the results from ‘solve_main’ to the working model and updates the upper/lower bound. This function is called after an optimal solution is found for the main problem.
- Parameters:
main_mip (Pyomo model) – The MIP main problem.
update_bound (bool, optional) – Whether to update the bound, by default True. Bound will not be updated when handling regularization problem.
- handle_main_unbounded(main_mip)
This function handles the result of the latest iteration of solving the MIP problem given an unbounded solution due to the relaxation.
- Parameters:
main_mip (Pyomo model) – The MIP main problem.
- Returns:
main_mip_results – The results of the bounded main problem.
- Return type:
- handle_nlp_subproblem_tc(fixed_nlp, result, cb_opt=None)
This function handles different terminaton conditions of the fixed-NLP subproblem.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
result (SolverResults) – Results from solving the NLP subproblem.
cb_opt (SolverFactory, optional) – The gurobi_persistent solver, by default None.
- handle_regularization_main_tc(main_mip, main_mip_results)
Handles the result of the regularization main problem.
- Parameters:
main_mip (Pyomo model) – The MIP main problem.
main_mip_results (SolverResults) – Results from solving the regularization main subproblem.
- Raises:
ValueError – MindtPy unable to handle the regularization problem termination condition.
- handle_subproblem_infeasible(fixed_nlp, cb_opt=None)
Solves feasibility problem and adds cut according to the specified strategy.
This function handles the result of the latest iteration of solving the NLP subproblem given an infeasible solution and copies the solution of the feasibility problem to the working model.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
cb_opt (SolverFactory, optional) – The gurobi_persistent solver, by default None.
- handle_subproblem_optimal(fixed_nlp, cb_opt=None, fp=False)
This function copies the result of the NLP solver function (‘solve_subproblem’) to the working model, updates the bounds, adds OA and no-good cuts, and then stores the new solution if it is the new best solution. This function handles the result of the latest iteration of solving the NLP subproblem given an optimal solution.
- Parameters:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
cb_opt (SolverFactory, optional) – The gurobi_persistent solver, by default None.
fp (bool, optional) – Whether it is in the loop of feasibility pump, by default False.
- handle_subproblem_other_termination(fixed_nlp, termination_condition, cb_opt=None)
Handles the result of the latest iteration of solving the fixed 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.
cb_opt (SolverFactory, optional) – The gurobi_persistent solver, by default None.
- Raises:
ValueError – MindtPy unable to handle the NLP subproblem termination condition.
- init_max_binaries()
Modifies model by maximizing the number of activated binary variables.
Note - The user would usually want to call solve_subproblem after an invocation of this function.
- Raises:
ValueError – MILP main problem is infeasible.
ValueError – MindtPy unable to handle the termination condition of the MILP main problem.
- init_rNLP(add_oa_cuts=True)
Initialize the problem by solving the relaxed NLP and then store the optimal variable values obtained from solving the rNLP.
- Parameters:
add_oa_cuts (Bool) – Whether add OA cuts after solving the relaxed NLP problem.
- Raises:
ValueError – MindtPy unable to handle the termination condition of the relaxed NLP.
- initialize_subsolvers()
Initialize and set options for MIP and NLP subsolvers.
- model_is_valid()
Determines whether the model is solvable by MindtPy.
- Returns:
True if model is solvable in MindtPy, False otherwise.
- Return type:
- process_objective(update_var_con_list=True)
Process model objective function.
Check that the model has only 1 valid objective. If the objective is nonlinear, move it into the constraints. If no objective function exists, emit a warning and create a dummy objective.
- Parameters:
update_var_con_list (bool, optional) – Whether to update the variable/constraint/objective lists, by default True. Currently, update_var_con_list will be set to False only when add_regularization is not None in MindtPy.
- set_appsi_solver_update_config()
Set update config for APPSI solvers.
- set_up_lazy_OA_callback()
Sets up the lazy OA using LazyConstraintCallback. Currently only support CPLEX and Gurobi.
- set_up_logger()
Set up the formatter and handler for logger.
- set_up_mip_solver()
Set up the MIP solver.
- Returns:
mainopt – The customized MIP solver.
- Return type:
SolverFactory
- set_up_solve_data(model)
Set up the solve data.
- Parameters:
model (Pyomo model) – The original model to be solved in MindtPy.
- set_up_tabulist_callback()
Sets up the tabulist using IncumbentCallback. Currently only support CPLEX.
- setup_fp_main()
Set up main problem for Feasibility Pump method.
- setup_main()
Set up main problem/main regularization problem for OA, ECP, Feasibility Pump and ROA methods.
- setup_regularization_main()
Set up main regularization problem for ROA method.
- solve(model, **kwds)
Solve the model.
- Parameters:
model (Pyomo model) – The MINLP model to be solved.
- Returns:
results – Results from solving the MINLP problem by MindtPy.
- Return type:
- solve_feasibility_subproblem()
Solves a feasibility NLP if the fixed_nlp problem is infeasible.
- Returns:
feas_subproblem (Pyomo model) – Feasibility NLP from the model.
feas_soln (SolverResults) – Results from solving the feasibility NLP.
- solve_fp_main()
This function solves the MIP main problem.
- Returns:
self.mip (Pyomo model) – The MIP stored in self.
main_mip_results (SolverResults) – Results from solving the main MIP.
- solve_fp_subproblem()
Solves the feasibility pump NLP subproblem.
This function sets up the ‘fp_nlp’ by relax integer variables. precomputes dual values, deactivates trivial constraints, and then solves NLP model.
- Returns:
fp_nlp (Pyomo model) – Fixed-NLP from the model.
results (SolverResults) – Results from solving the fixed-NLP subproblem.
- solve_main()
This function solves the MIP main problem.
- Returns:
self.mip (Pyomo model) – The MIP stored in self.
main_mip_results (SolverResults) – Results from solving the main MIP.
- solve_regularization_main()
This function solves the MIP main problem.
- Returns:
self.mip (Pyomo model) – The MIP stored in self.
main_mip_results (SolverResults) – Results from solving the main MIP.
- solve_subproblem()
Solves the Fixed-NLP (with fixed integers).
This function sets up the ‘fixed_nlp’ by fixing binaries, sets continuous variables to their initial var values, precomputes dual values, deactivates trivial constraints, and then solves NLP model.
- Returns:
fixed_nlp (Pyomo model) – Integer-variable-fixed NLP model.
results (SolverResults) – Results from solving the Fixed-NLP.
- update_dual_bound(bound_value)
Update the dual bound.
Call after solving relaxed problem, including relaxed NLP and MIP main problem. Use the optimal primal bound of the relaxed problem to update the dual bound.
- Parameters:
bound_value (float) – The input value used to update the dual bound.
- update_gap()
Update the relative gap and the absolute gap.
- update_primal_bound(bound_value)
Update the primal bound.
Call after solve fixed NLP subproblem. Use the optimal primal bound of the relaxed problem to update the dual bound.
- Parameters:
bound_value (float) – The input value used to update the primal bound.
- update_suboptimal_dual_bound(results)
If the relaxed problem is not solved to optimality, the dual bound is updated according to the dual bound of relaxed problem.
- Parameters:
results (SolverResults) – Results from solving the relaxed problem. The dual bound of the relaxed problem can only be obtained from the result object.
- version()
Return a 3-tuple describing the solver version.