Conversation
wzh1895
added a commit
that referenced
this pull request
Mar 13, 2026
Switched back to static solver and adopted dependency graphs
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.
Bumping version up to 0.3.0, this commit switches asdm back to a static solver that determines all dependencies before simulation and stores them in two graphs—one for initialization and another for iteration. These graphs specify the order in which variables are calculated, so there is no longer a need to trace dependencies dynamically during runtime via recursion.
The direct reason for returning to a static solver is the challenge of managing how outflows are constrained by the non-negative stocks they draw from. This involves considering the stock’s level, dependencies among stock-flows and flow-flows, and the intended values of all flows before any constraint is applied. A dynamic solver would have to figure all this out continuously at runtime while
name_spacevalues are updated, which is exceptionally difficult: it requires evaluating conditional rules involving multiple variables and following a particular calculation order - both of which contradict the nature of a dynamic solver that calculates dependent variables on demand, without a predefined order. Hence, the decision was made to switch back to a static solver.This reintroduction of a static solver echoes the original solver that computed variables in 2019 (though it was not yet called asdm). The original solver was almost static because it enumerated and calculated flows by recursively tracing their dependencies, the only dynamic aspect was that it did not explicitly order those flows. The SD model itself effectively served as the dependency graph. However, from today’s perspective, while an SD model diagram captures the majority of explicit dependencies, it does not capture certain implicit dependencies - especially those pertaining to non-negative stock constraints. These must be inferred separately and then merged into a more comprehensive dependency graph, which is precisely the approach taken by this commit.
In addition to reviving the static solver, this commit includes a (crude) finite state machine that manages a model’s various states, enabling more structured simulation controls such as pausing, resuming, and modifying equations on the fly. It also replaces print-based logging with Python’s logging module. A test script is also added to compare simulation results of multiple test models against results from Stella using pytest.
Below is a list of changes summarized:
List of Changes