Repository navigation
Support known_disturbance_inputs in symbol-based generate_control_function - #4230
ChrisRackauckas-Claude wants to merge 11 commits into
Conversation
…ction The symbol/analysis-point override of generate_control_function did not forward the known_disturbance_inputs keyword to the base function. This adds the keyword, opens the corresponding loops, and passes the resulting variables through. The disabled doc example in disturbance_modeling.md is re-enabled using the symbol API, and a test is added for the new keyword path. Fixes SciML#4215 Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| op = ModelingToolkit.inputs(io_sys) .=> 0 | ||
| x0 = ModelingToolkit.get_u0(io_sys, op) | ||
| p = MTKParameters(io_sys, op) | ||
| u = zeros(1) # Control input |
There was a problem hiding this comment.
please don't remove comments like this
| w = zeros(length(disturbance_inputs)) # Disturbance input (known disturbances are provided as arguments) | ||
| @test f_oop(x0, u, p, t, w) == zeros(5) | ||
| u = zeros(1) | ||
| w = zeros(2) |
There was a problem hiding this comment.
Please don't hardcode numbers when the existing code had a better solution
|
|
||
| g = ModelingToolkit.build_explicit_observed_function( | ||
| io_sys, outputs; inputs) | ||
| io_sys, outputs; inputs = ModelingToolkit.inputs(io_sys)[1:1]) |
There was a problem hiding this comment.
the existing code was better
Address review feedback: keep descriptive comments from the original example, use `length(disturbance_inputs)` instead of hardcoded `2`, and restore the multi-line formatting style. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Addressed all three review comments in 2cb0c23:
|
|
@baggepinnen more comments? |
| P = ssys.system_model | ||
| ```@example DISTURBANCE_MODELING | ||
| inputs = [:u] | ||
| disturbance_inputs = [:d1, :d2] |
There was a problem hiding this comment.
This is the old syntax of providing analysis points, the tutorial should keep using the new syntax.
The problem is that you should not use the legacy symbol-based API. |
Pass symbols inline to generate_control_function instead of creating intermediate variables with the old analysis-point syntax. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Fixed in 93dd2fb: symbols are now passed inline directly to |
Resolve conflict in analysis_points.jl by keeping known_disturbance_inputs forwarding from the PR while adopting master's SymbolicT[]/append! style for disturbance open-loop handling. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Agent-Harness: cursor-agent 2026.09.23-86fc751 Agent-Model: Composer Agent-Session: /home/crackauc/.cursor/projects/home-crackauc-sandbox-fleet-master-jobs-nw-modelingtoolkit-4230/agent-transcripts/1bf513c6-064f-4439-b8ff-0e7e29694beb Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Agent-Harness: cursor-agent 2026.09.23-86fc751 Agent-Model: Composer Agent-Session: /home/crackauc/.cursor/projects/home-crackauc-sandbox-fleet-master-jobs-nw-modelingtoolkit-4230/agent-transcripts/1bf513c6-064f-4439-b8ff-0e7e29694beb Co-authored-by: Cursor <cursoragent@cursor.com>
The new assertion copied Integrator-model expected derivatives from the docs, but the Downstream fixture uses ss(1+10/s) with feedthrough. Align with the existing disturbance_argument cases for the same model. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Agent-Harness: cursor-agent 2026.09.23-86fc751 Agent-Model: Composer Agent-Session: /home/crackauc/.cursor/projects/home-crackauc-sandbox-fleet-master-jobs-nw-modelingtoolkit-4230/agent-transcripts/1bf513c6-064f-4439-b8ff-0e7e29694beb Co-authored-by: Cursor <cursoragent@cursor.com>
Prefer model.u / model.d1 over Symbol names, matching the current analysis-point API guidance from review. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Agent-Harness: cursor-agent 2026.09.23-86fc751 Agent-Model: Composer Agent-Session: /home/crackauc/.cursor/projects/home-crackauc-sandbox-fleet-master-jobs-nw-modelingtoolkit-4230/agent-transcripts/1bf513c6-064f-4439-b8ff-0e7e29694beb Co-authored-by: Cursor <cursoragent@cursor.com>
Bring in the upstream fixes for the sparse Jacobian, benchmark setup, and the Optimization and QA checks. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.170.0 Agent-Model: gpt-6.2-sol Agent-Job: SciML__ModelingToolkit.jl__4230--20261121T214552Z-codex-gpt-6.2-sol Agent-Session: local session 01a20014-d6c7-73b2-a90a-c82f52ddebc1 (no session URL)
Open loops for analysis-point disturbances and forward symbolic variables as known inputs. Keep default unknown disturbances and exercise both control input forms. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.170.0 Agent-Model: gpt-6.2-sol Agent-Job: SciML__ModelingToolkit.jl__4230--20261121T214552Z-codex-gpt-6.2-sol Agent-Session: local session 01a20014-d6c7-73b2-a90a-c82f52ddebc1 (no session URL)
PR: #4230 Reviewed head: ff18c46 Risk assessment
Review reportVERDICT: CHANGES Risklow (L8: opt-in analysis-point support for an existing keyword on the control-function path) Blocking findings
Non-blocking findings
What I ran
What I did not verifyFull Documenter build, QA, other Julia versions, and remote CI. AUTHOR_GRADE: {"task":"bugfix","score":2,"difficulty":3,"rounds":1,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"The scalar probe distinguishes the fix from the base. Marked and array-valued known disturbances can silently produce incorrect derivatives."} Head link: ff18c46 🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol |
Keep explicitly known disturbances out of the inferred unknown list and flatten array disturbances in compiled input order. Test the keyword and positional interfaces and assert the affected state slots. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.170.0 Agent-Model: gpt-6.2-sol Agent-Job: SciML__ModelingToolkit.jl__4230--20261122T043814Z-codex-gpt-6.2-sol Agent-Session: local session 01a2018d-ea45-70e1-98d9-ab3af32c56a2 (no session URL)
PR: #4230 Reviewed head: e7a8f55 Risk assessment
Review reportVERDICT: CHANGES Riskhigh (H1: a previously working positional call now generates dynamics that throw for an array-valued unknown disturbance) Blocking findings
Non-blocking findingsNone. What I ran
What I did not verifyThe full documentation build, other test groups and other Julia versions remain unverified. AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":3,"rounds":1,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"The tutorial and downstream suite pass. Independent probes reproduced a regression for whole-array unknown disturbances, an incorrect parameter list and an element-order failure."} Head link: e7a8f55 🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-astra |
Group complete disturbance arrays for compilation and substitute shaped zeros for unknown arrays. Exclude disturbance parents from the returned parameters and test the ordering of the generated disturbance argument. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Codex <noreply@openai.com> Agent-Harness: Codex CLI 0.170.0 Agent-Model: gpt-6.2-sol Agent-Job: SciML__ModelingToolkit.jl__4230--20261122T175041Z-codex-gpt-6.2-sol Agent-Session: local session 01a20463-6835-7a93-b50e-977ae6e112d9 (no session URL)
PR: #4230 Reviewed head: 483c3f3 Risk assessment
Review reportVERDICT: CHANGES Riskmedium-low (ML1: corrects the parameter list returned by control-function generation for array disturbances) Blocking findings
Non-blocking findingsNone. What I ran
What I did not verifyI did not run the full documentation build, unrelated test groups or other Julia versions. An offset-indexed disturbance probe raised a AUTHOR_GRADE: {"task":"bugfix","score":4,"difficulty":3,"rounds":2,"author_harness":"Codex CLI 0.170.0","author_model":"gpt-6.2-sol","note":"The three earlier reproductions pass individually. A whole-vector consumer still fails when one disturbance element is measured and the other is unknown."} Head link: 483c3f3 🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-astra |
Summary
known_disturbance_inputskeyword to the symbol/analysis-point override ofgenerate_control_functioninanalysis_points.jl, opening the corresponding loops and forwarding the variables to the base function.disturbance_modeling.mdusing the symbol-based API ([:d1, :d2]instead of compiled system variables).test_disturbance_model.jlexercising the new keyword path.Fixes #4215
Test plan
test/downstream/test_disturbance_model.jlpassesknown_disturbance_inputswith symbol API (input count, zero/nonzero disturbance behavior)🤖 Generated with Claude Code
CI triage (2026-09-24)
Head commit at triage start:
93dd2fb813. Logs for that run were expired (HTTP 410); classifications use check durations/conclusions, annotations, and comparison against latestmasterruns. After merge + fixes, new CI is on9241451537.masterformat-check green (run 35977707462). Fixed via Runic on changed kwargs (6bb58c91f1).master(job 107109419541); PR added an assertion that mismatched the PI fixture. Local Julia 1.12 Downstream disturbance test now passes after9241451537.master(run 35977706990). PR re-enables the symbol/known_disturbance_inputsexample; verified locally against Integrator model.missingsspelling insystemstructure.jl(not in PR diff). Typos clean on PR-touched files.prematrix; consistent with nightly resolve/start failure rather than test logic.master(run 35977707000).generate_control_function+ docs/test.masterdrift since Jan head; several Base groups green on recentmasterDownstream/InterfaceII/Extensions. Re-check on post-merge CI.master(run 35838707817).Risk assessment
generate_control_functionoverload; merges eight months ofmasterinto the branch.generate_control_functionwithknown_disturbance_inputs; disturbance-modeling docs example; Downstream disturbance tests.test/downstream/test_disturbance_model.jlpasses; Integrator doc snippet reproduces[0,0,0,1,2]; Runic + typos clean on touched files.🤖 Posted by an AI agent — harness: cursor-agent 2026.09.23-86fc751 · model: Composer
Conversation:
Independent review (Codex CLI 0.162.1 gpt-6.1-sol, head df245ee)
VERDICT: CHANGES
The new analysis-point disturbance path works, but it breaks an existing, documented symbolic-variable input form. Preserve that form and add a regression test before merging. The supplied failing CI checks also lack sufficient evidence to establish no regressions against master.
[P1] lib/ModelingToolkitBase/src/systems/analysis_points.jl:936 — confirmed by running: symbolic known disturbances now throw when the control input is an analysis point. canonicalize_ap wraps an ordinary symbolic variable unchanged, and line 938 then calls open_loop on that Num, which has no matching method. The base wrapper forwards these symbolic variables directly to the underlying generator, where they are supported. This affects both Symbol and AnalysisPoint control-input overloads. Transform analysis-point disturbances while continuing to forward symbolic-variable disturbances, and test both forms.
Standalone reproducer used for the comparison:
Julia 1.12.7, identical resolved dependencies: merge base b5a7653 passes 1/1; head df245ee errors with "MethodError: no method matching open_loop(::System, ::Num)" at line 938. This is a newly rejected input, not merely missing coverage for the added feature.
Verification: read the full three-file diff, linked issue, supplied comments and reviews, and applicable criteria. Ran with JULIA_NUM_THREADS=4, JULIA_NUM_PRECOMPILE_TASKS=4, --startup-file=no, and timeout 3600 in isolated environments using the respective local package sources. test/downstream/test_disturbance_model.jl passes 20/20 at head. The identical head test file on the merge base reaches the added call at test/downstream/test_disturbance_model.jl:206 and errors during compilation with symbol-valued known disturbances, after two earlier assertions pass. Thus the added test distinguishes the original bug. Additional scalar-model checks for Symbol/AnalysisPoint controls and known disturbances, with and without unknown disturbances, pass 12/12 at head. The restored tutorial's plant definition, integrating-disturbance wrapper, and generated-function assertions pass 3/3; the scratch extraction uses OrdinaryDiffEqTsit5 instead of the OrdinaryDiffEq umbrella import. Tracked repository files remain unchanged.
Gates: G1 has independent equation-based checks for the generated dynamics; no numerical solver algorithm or tolerance changes occur. G2 introduces no GPU, AD, Reactant, or MPI paths. G3 introduces no shared state, cache, threading, or global-default changes. These gates do not excuse the confirmed compatibility regression.
Not verified: full documentation build, complete Downstream group, QA, other test groups, and downstream integration suites were not run locally. An initial standalone test attempt lacked the direct ControlSystemsBase dependency; after adding that already-resolved dependency to the scratch environment, the test file passed. An initial extra scalar-model probe used colliding variable/analysis-point names; the corrected probe produced the 12/12 result above. GitHub CLI could not retrieve CI jobs because authentication is unavailable; no credentials were sought and nothing was posted. Consequently, comparison with master is UNVERIFIED for every supplied failing check: Benchmarks (lts); Benchmarks (1); NeuralPDE.jl/NNPDE2/1/; SciMLBase.jl/SymbolicIndexingInterface/1/; SciMLSensitivity.jl/Core8/1/; downgrade-mtkbase (Optimization); ModelingToolkitBase InterfaceII on Julia 1 and lts; ModelingToolkitBase Optimization on Julia 1 and lts; ModelingToolkitBase QA on Julia 1; root Optimization on Julia 1 and lts; and root QA on Julia 1. The historical classifications in the PR body concern earlier heads and do not establish the status of these failures. No failure is classified as pre-existing or PR-caused from duration alone.
🤖 Posted by an AI agent — harness: Codex CLI 0.162.1 · model: gpt-6.1-sol
Conversation: Codex exec session 01a14b4f-eed5-7763-a520-7a9900a20e1c (no public URL)
Codex CLI gpt-6.1-sol rated it high (H1: rejects previously working public inputs) at head df245ee
Fix by Codex CLI 0.170.0 gpt-6.2-sol (head ff18c46)
generate_control_functionnow forwards symbolic-variable disturbances and opens the loops for analysis-point disturbances. The regression tests exercise both Symbol and AnalysisPoint controls and both forms of specifying an analysis point.Validation on Julia 1.12.7
MethodError: no method matching open_loop(::System, ::Num)for both control forms, 2 errors out of 2. After:Symbolic known disturbances with an analysis point | 2 2 8.9s.julia --project=@runic -m Runic --inplace lib/ModelingToolkitBase/src/systems/analysis_points.jl test/downstream/test_disturbance_model.jl,git diff --name-only -z upstream/master | xargs -0 -r typos --, andgit diff --check upstream/masterexited 0.GROUP=Downstream julia --project -e 'using Pkg; Pkg.test()'exited 0 withDownstream | 39 39 33m57.8sandTesting ModelingToolkit tests passed.GROUP=QA julia --project -e 'using Pkg; Pkg.test()'reported39 passed, 1 failed, 0 errored, 0 broken. It found the same six unapproved public reexports as the master QA job.julia --project=docs -e 'using Pkg; Pkg.instantiate()'exited 0. The tutorial examples ran directly withGenerated disturbance-model dynamics and observations | 3 3 5.2s. The first full docs build timed out. The retry,OPENBLAS_NUM_THREADS=1 julia --project=docs docs/make.jl, completed doctests and example expansion, then exited 1 withmakedocs encountered an error [:linkcheck] -- terminating build before renderingafter GitHub returned HTTP 429 for an unchanged PDEBase link.Next counted review must come from a smart model in a fresh session, not this fix session.
🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a20014-d6c7-73b2-a90a-c82f52ddebc1 (no session URL)
Fix by Codex CLI 0.170.0 gpt-6.2-sol (head e7a8f55)
disturbance = true.Validation on Julia 1.12.4
julia --startup-file=no --project -e 'using Pkg; Pkg.instantiate(; allow_autoprecomp=false); include(ARGS[1])'with the extracted test script as its argument.Review regression tests | 9 failed, 9 total | 13.3s. The marked scalar derivative was[13.0]versus[1.0]. Both array interfaces retained the elements inpsand returned[13.0]for every testedw.Review regression tests | 9 9 10.4s. The scalar derivative is[1.0]and the array derivatives are[36.0],[33.0], and[43.0]with fixed operating-point parameters.GROUP=Downstream julia --project -e 'using Pkg; Pkg.test()'exited 0 withDownstream | 52 52 15m41.4sandTesting ModelingToolkit tests passed.GROUP=QA julia --project -e 'using Pkg; Pkg.test()'exited 1 with39 passed, 1 failed, 0 errored, 0 broken. The six unapproved reexports match the master root QA failure.julia --project=@runic -m Runic --inplace lib/ModelingToolkitBase/src/systems/analysis_points.jl test/downstream/test_disturbance_model.jl,git diff --name-only -z upstream/master | xargs -0 -r typos --, andgit diff --check upstream/masterall exited 0.Next counted review must come from a smart model in a fresh session, not this fix session.
🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a2018d-ea45-70e1-98d9-ab3af32c56a2 (no session URL)
Fix by Codex CLI 0.170.0 gpt-6.2-sol (head 483c3f3)
Validation on Julia 1.12.4
julia --startup-file=no --compiled-modules=existing -O1 --project="$project" "$regression_driver"ran the same extracted test cases with identical resolved dependencies on both heads.Disturbance regressions | 19 passed, 2 failed, 6 errored, 27 total. The whole-array case reportedUndefVarError: w not defined in ModelingToolkitBasein both split modes. The keyword and positionalisempty(ps)assertions found[w(t)]with split generation. Selecting element 1 alone or supplying elements in reverse order reportedElements of scalarized array variables must be in sorted orderin both split modes.Disturbance regressions | 27 27 1m16.5s. The generated functions returned[15.0]for the unknown array and[17.0],[-23.0], and[-5.0]for the mixed and reversed-order cases. Both parameter assertions passed.GROUP=Downstream timeout 3600 julia --project -e 'using Pkg; Pkg.test()'exited 0 withDownstream | 68 68 14m03.5sandTesting ModelingToolkit tests passed.GROUP=QA timeout 3600 julia --project -e 'using Pkg; Pkg.test()'exited 1 with39 passed, 1 failed, 0 errored, 0 broken. The sole failure was the six unapproved public reexports also reported by master at the PR merge base. Current master root QA still fails on the five Symbolics operator reexports.julia --project=@runic -m Runic --inplace lib/ModelingToolkitBase/src/inputoutput.jl test/downstream/test_disturbance_model.jl,git diff --name-only -z "$(git merge-base upstream/master HEAD)" | xargs -0 -r typos --, andgit diff --check upstream/master...HEADall exited 0.Next counted review must come from a smart model in a fresh session, not this fix session.
🤖 Posted by an AI agent — harness: Codex CLI 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a20463-6835-7a93-b50e-977ae6e112d9 (no session URL)