Skip to main content

Week 3

Progress this Week

This week I extended the parsers to more SBML and MathML constructs and started working on the simulator. The SBML parser now supports Function Definitions and the MathML parser supports lambda functions and variable bindings. 

The mathml package can also be used to evaluate an abstract syntax tree now, in the following way:

    
    let model = sbml_rs::parse(&filename).expect("Couldn't parse model.");
// Supply values for variables
let mut hm: HashMap<String, f64> = HashMap::new();
hm.insert("compartment".into(), 5.0);
hm.insert("k1".into(), 5.0);
hm.insert("S1".into(), 6.0);
// Evaluate math nodes
for tag in &model {
if let Tag::MathTag(math_tag) = tag {
println!("{}", evaluate_node(&math_tag.nodes, 0, &hm).unwrap());
}
}


If the AST has any constants, they're taken directly, but if there are any variables, their values need to be specified through a HashMap, as shown above. The above snippet, when run on this model prints the value 150, which is 5 * 5 * 6. 

I have also published all the packages to crates.io, and they can all be found here.

Here are the links to the relevant Github repositories:
  1. sbml-sim
  2. sbml-rs
  3. mathml-rs
Other than that, I went through some parts of the source code of LibSBMLSim and its publication to get an idea of how the simulator is expected to function. 

Progress so Far

The first three weeks of the coding period were allocated to developing the parser, so I'm mostly on track with the proposed timeline. However, the Euler method implementation was expected to be done in week 3, but that has been delayed by a few days due to the issues with parsers, described earlier in week 1. To briefly summarize, I was trying to work with the existing SBML and MathML parsers, but I realized it wouldn't be possible to make them work together, so I had to write them from scratch.

Other than that, all the requirements for the simulator are in place and I think I will be able to catch up with the timeline in the coming two weeks.

Plan for the Coming Week

As per discussion with mentors on 29 June, the plan for the coming week is the following:
  1. Prepare hashmap for AST node evaluation from the values given in the model.
  2. Implement integrator based on the Euler method.
  3. Simulate the first few models from the SBML test suite and compare results
  4. If all this is done, implement the fourth-order Runge-Kutta integrator.

Comments