-
Notifications
You must be signed in to change notification settings - Fork 563
Description
Summary
When we create a temporary block and then solve using ipopt_v2 with scale_model=True, it is known that scaling factors defined in the original model are not copied over or used. However, the solver also appears to ignore scaling factors that are manually defined on the temporary block.
Steps to reproduce the issue
# temporary_block_not_scaled.py
import pyomo.environ as pyo
from pyomo.util.subsystems import create_subsystem_block
# import idaes to allow use of ipopt
import idaes
m = pyo.ConcreteModel()
m.x = pyo.Var(initialize=1e-4, bounds=(0, None))
m.con = pyo.Constraint(expr=m.x ** 2 == 1+1e-12)
t_block = create_subsystem_block([m.con], [m.x])
t_block.scaling_factor = pyo.Suffix(direction=pyo.Suffix.EXPORT)
t_block.scaling_factor[m.x] = 1e4
solver_obj = pyo.SolverFactory("ipopt_v2")
solver_obj.config.writer_config.scale_model = True
solver_obj.options.max_iter = 0
print(f"x value: {m.x.value}")
solver_obj.solve(t_block)
# Scaling factor of 1e4 means the value shouldn't be pushed
print(f"x value: {m.x.value}")
The default IPOPT configuration has bound_push=1e-2. Since we're using a scaling factor of 1e4 for m.x, its initial value of 1e-4 should not be changed---the scaled value of 1 is further than the bound push of 1e-2. However, m.x has its value pushed to 1e-2, which indicates the unscaled value of x is getting passed to the solver.
x value: 0.0001
x value: 0.00999999Information on your system
Pyomo version: 6.9.5
Python version: 3.12
Operating system: Windows 11
How Pyomo was installed (PyPI, conda, source): pip
Solver (if applicable): ipopt_v2