Add parsing support for direct steady state constraints (y[ss] = value)#256
Draft
Copilot wants to merge 3 commits intocopilot/update-equation-modification-functionalityfrom
Draft
Conversation
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for direct steady state constraints in parameters macro
Add parsing support for direct steady state constraints (Feb 1, 2026
y[ss] = value)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds syntax for directly specifying steady state values in the
@parametersmacro. This enables pinning variable levels for rank-deficient models where equations only determine ratios, not absolute levels.Changes
Parser (
src/parser.jl)var[ss] = exprpatterns inparse_parameter_definitions_rawData Structures (
src/structures.jl,src/options_and_caches.jl)ss_direct_constraints_vars::Vector{Symbol}andss_direct_constraints_exprs::Vector{Any}topost_parameters_macroupdate_post_parameters_macroDocumentation
docs/src/steady_state.md@parametersmacro docstringTests (
test/test_ss_direct_constraints.jl)Note
This PR implements parsing and storage only. Solver integration to actually use constraints for rank-deficient systems is future work per the implementation plan.
Original prompt
Implementation Plan: Direct Steady State Constraints (
y[ss] = value)Overview
Add support for directly specifying steady state values in the
@parametersmacro:This allows users to pin down steady state values without specifying which parameter adjusts (unlike the existing
param | y[ss] = targetsyntax).Key complexity: The constraint value can be an arbitrary expression involving other parameters, so it must be evaluated at solve time, not parse time.
Design Decisions
When is this useful?
Note: This feature handles rank deficiency (continuum of solutions). True multiple discrete equilibria are a different problem.
Core Algorithm (Option 3: Sequential with Hint)
Why this approach?
Implementation Tasks
Task 1: Parse
y[ss] = valuein@parametersMacroFile:
src/macros.jlGoal: Recognize and capture
y[ss] = exprpatterns in the@parametersblock, where:[ss],[stst],[steady], etc.)Detection pattern:
Key insight: The RHS can be a complex expression involving parameters. We must:
What to store:
Integration approach:
param | y[ss] = target) are parsed and storedpostwalkthat handles other parameter definitionsx.args[1] isa Symbolcheck for regular parameter assignmentsExpression evaluation at solve time:
Generate a function that evaluates the constraint targets given current parameter values (similar to calibration equation targets):
Task 2: Add Storage in Data Structures
File:
src/structures.jlAdd to
post_parameters_macrostruct (around line 265):Also add a compiled evaluator function that will be generated at macro expansion time:
This function is generated from the expressions and called at solve time to get numeric target values.
Update constructor call in
macros.jl(around line 1520) to include the new fields.Task 3: Validation in
@parametersMacroFile:
src/macros.jlAdd validation (after parsing, before constructing
post_parameters_macro):