Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for Params participating in Var bounds in contrib.parmest.utils.convert_params_to_vars #3375

Open
shermanjasonaf opened this issue Oct 2, 2024 · 0 comments
Labels

Comments

@shermanjasonaf
Copy link
Contributor

shermanjasonaf commented Oct 2, 2024

Summary

The method convert_params_to_vars(model, param_names, fix_vars) of contrib.parmest.utils does not seem to properly address cases where a Var bound is a mutable expression involving one or more of the Param objects specified through param_names

Steps to reproduce the issue

  1. Construct a model with at least one Var having a bound dependent on at least one Param.
>>> import pyomo.environ as pyo
>>> from pyomo.contrib.parmest.utils import convert_params_to_vars
>>> m = pyo.ConcreteModel()
>>> m.q = pyo.Param(initialize=1, mutable=True)
>>> m.v = pyo.Var(bounds=(0, m.q))
>>> m.c = pyo.Constraint(expr=m.v - pyo.log(m.q) ** 2 <= 0)
>>> m.pprint()
1 Param Declarations
    q : Size=1, Index=None, Domain=Any, Default=None, Mutable=True
        Key  : Value
        None :     1

1 Var Declarations
    v : Size=1, Index=None
        Key  : Lower : Value : Upper : Fixed : Stale : Domain
        None :     0 :  None :   1.0 : False :  True :  Reals

1 Constraint Declarations
    c : Size=1, Index=None, Active=True
        Key  : Lower : Body          : Upper : Active
        None :  -Inf : v - log(q)**2 :   0.0 :   True

3 Declarations: q v c
  1. Invoke convert_params_to_vars:
>>> mdl = convert_params_to_vars(m, param_names=["q"])
  1. Check the updated model:
>>> mdl.pprint()
2 Var Declarations
    q : Size=1, Index=None
        Key  : Lower : Value : Upper : Fixed : Stale : Domain
        None :  None :     1 :  None : False : False :  Reals
    v : Size=1, Index=None
        Key  : Lower : Value : Upper : Fixed : Stale : Domain
        None :     0 :  None :   1.0 : False :  True :  Reals

2 Constraint Declarations
    c : Size=1, Index=None, Active=False
        Key  : Lower : Body          : Upper : Active
        None :  -Inf : v - log(q)**2 :   0.0 :  False
    constraints : Size=1, Index={1}, Active=True
        Key : Lower : Body          : Upper : Active
          1 :  -Inf : v - log(q)**2 :   0.0 :   True

4 Declarations: v c q constraints
  1. Check the upper bound of v further. Notice that the upper bound is a Param object named q that is neither m.q nor mdl.q and does not live on the model mdl returned by convert_params_to_vars:
>>> mdl.v.ub
1
>>> mdl.v.upper
q
>>> mdl.v.upper is mdl.q
False
>>> mdl.v.upper is m.q
False
>>> type(mdl.v.upper)
<class 'pyomo.core.base.param.ScalarParam'>
>>> mdl.v.upper.model() is None
True

Information on your system

Pyomo version: 6.8.1dev0 @ df51e99
Python version: 3.12.3
Operating system: Ubuntu 20.04
How Pyomo was installed (PyPI, conda, source): source
Solver (if applicable):

Additional information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant