pyomo-cvp
Control vector parameterization for pyomo.dae.
pyomo.dae makes control profiles piecewise-constant by adding linking
equality constraints (reduce_collocation_points), which keeps every
collocation-point copy of the control in the model plus one equation per
tied copy. pyomo-cvp does it by elimination: after any DAE
discretization, each declared control keeps only its profile's free values,
every other copy is substituted out of the model, and the component is
replaced under its own name. The model you solve is the model you meant:
no extra variables, no linking constraints.
On the classic race car problem (nfe=15, ncp=3, Lagrange-Radau):
| control vars | linking constraints | |
|---|---|---|
reduce_collocation_points |
46 | 30 |
cvp.parameterize |
15 | 0 |
Install
pip install pyomo-cvp
Usage
import pyomo.environ as pyo
from pyomo_cvp import declare_profile, control_value
# ... build a pyomo.dae model with control m.u over ContinuousSet m.tau ...
declare_profile(m.u, wrt=m.tau, profile="piecewise_constant")
pyo.TransformationFactory("dae.collocation").apply_to(
m, nfe=15, ncp=3, scheme="LAGRANGE-RADAU")
pyo.TransformationFactory("cvp.parameterize").apply_to(m)
# m.u now has exactly nfe members, one per finite element
pyo.SolverFactory("ipopt").solve(m)
control_value(m.u, 0.5) # evaluate the profile at any time
The explicit form (no declaration) is equivalent:
pyo.TransformationFactory("cvp.parameterize").apply_to(
m, var=m.u, contset=m.tau, profile="piecewise_constant")
Works with any pyomo.dae discretization: Lagrange-Radau,
Lagrange-Legendre (where it also eliminates the dangling element-boundary
copies the constraint-based approach leaves unconstrained), or finite
difference. Controls may carry additional (non-time) indices.
Profiles
'piecewise_constant'--- one free value per finite element, indexed by the element's start time (u[t0]exists). The control holds one value per element and changes value at the element starts. Inside an element,u[t]is that element's value. At an element boundary the control jumps, sou[t]there could mean the value before the jump or the value after it, and the two uses need different answers: model equations (ODEs, and any constraint indexed over the time set) describe the interval that ends at the boundary, so thereu[t]is the value before the jump; objectives and cost constraints charge for the decision made at that instant, so thereu[t]is the value after the jump. At the final time no new value starts: model equations use the last value, and a cost that references the control at the final time is an error.'piecewise_linear'--- one free value per element boundary, continuous, interior points interpolated.'collocation'or('collocation', k): the control is the element's collocation polynomial, with k free values per element (the last k collocation points, and k = ncp for the plain form) and Lagrange interpolation elsewhere. The elimination form ofreduce_collocation_points(ncp=k).
Examples
Worked notebooks under examples/:
- racecar_cvp.ipynb: minimum-time race car, both invocation forms and all three profiles.
- hicks_cvp.ipynb: the Hicks-Ray CSTR.
- Quad_tank_cvp.ipynb: the quadruple-tank process.
Install their dependencies with pip install pyomo-cvp[examples].
Citing
If you use this package, please also cite the pyomo.dae framework it builds on:
Nicholson, B., Siirola, J.D., Watson, J.-P., Zavala, V.M., Biegler, L.T. (2018). pyomo.dae: a modeling and automatic discretization framework for optimization with differential and algebraic equations. Mathematical Programming Computation 10(2), 187-223. doi:10.1007/s12532-017-0127-0
@article{nicholson2018pyomodae,
author = {Nicholson, Bethany and Siirola, John D. and Watson, Jean-Paul
and Zavala, Victor M. and Biegler, Lorenz T.},
title = {pyomo.dae: a modeling and automatic discretization framework
for optimization with differential and algebraic equations},
journal = {Mathematical Programming Computation},
volume = {10},
number = {2},
pages = {187--223},
year = {2018},
doi = {10.1007/s12532-017-0127-0}
}
Part of the DRTO stack
pyomo-cvp stands alone, but it is also the control-parameterization layer of
DRTO, a unified framework for dynamic
real-time optimization (NMPC, moving horizon estimation, and steady-state
RTO) built on Pyomo. In DRTO, drto.control(m.u, profile=...) delegates
to this package, so a declared model gets its control profiles without
calling pyomo-cvp directly. If you are parameterizing controls for a
receding-horizon controller, DRTO may be the layer you actually want.
Maintainer
Maintained by @devin-griff. Issues and pull requests welcome.
License
BSD 3-Clause License. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyomo_cvp-0.7.2.tar.gz.
File metadata
- Download URL: pyomo_cvp-0.7.2.tar.gz
- Upload date:
- Size: 160.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de247610d593b2a2bcb080df93a3134e0987ce266b828a48513846a540ff238
|
|
| MD5 |
88c6890c188c0aee6362f4043e1720e7
|
|
| BLAKE2b-256 |
7d8b80917ad7e0c14940bf2e0de66bc3628d93b1ff4a410f1a4b1fd26dcaab14
|
Provenance
The following attestation bundles were made for pyomo_cvp-0.7.2.tar.gz:
Publisher:
publish.yml on devin-griff/pyomo-cvp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyomo_cvp-0.7.2.tar.gz -
Subject digest:
0de247610d593b2a2bcb080df93a3134e0987ce266b828a48513846a540ff238 - Sigstore transparency entry: 2256474054
- Sigstore integration time:
-
Permalink:
devin-griff/pyomo-cvp@e2789a18a4766c2e36f2402071a0909f229be827 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/devin-griff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2789a18a4766c2e36f2402071a0909f229be827 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyomo_cvp-0.7.2-py3-none-any.whl.
File metadata
- Download URL: pyomo_cvp-0.7.2-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7512c2a8d05ef878e078bc50a1fac0152d23dfb49c9e4984d7138d65b9086d5a
|
|
| MD5 |
9add7e9d8f0d464cf9b3f5238e61567e
|
|
| BLAKE2b-256 |
dfdb3618f613e772ffca2122ee61cc4d23df4d1d345ebc96e927199123f294c0
|
Provenance
The following attestation bundles were made for pyomo_cvp-0.7.2-py3-none-any.whl:
Publisher:
publish.yml on devin-griff/pyomo-cvp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyomo_cvp-0.7.2-py3-none-any.whl -
Subject digest:
7512c2a8d05ef878e078bc50a1fac0152d23dfb49c9e4984d7138d65b9086d5a - Sigstore transparency entry: 2256474065
- Sigstore integration time:
-
Permalink:
devin-griff/pyomo-cvp@e2789a18a4766c2e36f2402071a0909f229be827 -
Branch / Tag:
refs/tags/v0.7.2 - Owner: https://github.com/devin-griff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2789a18a4766c2e36f2402071a0909f229be827 -
Trigger Event:
push
-
Statement type: