Skip to content

Commit

Permalink
Various code2amr fixes (#594)
Browse files Browse the repository at this point in the history
- Fixed bug where euler method states would show up as transitions
- Added support for For loop wiring
- Added workaround to handle empty method-like functions
- Added better error handling for repeated edge queries from function
network

---------

Co-authored-by: Justin <[email protected]>
  • Loading branch information
Free-Quarks and Justin authored Oct 26, 2023
1 parent 52de34d commit 03b0d1e
Show file tree
Hide file tree
Showing 2 changed files with 570 additions and 184 deletions.
10 changes: 9 additions & 1 deletion skema/skema-rs/mathml/src/acset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ impl From<Vec<FirstOrderODE>> for PetriNet {
let mut rate_vec = Vec::<Rate>::new();
let mut state_string_list = Vec::<String>::new();
let mut terms = Vec::<PnTerm>::new();
let mut dirty_terms = Vec::<PnTerm>::new();

// this first for loop is for the creation state related parameters in the AMR
for ode in ode_vec.iter() {
Expand Down Expand Up @@ -361,7 +362,14 @@ impl From<Vec<FirstOrderODE>> for PetriNet {

// this collects all the terms from the equations
for ode in ode_vec.iter() {
terms.append(&mut get_terms(state_string_list.clone(), ode.clone()));
dirty_terms.append(&mut get_terms(state_string_list.clone(), ode.clone()));
}

// now to trim off terms that are for euler methods, dyn_state != exp_state && parameters.len() != 0
for term in dirty_terms.iter() {
if term.dyn_state != term.exp_states[0] || term.parameters.len() != 0 {
terms.push(term.clone());
}
}

for term in terms.iter() {
Expand Down
Loading

0 comments on commit 03b0d1e

Please sign in to comment.