Skip to content

Add functionality to directly convert a stockflow acset -> stockflow amr and stockflow amr -> stockflow acset - #41

Open
nanglo123 wants to merge 13 commits into
AlgebraicJulia:mainfrom
nanglo123:amr_acset_conversion
Open

nanglo123 wants to merge 13 commits into
AlgebraicJulia:mainfrom
nanglo123:amr_acset_conversion

Conversation

@nanglo123

Copy link
Copy Markdown

No description provided.

Comment thread src/acsets/amr_conversion/stockflow.py Outdated
if link['source'] in stocks_mapping:
link_dict = {'_id': link_id}
link_dict['s'] = stocks_mapping[link['source']]
link_dict['t'] = idx

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally set link_dict['t'] = link['target'][4:] to set the 't' field of the output acset to the flow id defined by the input amr link's 'target' field.

@codecov

codecov Bot commented Nov 7, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f966b18) 87.46% compared to head (c4c8423) 87.46%.

❗ Current head c4c8423 differs from pull request most recent head aaab268. Consider uploading reports for the commit aaab268 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #41   +/-   ##
=======================================
  Coverage   87.46%   87.46%           
=======================================
  Files           6        6           
  Lines         327      327           
  Branches       54       54           
=======================================
  Hits          286      286           
  Misses         36       36           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nanglo123
nanglo123 force-pushed the amr_acset_conversion branch from a143780 to baa2b5f Compare November 8, 2023 21:12
Comment thread src/acsets/amr_conversion/stockflow.py Outdated
Comment thread src/acsets/amr_conversion/stockflow.py Outdated
params_stock_flow_map[flow_id] = []

params_stock_flow_map[flow_id].extend(
re.findall(r'p\.([^()*+-/ ]+)', flow['ϕf']))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this assume that a parameter always starts with p.?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we assumed that was the case.

Comment thread src/acsets/amr_conversion/stockflow.py Outdated
params_stock_flow_map[flow_id].extend(
re.findall(r'p\.([^()*+-/ ]+)', flow['ϕf']))
params_stock_flow_map[flow_id].extend(
re.findall(r'u\.([^()*+-/ ]+)', flow['ϕf']))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this assume that a state always starts with u.?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we assumed that was the case.

Comment thread src/acsets/amr_conversion/stockflow.py Outdated
for parameter in amr['semantics']['ode']['parameters']:
if parameter['id'].startswith('p_'):
symbols[parameter['id'][2:]] = sympy.Symbol(
'p.' + parameter['id'][2:])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole p. and u. thing are implementation details in julia that the state variable of a dynamical system is called u and the parameters are p. Do we want to cannonicalize that in the standard?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We thought that u. and p. are required/expected in your ACSet implementation. So we parse them when reading in an ACSet and generate them when outputting an ACSet. If that's not the case, we can remove the custom handling of these.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpfairbanks could you confirm if the u. and p. are expected in the ACSet or if we should remove this assumption?

@bgyori

bgyori commented Jan 19, 2024

Copy link
Copy Markdown
Contributor

@jpfairbanks, with these latest commits, @nanglo123 removed explicit handling of u. and p. so any names will work. Anything else to do on this PR?

@nanglo123
nanglo123 force-pushed the amr_acset_conversion branch from b01f504 to c4c8423 Compare January 22, 2024 16:02
@bgyori

bgyori commented Jan 31, 2024

Copy link
Copy Markdown
Contributor

We don't have merge permissions here so whoever does, please merge!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants