From 0b4d16b6d8bc334949481ff69f8e7370d132a1b6 Mon Sep 17 00:00:00 2001 From: Bernard Knueven Date: Thu, 20 Jun 2024 20:51:10 -0600 Subject: [PATCH] modify tests so the fail on main --- .../tests/test_external_grey_box_model.py | 45 +++++++------- .../tests/test_pyomo_grey_box_nlp.py | 60 ++++++++++--------- 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py b/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py index 188aba30eeb..f0a0dc545af 100644 --- a/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py +++ b/pyomo/contrib/pynumero/interfaces/tests/test_external_grey_box_model.py @@ -1846,14 +1846,15 @@ def test_scaling_pyomo_model_only(self): ) m.obj = pyo.Objective(expr=(m.egb.outputs['Pout'] - 20) ** 2) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) # m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable # m.scaling_factor[m.hin] = 1.8 m.scaling_factor[m.hout] = 1.9 # m.scaling_factor[m.incon] = 2.1 @@ -1971,14 +1972,15 @@ def test_scaling_pyomo_model_and_greybox(self): ) m.obj = pyo.Objective(expr=(m.egb.outputs['Pout'] - 20) ** 2) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) # m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable # m.scaling_factor[m.hin] = 1.8 m.scaling_factor[m.hout] = 1.9 # m.scaling_factor[m.incon] = 2.1 @@ -2063,14 +2065,15 @@ def test_external_greybox_solve_scaling(self): ) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable m.scaling_factor[m.mu] = 1.9 m.scaling_factor[m.pincon] = 2.2 diff --git a/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py b/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py index 1dcdc2a6237..e4842652278 100644 --- a/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py +++ b/pyomo/contrib/pynumero/interfaces/tests/test_pyomo_grey_box_nlp.py @@ -956,14 +956,15 @@ def test_scaling_pyomo_model_only(self): ) m.obj = pyo.Objective(expr=(m.egb.outputs['Pout'] - 20) ** 2) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) # m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable # m.scaling_factor[m.hin] = 1.8 m.scaling_factor[m.hout] = 1.9 # m.scaling_factor[m.incon] = 2.1 @@ -2267,14 +2268,15 @@ def test_scaling_pyomo_model_only(self): ) m.obj = pyo.Objective(expr=(m.egb.outputs['Pout'] - 20) ** 2) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) # m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable # m.scaling_factor[m.hin] = 1.8 m.scaling_factor[m.hout] = 1.9 # m.scaling_factor[m.incon] = 2.1 @@ -2392,14 +2394,15 @@ def test_scaling_pyomo_model_and_greybox(self): ) m.obj = pyo.Objective(expr=(m.egb.outputs['Pout'] - 20) ** 2) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) # m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable # m.scaling_factor[m.hin] = 1.8 m.scaling_factor[m.hout] = 1.9 # m.scaling_factor[m.incon] = 2.1 @@ -2484,14 +2487,15 @@ def test_external_greybox_solve_scaling(self): ) m.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) + m.egb.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT) m.scaling_factor[m.obj] = 0.1 # scale the objective - m.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable - m.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable - m.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable - # m.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable - m.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable - m.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable - m.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable + m.egb.scaling_factor[m.egb.inputs['Pin']] = 1.1 # scale the variable + m.egb.scaling_factor[m.egb.inputs['c']] = 1.2 # scale the variable + m.egb.scaling_factor[m.egb.inputs['F']] = 1.3 # scale the variable + # m.egb.scaling_factor[m.egb.inputs['P1']] = 1.4 # scale the variable + m.egb.scaling_factor[m.egb.inputs['P3']] = 1.5 # scale the variable + m.egb.scaling_factor[m.egb.outputs['P2']] = 1.6 # scale the variable + m.egb.scaling_factor[m.egb.outputs['Pout']] = 1.7 # scale the variable m.scaling_factor[m.mu] = 1.9 m.scaling_factor[m.pincon] = 2.2