From 6c8927a6599772f52cf305e7c4acd9f0b3e8760e Mon Sep 17 00:00:00 2001 From: ZedongPeng Date: Sat, 18 May 2024 16:59:06 -0400 Subject: [PATCH] update constraint tolerance --- pyomo/contrib/mindtpy/cut_generation.py | 4 ++-- pyomo/contrib/mindtpy/single_tree.py | 4 ++-- pyomo/contrib/mindtpy/util.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyomo/contrib/mindtpy/cut_generation.py b/pyomo/contrib/mindtpy/cut_generation.py index e932755e9fd..aa7894eab18 100644 --- a/pyomo/contrib/mindtpy/cut_generation.py +++ b/pyomo/contrib/mindtpy/cut_generation.py @@ -109,7 +109,7 @@ def add_oa_cuts( constr.has_ub() and ( linearize_active - and abs(constr.uslack()) < config.zero_tolerance + and abs(constr.uslack()) < config.constraint_tolerance ) or (linearize_violated and constr.uslack() < 0) or (config.linearize_inactive and constr.uslack() > 0) @@ -147,7 +147,7 @@ def add_oa_cuts( constr.has_lb() and ( linearize_active - and abs(constr.lslack()) < config.zero_tolerance + and abs(constr.lslack()) < config.constraint_tolerance ) or (linearize_violated and constr.lslack() < 0) or (config.linearize_inactive and constr.lslack() > 0) diff --git a/pyomo/contrib/mindtpy/single_tree.py b/pyomo/contrib/mindtpy/single_tree.py index 05ba6bbee86..be5c5cdbff7 100644 --- a/pyomo/contrib/mindtpy/single_tree.py +++ b/pyomo/contrib/mindtpy/single_tree.py @@ -162,7 +162,7 @@ def add_lazy_oa_cuts( constr.has_ub() and ( linearize_active - and abs(constr.uslack()) < config.zero_tolerance + and abs(constr.uslack()) < config.constraint_tolerance ) or (linearize_violated and constr.uslack() < 0) or (config.linearize_inactive and constr.uslack() > 0) @@ -201,7 +201,7 @@ def add_lazy_oa_cuts( constr.has_lb() and ( linearize_active - and abs(constr.lslack()) < config.zero_tolerance + and abs(constr.lslack()) < config.constraint_tolerance ) or (linearize_violated and constr.lslack() < 0) or (config.linearize_inactive and constr.lslack() > 0) diff --git a/pyomo/contrib/mindtpy/util.py b/pyomo/contrib/mindtpy/util.py index 1543497838f..154b5905f64 100644 --- a/pyomo/contrib/mindtpy/util.py +++ b/pyomo/contrib/mindtpy/util.py @@ -581,11 +581,11 @@ def set_solver_constraint_violation_tolerance( The specific configurations for MindtPy. """ if solver_name == 'baron': - opt.options['AbsConFeasTol'] = config.zero_tolerance + opt.options['AbsConFeasTol'] = config.constraint_tolerance elif solver_name in {'ipopt', 'appsi_ipopt'}: - opt.options['constr_viol_tol'] = config.zero_tolerance + opt.options['constr_viol_tol'] = config.constraint_tolerance elif solver_name == 'cyipopt': - opt.config.options['constr_viol_tol'] = config.zero_tolerance + opt.config.options['constr_viol_tol'] = config.constraint_tolerance elif solver_name == 'gams': if config.nlp_solver_args['solver'] in { 'ipopt', @@ -600,7 +600,7 @@ def set_solver_constraint_violation_tolerance( ) if config.nlp_solver_args['solver'] in {'ipopt', 'ipopth'}: opt.options['add_options'].append( - 'constr_viol_tol ' + str(config.zero_tolerance) + 'constr_viol_tol ' + str(config.constraint_tolerance) ) if warm_start: # Ipopt warmstart options @@ -614,15 +614,15 @@ def set_solver_constraint_violation_tolerance( ) elif config.nlp_solver_args['solver'] == 'conopt': opt.options['add_options'].append( - 'RTNWMA ' + str(config.zero_tolerance) + 'RTNWMA ' + str(config.constraint_tolerance) ) elif config.nlp_solver_args['solver'] == 'msnlp': opt.options['add_options'].append( - 'feasibility_tolerance ' + str(config.zero_tolerance) + 'feasibility_tolerance ' + str(config.constraint_tolerance) ) elif config.nlp_solver_args['solver'] == 'baron': opt.options['add_options'].append( - 'AbsConFeasTol ' + str(config.zero_tolerance) + 'AbsConFeasTol ' + str(config.constraint_tolerance) ) opt.options['add_options'].append('$offecho')