Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 2382 separate model classes #2385

Closed
wants to merge 22 commits into from

Conversation

valentinsulzer
Copy link
Member

Description

Create new classes for ParameterisedEquations and DiscretisedEquations. Fixes #2382

To maintain backwards compatibility with the inplace processing, these are assigned to the equations attribute of the BaseModel class (and hence all model classes). The equations attribute starts as SymbolicEquations, which allows assignment of rhs, algebraic, etc. After setting parameters, it becomes ParameterisedEquations, which no longer allows modifications of attributes after they are assigned in the init function. After discretisation, it becomes DiscretisedParameters (no assignment possible).

The variables attribute of the ParameterisedEquations and DiscretisedEquations classes is the OnTheFlyUpdateDict, which initially has no entries. Entries are updated by setting parameters/discretising the variable the first time it is called (similarly to how solution.update works). This fixes #2242

In future, we can follow this style for the base solver, creating new equations such as JaxEquations, CasadiEquations, and PythonEquations, and hence cleaning up a lot of the code in BaseSolver

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@valentinsulzer valentinsulzer marked this pull request as draft October 20, 2022 00:26
@kratman kratman deleted the issue-2382-separate-model-classes branch March 19, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant