Skip to main content

pyomo-cvp

PyPI Python versions CI License

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 final time carries no control).
  • '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 of reduce_collocation_points(ncp=k).

Examples

Worked notebooks under examples/:

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

pyomo_cvp-0.6.2.tar.gz (155.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyomo_cvp-0.6.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pyomo_cvp-0.6.2.tar.gz.

File metadata

  • Download URL: pyomo_cvp-0.6.2.tar.gz
  • Upload date:
  • Size: 155.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyomo_cvp-0.6.2.tar.gz
Algorithm Hash digest
SHA256 2107e0404c1d825e12a2a4d5b540aafaa5bf39d05ffb8ed4886103fef15ae589
MD5 7bc4486e1c7a859f2bba120c932a5d89
BLAKE2b-256 5cb7856e6606ba7fa0616925ffbfff1d65039951c60264972fd59411590b4a70

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomo_cvp-0.6.2.tar.gz:

Publisher: publish.yml on devin-griff/pyomo-cvp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomo_cvp-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: pyomo_cvp-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyomo_cvp-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5bf9f004dca9333c5f12ced3281bab09aaf737fa71df1f8d433e8fd39df17934
MD5 74b4c18a9b305bb0907bc93150d3d659
BLAKE2b-256 4354f6255e4d1a7ebbb92b77693594b63e333b54e16fd5c30056072cfecc8cd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomo_cvp-0.6.2-py3-none-any.whl:

Publisher: publish.yml on devin-griff/pyomo-cvp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.3.1

2 files

0.6.3

2 files

This release

0.6.2 This release

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page