Control vector parameterization for pyomo.dae: piecewise control profiles by variable elimination instead of linking constraints.
Project description
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 |
This matters for NLP solvers such as IPOPT, which have no presolve to strip redundant variables and equalities.
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.'piecewise_linear'--- one free value per element boundary, continuous, interior points interpolated.('reduced_collocation', k)--- k free values per element (the last k collocation points), Lagrange interpolation elsewhere; the elimination form ofreduce_collocation_points(ncp=k).
See examples/racecar_cvp.ipynb for a complete worked example showing both forms and all three profiles.
License
Apache License 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
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.1.0.tar.gz.
File metadata
- Download URL: pyomo_cvp-0.1.0.tar.gz
- Upload date:
- Size: 65.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
904fee192e75f4f07af14edf6e7290ebdbf472c81929490477458192f628c22c
|
|
| MD5 |
b29cc7755ea35cc5372cd10bb5e51298
|
|
| BLAKE2b-256 |
b9b4f205185348da44f02222f77eecd8123fbbf742a03759490bf6eefeb0e713
|
Provenance
The following attestation bundles were made for pyomo_cvp-0.1.0.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.1.0.tar.gz -
Subject digest:
904fee192e75f4f07af14edf6e7290ebdbf472c81929490477458192f628c22c - Sigstore transparency entry: 2083031619
- Sigstore integration time:
-
Permalink:
devin-griff/pyomo-cvp@eca99d399ee6ca8a8206caeb6f5d56332274f95e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/devin-griff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eca99d399ee6ca8a8206caeb6f5d56332274f95e -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyomo_cvp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyomo_cvp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff95e8b1d3d420825de2169327c5a4fffebef2858279a3ba2e7e361a6dc0a836
|
|
| MD5 |
63e79f0b4d4092d7f5080a796a39c506
|
|
| BLAKE2b-256 |
5b507e01224d5473e648671fa8d4bfc17571e12d6dfb8de2dfdb8ea37bd4c6d9
|
Provenance
The following attestation bundles were made for pyomo_cvp-0.1.0-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.1.0-py3-none-any.whl -
Subject digest:
ff95e8b1d3d420825de2169327c5a4fffebef2858279a3ba2e7e361a6dc0a836 - Sigstore transparency entry: 2083031682
- Sigstore integration time:
-
Permalink:
devin-griff/pyomo-cvp@eca99d399ee6ca8a8206caeb6f5d56332274f95e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/devin-griff
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@eca99d399ee6ca8a8206caeb6f5d56332274f95e -
Trigger Event:
push
-
Statement type: