Commit 8a18d36
Port the Pyomo extension to Pyomo 2 / Symbolics 7 (#4888)
* Port the Pyomo extension to Pyomo 2 / Symbolics 7
MTKPyomoDynamicOptExt could not load at all: its compat was pinned to
Pyomo 0.1.0, and every registered Pyomo version up to 1.0.1 declared
`Symbolics = "6.39.1 - 6"` while MTKBase requires Symbolics 7.32.1. The
extension also called `Symbolics.symstruct` and `Symbolics.Struct` directly,
both removed in Symbolics 7.
* Compat bumped to Pyomo 2.0.1.
* `Symbolics.symstruct(ConcreteModel)` -> `SymbolicConcreteModel`. Symbolics 7
uses the Julia type itself as the symtype.
* `pysym_getproperty` / `_getproperty` deleted here; they now live in Pyomo.jl,
which can test them against a real model.
* Symbolic indexing goes through `Pyomo.pyomo_getindex`. Symbolics 7 moved the
symtype out of `BasicSymbolic`'s type parameter, so the old
`BasicSymbolic{Struct{PyomoVar}}` `getindex` dispatch is not expressible; the
`Symbolics.value` calls that existed only to reach it are gone too.
* `Symbolics.substitute(..., fold = false)` -> `fold = Val(false)`. SymbolicUtils
takes `fold` as a `Val`; the `Bool` form throws on every `add_constraint!` and
`set_objective!`. `Val` is valid at the declared SymbolicUtils floor (4.35.3).
`using Pyomo` is uncommented in the test file and Pyomo added to the
optimization test environment, where it was not a dependency. Every Pyomo
assertion sits behind `if @isdefined(Pyomo)`, so none of them have run.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GYQeAiC2x9nJ7Mmwwxhe2
* Require Pyomo 2.0.2
2.0.1 shipped without the promote_shape, isinteger and operator fixes; CI on
this branch failed against it with
ArgumentError: Invalid shapes for cos: (SymbolicUtils.Unknown(-1),).
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GYQeAiC2x9nJ7Mmwwxhe2
---------
Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 92ca8a4 commit 8a18d36
4 files changed
Lines changed: 16 additions & 23 deletions
File tree
- lib/ModelingToolkitBase
- ext
- test/optimization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | 97 | | |
107 | 98 | | |
108 | 99 | | |
| |||
165 | 156 | | |
166 | 157 | | |
167 | 158 | | |
168 | | - | |
| 159 | + | |
169 | 160 | | |
170 | 161 | | |
171 | 162 | | |
| |||
192 | 183 | | |
193 | 184 | | |
194 | 185 | | |
195 | | - | |
196 | | - | |
| 186 | + | |
| 187 | + | |
197 | 188 | | |
198 | 189 | | |
199 | 190 | | |
| |||
206 | 197 | | |
207 | 198 | | |
208 | 199 | | |
209 | | - | |
| 200 | + | |
210 | 201 | | |
211 | 202 | | |
212 | 203 | | |
| |||
243 | 234 | | |
244 | 235 | | |
245 | 236 | | |
246 | | - | |
247 | | - | |
| 237 | + | |
| 238 | + | |
248 | 239 | | |
249 | 240 | | |
250 | 241 | | |
251 | | - | |
252 | | - | |
| 242 | + | |
| 243 | + | |
253 | 244 | | |
254 | 245 | | |
255 | 246 | | |
| |||
258 | 249 | | |
259 | 250 | | |
260 | 251 | | |
261 | | - | |
262 | | - | |
263 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
264 | 255 | | |
265 | 256 | | |
266 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments