Skip to content

Commit d4e4e0a

Browse files
committed
add small test
1 parent 29e0395 commit d4e4e0a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pyomo/contrib/pynumero/interfaces/tests/test_nlp.py

+19
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,25 @@ def test_indices_methods(self):
699699
dense_hess = hess.todense()
700700
self.assertTrue(np.array_equal(dense_hess, expected_hess))
701701

702+
def test_subblock_scaling(self):
703+
m = pyo.ConcreteModel()
704+
m.b = b = pyo.Block()
705+
b.x = pyo.Var(bounds=(5e-17, 5e-16), initialize=1e-16)
706+
b.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT)
707+
b.scaling_factor[b.x] = 1e16
708+
709+
b.c = pyo.Constraint(rule=b.x == 1e-16)
710+
b.scaling_factor[b.c] = 1e16
711+
712+
b.o = pyo.Objective(expr=b.x)
713+
b.scaling_factor[b.o] = 1e16
714+
715+
nlp = PyomoNLP(m)
716+
717+
assert nlp.get_obj_scaling() == 1e16
718+
assert nlp.get_primals_scaling()[0] == 1e16
719+
assert nlp.get_constraints_scaling()[0] == 1e16
720+
702721
def test_no_objective(self):
703722
m = pyo.ConcreteModel()
704723
m.x = pyo.Var()

0 commit comments

Comments
 (0)