Skip to content

Commit

Permalink
add use_convex_relaxation option
Browse files Browse the repository at this point in the history
  • Loading branch information
ZedongPeng committed May 8, 2024
1 parent c650fd4 commit 859a6f2
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 408 deletions.
23 changes: 20 additions & 3 deletions pyomo/contrib/mindtpy/algorithm_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ def setup_main(self):
* sum(v for v in MindtPy.cuts.slack_vars.values())
)
main_objective = MindtPy.objective_list[-1]
if not config.use_obbt:
if not config.use_convex_relaxation:
MindtPy.del_component('mip_obj')
MindtPy.mip_obj = Objective(
expr=main_objective.expr
Expand Down Expand Up @@ -2402,6 +2402,15 @@ def check_config(self):
):
self.load_solutions = False

if config.use_obbt:
config.use_convex_relaxation = True

if config.add_slack and config.use_convex_relaxation:
raise NotImplementedError(
"In current implementation, use_convex_relaxation "
"and add_slack cannot be activated at the same time."
)

################################################################################################################################
# Feasibility Pump

Expand Down Expand Up @@ -2681,10 +2690,18 @@ def initialize_mip_problem(self):

self.mip = self.working_model.clone()

# OBBT
if config.use_obbt:
# Convex relaxation
if config.use_convex_relaxation:
with time_code(self.timing, 'presolve - convex relaxation'):
self.mip.coramin_relaxation = coramin.relaxations.relax(self.mip)
# If the variable is fixed or have lower bounds equal to their upper bounds, Coramin recognizes that this type of constraint is linear under those conditions and will just return the original constraint.
# MindtPy need to manually deactivate the original constraint.
for rel in coramin.relaxations.relaxation_data_objects(
self.mip.coramin_relaxation
):
if rel.component("_original_constraint") is not None:
rel._original_constraint.deactivate()

# TODO: only needed for avm cuts
# for rel in coramin.relaxations.relaxation_data_objects(
# self.mip.coramin_relaxation
Expand Down
10 changes: 9 additions & 1 deletion pyomo/contrib/mindtpy/config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,18 @@ def _add_common_configs(CONFIG):
domain=bool,
),
)
CONFIG.declare(
'use_convex_relaxation',
ConfigValue(
default=False,
description='Use convex relaxation to tighten the feasible region of the problem.',
domain=bool,
),
)
CONFIG.declare(
'use_obbt',
ConfigValue(
default=True,
default=False,
description='Use obbt to tighten the feasible region of the problem.',
domain=bool,
),
Expand Down
2 changes: 1 addition & 1 deletion pyomo/contrib/mindtpy/outer_approximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def check_config(self):
'sqp_lag',
}:
self.regularization_mip_type = 'MIQP'
_MindtPyAlgorithm.check_config(self)
super().check_config()

def initialize_mip_problem(self):
"""Deactivate the nonlinear constraints to create the MIP problem."""
Expand Down
Loading

0 comments on commit 859a6f2

Please sign in to comment.