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

Convert State to Stateful Parameter #89

Closed
mraunak opened this issue Jul 8, 2021 · 4 comments
Closed

Convert State to Stateful Parameter #89

mraunak opened this issue Jul 8, 2021 · 4 comments
Assignees

Comments

@mraunak
Copy link
Contributor

mraunak commented Jul 8, 2021

Overview

Bring in the concept of Stateful Parameters instead of State. The Node object will have Function and Parameter, and further Parameter is categorized as Stateful and fixed Parameter. Stateful Parameter stores the value and changes with time.

Step1: Create Stateful Parameter

  • Change the time derivative to change in value of parameter and output the updated value
  • Rename existing scheduler to execution_engine to perform calculation
  • Link with standalone repo of scheduler for scheduling the next execution
  • Pull to development branch

Step2: Write the Translator

  • Convert dv/dt to incremental format
  • Define a translator that converts states file into stateful parameters file
@Shanka123
Copy link
Contributor

Shanka123 commented Jul 9, 2021

Apart from parameters nodes also have stateful parameters whose values are associated with a function and evolves with time as the graph is evaluated.
.
A stateful parameter has the following components:

  1. id
  2. default initial value to start with
  3. value updated by a MDF function that uses the previous value of the stateful parameter, time increment (dt)

Initial work on this here: https://github.com/ModECI/MDF/tree/stateful_parameter

Initial thoughts on implementing the translator:

  1. Input should be any json file with implementation of states.
  2. Extract the parameters / arguments from the expression of time derivative, parameters field of the nodes.
  3. Create a new MDF function using the expression of time derivative for each state, extracted arguments.

@jdcpni
Copy link
Contributor

jdcpni commented Jul 9, 2021 via email

@Shanka123
Copy link
Contributor

Translator has been implemented and tested successfully. Translator converts files with state if it contains to file with stateful parameters, otherwise unchanged. The output file upon evaluation produces the same results.
Steps to implement translator

  1. import the original json file to be translated
  2. if node object has states and time derivative then add 'dt' to the parameters of the node object and add 'time' as a stateful parameter
  3. create functions for time_derivative expression for each state variable
  4. Replace all names containing states into stateful_parameters
  5. While evaluating the graph of the translated version, add the corresponding MDF functions

file location: src/modeci_mdf/full_translator.py
currently on branch 'stateful_parameter': https://github.com/ModECI/MDF/blob/stateful_parameter/src/modeci_mdf/full_translator.py

@pgleeson
Copy link
Member

Translator code merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants