Thursday, August 21, 2014

Project Wrap-up


The Google Summer of Code program is over. I had an amazing time working on this project. I really enjoyed working in this project and I am thankful for this opportunity. I am happy with my results and, hopefully, I can continue to contribute to the community. In summary, this summer I implemented:
  • Arrays package: I implemented the arrays extensions in JSBML, and this allows people to create regular structures more efficiently. I think the extension is quite straightforward to use. I got the impression some people were confused as to what the arrays package is. People might misinterpret the package, thinking that it is a container that can be populated with objects. This is wrong. An arrayed object indicates you have many copies that share similar attributes.
  • Validation: I implemented a routine that validates arrayed models. The most recent specification defines a set of validation rules that models extending arrays must not violate. Just to be clear, the most recent specification is not yet up on the web, but you can find it in the svn repository. I think the specification has come to a stable point, though changes are not discarded. Validation will be required to update on a regular basis to accommodate the changes in validation rules.
  • Flattening: I implemented a routine that flattens out array constructs. Models do not necessarily need to handle arrays if they flatten the model beforehand. This makes arrays support easier. Flattening arrays makes sense because if you say you have an array of species S, you are actually saying that you have n copies of S, where n is the size of the array. You can inline the objects, which eliminates array constructs.
In summary, I would say that the arrays package seemed easy at the beginning. I was able to implement the extension fairly quick, which gave me the false impression I would run out of things to do in the summer. I could not be more wrong! The extension is simple, but flattening and validation can be quite tricky since arrays have many implications on the math.

We, the students who were participating in the program and that were working with the JSBML team, got the opportunity to share our projects with the community at COMBINE. The slides I used can be found here. I think everything went quite well. Yusef and Victor did a really good job; their project were quite amazing and they did great in their presentations.

I thought it would be interesting to create big models in SBML using the arrays package. Without arrays, this task would be very tedious, but I managed to create this models fairly easily. I created these arrayed models in iBioSim. I believe the flattened models could be used for performance analysis; how fast does a certain simulation tool performs. Also, it would be interesting to use the flattened models to test the new implementation of the ASTNode that Victor has done compared to the old structure.


model01
This model has 1000 assignment rules, 1000 parameters x, 1000 parameters y.

model02
This model has 1000 reactions, 1000 species a, 1000 species b, and 1000 species c.

model03
This model has 5000 parameters, 10000 events.

Any comments, suggestions, or questions, please don't hesitate to contact me!

Monday, August 11, 2014

Weekly Log: August 04 - August 10

This week I focused on my final presentation and finishing up the last pieces of the arrays package. I fixed some bugs I found and also finished the compiler I wrote for evaluating vectors. Now that GSoC is coming to an end, I am taking this week to polish my code and improve documentation. However, the main focus of the past week is to prepare myself for the presentation the JSBML students have with the mentors.

Monday, August 4, 2014

Weekly Log: July 28 - August 3

This week I have been mainly working on two things: validation and final presentation. The arrays package turned out to be more difficult than I was anticipating. The package itself is very straightforward, but validating and flattening a model is not so easy mostly because of all the math implications. Last week I changed the flattening routine to reflect two changes: one is that implicit sizes are going to be disallowed and second I had the wrong interpretation of reaction and species reference with dimensions.

By implicit sizes, we mean that if a variable is an array, say X, and we want to give an initial assignment to X, then the right-hand side must be evaluated to a scalar. If the right-hand side evaluates to a vector, then it must be the case that X has Dimension objects where the dimension sizes match the assigned vector dimension sizes.

Reactions and events are kind of tricky so I made a special case for both. The problem of these SBase objects is that they have children that can have Dimension objects or have vector MathML. For instance, events have trigger/delay/priority which can be vectors. In addition, events have event assignment objects that are allowed to have a list of Dimensions. Reactions have KineticLaw objects which can also be a vector. Furthermore, reactions have SpeciesReference objects which can be an array. The tricky part which I hadn't considered was the case where species reference and reaction are arrays and species reference have ids. Since species reference cannot have duplicate id, I had to make the flattened species reference id to take both the parent reaction's index value and the species reference index value to ensure uniqueness.

Finally, I started making the slides for my final presentation. The final presentation will be an important factor to decide whether or not I pass my final Google Summer of Code evaluation. We, the students and mentors, will have a joint meeting next week, so I need to practice my presentation throughout this week. This presentation will serve as a practice for a talk every student will give at COMBINE.

Monday, July 28, 2014

Weekly Log: July 21 - July 27

The flattening routine should in theory work for all SBML core constructs. I have been testing the flattening function this past week. I integrated the flattening routine in a tool called iBioSim, which is a tool being developed at the University of Utah that can be used for the modeling and analysis of SBML models. Within iBioSim, I was able to construct an arrayed model thanks to one of my lab colleagues, Scott Glass, who is responsible for the GUI support for the Arrays package.

Here is a model in iBioSim. In this model, there are two parameters of size n and one rule of size n, where n is a constant parameter of value 10. This parameter is not shown here, because constant parameters are kept in the constants tab. These objects are enclosed by a compartment Cell, but this is irrelevant to this model. iBioSim adds a compartment by default.

I give a initial assignment to Y as shown below.

Y is given a vector as initial assignment. This can be translated as
Y[0] = 0
Y[1] = 1 and so on

Finally, I specify the attributes for the rule:



rule0 is an assignment rule, where X is the LHS and Y is the RHS. This is actually saying that:
X[9-d0] = Y[d0] where d0 is the dimension id for a Dimension object of the assignment rule with array dimension 0. Since the dimension has size 10, d0 can take any value from 0 to 9. When this is simulated, I get the following:

Values of Y

Values of X

You can see that X has the values of Y in reverse order, just like we specified in the assignment rule.

One of the requirements for a package to be fully accepted to the standard is to have at least two tools implement the package. iBioSim has started the implementation, though it is not yet finalized. Hopefully, there will be other tools using the arrays package because I believe it can be very helpful from a modeling standpoint.

Tuesday, July 22, 2014

Weekly Log: July 14 - July 20

I am posting one day late this week so I apologize. I have been working on the flattening routine for the arrays package. I implemented the algorithm and the routine is completed in two passes:

1. Flatten dimension and index objects

Essentially, what I am doing to flatten SBase objects with dimension objects is making n copies of the arrayed sbase, where n is the product of each dimension size. For instance, imagine you have this SBML model. For the sake of simplicity, I would write this in a Java-base syntax:

Parameter size = 2;
Parameter X = new Parameter[size][size];

Essentially, I would turn this into:

Parameter size = 2;
Parameter X_0_0;
Parameter X_0_1;
Parameter X_1_0;
Parameter X_1_1;

If an SBase you are flattening has math associated with it and in the math there is a dimension id, then I replace the dimension id for the actual index value. When there is an assignment, I update the id of the SBaseRef. For example:

Parameter size = 2;
Parameter X = new Parameter[size][size];
Parameter Y = new Parameter[size][size];

for (int i  = 0; i < 2; ++i) 
  for (int i  = 0; i < 2; ++i) 
    X[i][j] = Y[j][i];

The above example would be turned into:

Parameter size = 2;
Parameter X_0_0, X_0_1, X_1_0, X_1_1;
Parameter Y_0_0, Y_0_1, Y_1_0, Y_1_1;
X_0_0 = {{Y_0_0, Y_0_1}, {Y_1_0, Y_1_1}}[0][0];
X_0_1 = {{Y_0_0, Y_0_1}, {Y_1_0, Y_1_1}}[1][0];
X_1_0 = {{Y_0_0, Y_0_1}, {Y_1_0, Y_1_1}}[0][1];
X_1_1 = {{Y_0_0, Y_0_1}, {Y_1_0, Y_1_1}}[1][1];

Last, I update the Metaid of each SBase.


2. Flatten vector and selector math

After I flatten dimension and index objects, I evaluate vector and selector MathML objects to be just a scalar value. In the above example, the assignments would be turned into:

X_0_0 = Y_0_0;
X_0_1 = Y_1_0;
X_1_0 = Y_0_1;
X_1_1 = Y_1_1;

Vectors are also evaluated and at the end you end up with scalars only.

Here is an example in SBML:

Arrayed model:
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" arrays:required="true" xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1" version="1">
  <model>
    <listOfParameters>
      <parameter id="n" value="10"/>
      <parameter id="X" value="1">
        <arrays:listOfDimensions xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1">
          <arrays:dimension arrays:id="i" arrays:size="n" arrays:arrayDimension="0"/>
        </arrays:listOfDimensions>
      </parameter>
      <parameter id="Y" value="2">
        <arrays:listOfDimensions xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1">
          <arrays:dimension arrays:id="i" arrays:size="n" arrays:arrayDimension="0"/>
        </arrays:listOfDimensions>
      </parameter>
    </listOfParameters>
    <listOfInitialAssignments>
      <initialAssignment symbol="X">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <vector>
            <cn type="integer"> 1 </cn>
            <cn type="integer"> 2 </cn>
            <cn type="integer"> 3 </cn>
            <cn type="integer"> 4 </cn>
            <cn type="integer"> 5 </cn>
            <cn type="integer"> 6 </cn>
            <cn type="integer"> 7 </cn>
            <cn type="integer"> 8 </cn>
            <cn type="integer"> 9 </cn>
            <cn type="integer"> 10 </cn>
          </vector>
        </math>
              <arrays:listOfDimensions xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1">
          <arrays:dimension arrays:id="i" arrays:size="n" arrays:arrayDimension="0"/>
        </arrays:listOfDimensions>
      </initialAssignment>
    </listOfInitialAssignments>
    <listOfRules>
      <assignmentRule variable="Y">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <apply>
            <selector/>
            <ci> X </ci>
            <ci> i </ci>
          </apply>
        </math>
              <arrays:listOfDimensions xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1">
          <arrays:dimension arrays:id="i" arrays:size="n" arrays:arrayDimension="0"/>
        </arrays:listOfDimensions>
        <arrays:listOfIndices xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1">
          <arrays:index arrays:referencedAttribute="variable" arrays:arrayDimension="0">
            <math xmlns="http://www.w3.org/1998/Math/MathML">            
              <apply>
                <minus/>
                <cn type="integer"> 9 </cn>
                <ci> i </ci>
              </apply>
            </math>
                    </arrays:index>
        </arrays:listOfIndices>
      </assignmentRule>
    </listOfRules>
  </model>

</sbml>

Flatten model:
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" arrays:required="true" xmlns:arrays="http://www.sbml.org/sbml/level3/version1/arrays/version1" version="1">
  <model>
    <listOfParameters>
      <parameter id="n" value="10"/>
      <parameter id="X_0" value="1"/>
      <parameter id="X_1" value="1"/>
      <parameter id="X_2" value="1"/>
      <parameter id="X_3" value="1"/>
      <parameter id="X_4" value="1"/>
      <parameter id="X_5" value="1"/>
      <parameter id="X_6" value="1"/>
      <parameter id="X_7" value="1"/>
      <parameter id="X_8" value="1"/>
      <parameter id="X_9" value="1"/>
      <parameter id="Y_0" value="2"/>
      <parameter id="Y_1" value="2"/>
      <parameter id="Y_2" value="2"/>
      <parameter id="Y_3" value="2"/>
      <parameter id="Y_4" value="2"/>
      <parameter id="Y_5" value="2"/>
      <parameter id="Y_6" value="2"/>
      <parameter id="Y_7" value="2"/>
      <parameter id="Y_8" value="2"/>
      <parameter id="Y_9" value="2"/>
    </listOfParameters>
    <listOfInitialAssignments>
      <initialAssignment symbol="X_0">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 1 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_1">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 2 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_2">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 3 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_3">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 4 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_4">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 5 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_5">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 6 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_6">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 7 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_7">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 8 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_8">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 9 </cn>
        </math>
            </initialAssignment>
      <initialAssignment symbol="X_9">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <cn type="integer"> 10 </cn>
        </math>
            </initialAssignment>
    </listOfInitialAssignments>
    <listOfRules>
      <assignmentRule variable="Y_9">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_0 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_8">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_1 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_7">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_2 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_6">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_3 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_5">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_4 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_4">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_5 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_3">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_6 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_2">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_7 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_1">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_8 </ci>
        </math>
            </assignmentRule>
      <assignmentRule variable="Y_0">
        <math xmlns="http://www.w3.org/1998/Math/MathML">        
          <ci> X_9 </ci>
        </math>
            </assignmentRule>
    </listOfRules>
  </model>

</sbml>


Monday, July 14, 2014

Weekly Log: July 7 - July 13

This week I continued working on the compiler that evaluates vectors. I implemented a few of the functions that were missing and I think I am somewhat close to finishing up everything on the compiler.

After the last meeting with my mentor, Nico Rodriguez, we decided to put the validation aside for a little bit and start the implementation of the flattening routine.  Arrays is just syntactic sugar for the modeling language; you can construct models that would behave exactly the same using other constructs. For this reason,  flattening makes a lot of sense in the context of the arrays package. Note that the flattening routine is important for the arrays package because it would allow many tools to simulate arrayed models without much effort.

In a previous meeting, we discussed an algorithm for the arrays package. Chris Myers, one of my mentors, helped me solidify the algorithm. I started the implementation, and I am testing the code. I will post details and the results in the next blog post.

Monday, July 7, 2014

Weekly Log: June 30 - July 6

This week I worked on a compiler that evaluates vectors. For instance, the compiler
  • accepts {{1},{2},{3}} + {{4},{5},{6}} and outputs {{5},{7},{9}}
  • accepts {{1},{2},{3}} + 2 and outputs {{3},{4},{5}}
  • accepts sin({pi, pi/2, -pi}) and outputs {0, 1, 0}
  • and so on.
For every binary or nary operations, the vector dimension of the input nodes should match in size unless it is a scalar. As shown in the example, if you have a vector plus a scalar, then each entry will be incremented by the scalar value. For instance, the compiler
  • rejects {{1},{2},{3}} + {{4}}
  • rejects {1, 2, 3} + {{1},{2},{3}}
  • and so on.
When there is an SIdRef object type, I check if the object has dimensions and, if so, I convert it to a vector. Otherwise, I convert it to a scalar.

Ultimately, the compiler needs to do absolute value, trigonometric operations, logical operations, arithmetic operations, floor, ceiling, fraction, inequalities, lambda function, piecewise function, logarithm operations, power, square root, selector... 

I haven't implemented all of them, but I got a lot of them done. This compiler will be used in the remaining validation rule that specifies that states the vector dimensions should match unless it is a scalar. 

In addition to the compiler, I updated the arrays specification to include a flattening algorithm. I discussed the algorithm with my mentors, Chris and Nico. There are a couple of things that needs to be fixed but the algorithm seem to be in the right track. Perhaps after polishing it a little bit, the algorithm will be good to go and I can start the implementation. The vector compiler can potentially be used in the flattening routine as well.

Monday, June 30, 2014

Weekly Log: June 23 - June 29

I continued to implement validation for the arrays package in JSBML. For the past week, I wrote a compiler for ASTNode objects to evaluate an expression. I wrote this compiler so I can determine whether there is any index math that goes out of bounds. I made the compiler accept a map that maps an id to a value. Each pair corresponds to an array dimension for a certain array object you are referencing. I use the map so I can change the value of a certain id to calculate the lower bound and upper bound for a certain array. 

It is important to note that only indices that are statically computable are allowed. This means if an id appears in the math, the object is refers to should be constant. Even with this implication, determining whether an index goes out of bounds is not easy. Right now, I assume that every index math is monotonically increasing. This way I just need to compute the end points for that function. However, this is not always true. A function may have selectors, piecewise function, trigonometric, and etc, so the bounds can be anywhere in between the end points.  This means that all the points must be evaluated.

As of revision 20642, I have done validation for the following rules:

10206, 1207, 1208, 10209, 10210, 20103, 20104, 20107, 20108, 20111, 20112, 20114, 20202, 20204, 20205, 20302, 20305, 20307, 20308.

There are two rules that says Dimension and Index objects can only have attribute arrayDimension set to 0, 1, or 2, but since it is likely this limitation will be removed in a later version, I am not checking for these rules. 

This week, I am going to do more testing for validation. In addition, I need to implement one validation rule that checks that binary and nary operations have arguments that match in number of dimensions (rule 10211). In addition, I am going to start thinking about the pseudocode for the flattening routine.

Wednesday, June 25, 2014

Monday, June 23, 2014

Weekly Log: June 16 - June 22

The C++ SBML library, libsbml, is quite extensive in terms of validation, and it would be infeasible to validate everything libsbml does in the time frame I have. So my focus is only the arrays package.

This week I started coding for the arrays package validation. In the validation section of the arrays specification, there are categories of validation. For instance, there are lists of rules that are applied to extended SBase objects, dimension objects, index objects, and math, among others.  I tried to be as consistent as possible to the validator in libsbml. The validator I am implementing works as follows: there is a validator for each validation category (sbase, dimension, index...), and each validator checks a set of constraints, where each constraint checks for a certain validation rule (e.g. dimension size should point to a valid parameter with a non-negative integer value and that is both scalar and constant). If a constraint is violated, then an error is reported. The error tells what is wrong with the given document that is being checked. Each validator returns a list of errors. The arrays validator calls the validator for each validation category.

So far, these are the things being validated:
  • Only certain SBase objects can have a listOfDimensions;
  • For listOfDimensions and listOfIndices, array dimension for the objects in the list should be unique;
  • For listOfDimensions and listOfIndices, having an object with array dimension n implies that there is objects with array dimension 0..n-1;
  • Dimension size should point to a parameter. This parameter should be a scalar with a constant non-negative integer value;
  • The first argument of a selector function should point to a vector or an array object.
  • Vectors should be regular, and not rigged.
There are still some validation left to do and this will keep me busy for some time.

Monday, June 16, 2014

Weekly Log: June 9 - June 15

What is a good model? what is a bad model? what is a valid model? These questions are raised when we are proposing a new package. Every package has its own specifications that contains a lot of useful information. For example, it tells what is the purpose of the package, what it contains, how it is constructed, what you can and what you cannot do with it. So far, I have implemented the arrays package in JSBML in accordance with the latest specifications. Though you can construct models with the arrays package, valid models are not enforced in JSBML. This means that nothing prevents you from constructing invalid models. But at this point may ask yourself, what is allowed and what is not allowed in the arrays package.

A valid model is one that does not violate any of the validation rules listed in the spec. Last week I worked mainly on documentation since the arrays package lacked validation rules. I updated the arrays specifications and wrote a list of validation rules.  For example, the arrays package is currently limited to at most three array dimensions. This means that if you add a species with four dimensions, you violate the specifications. So if you are interested to know what the arrays validation rules are,  let me know. The arrays package is still in development, so the spec is not yet finalized and is subject to change. Hopefully, my work helps the community reach a consensus.


It is quite difficult to enforce the validity of SBML models. That's because a modeling tool may allow the user to do something that violates the specifications and also, nothing prevents a user to go into the SBML file and change something that completely ruins the model. Therefore, I am implementing a validator that conforms with the validation rules and automatically checks the validity of a model. More details to come.

Sunday, June 8, 2014

Weekly Log: June 2 - June 8

This week I looked at the Java Compiler Compiler (JavaCC) classes for the infix parsing of the selector function and vector constructor necessary for the arrays package. We can do lexical analysis and parsing using JavaCC.

In lexical analysis, we tokenize a sequence of characters. After we tokenize the input, we define the grammar for the parsing and JavaCC will construct an automata for matching regular expressions. For example, if we receive "3+3" and we define a rule such as:

<Number> ::= [1-9][0-9]*
<Op> :: = [ +, -, *, / ]
<Expression> ::= <Number> <Op> <Number>

Then, that particular string will turn into:

(NUMBER 3) (OP +) (NUMBER 3)

and this sequence will be turned into an expression.

For the selector and vector, I had to define four tokens:

< LEFT_BRACES : "{" >

< RIGHT_BRACES : "}" >

< LEFT_BRACKET : "[" >

< RIGHT_BRACKET : "]" >



The parsing rules are defined as follows:

For vector:
< LEFT_BRACES > node (, node)* < RIGHT_BRACES >
< LEFT_BRACES >  < RIGHT_BRACES >

For selector:
id <LEFT_BRACKET> node < RIGHT_BRACKET>

where node can be anything JSBML supports (number, expressions, strings...).

For example, these are all valid math:
  • {}
  • {1, 2, 3}
  • {{1, 2, 3}, {4, 5, 6}}
  • {cos(x), sin(y)}
  • Y[1]
  • Y[3*1-(31-67)+5]
These are not valid:
  • {1, 3,} 
  • [i]
  • y[]
However, you can still do things such as:
  • Y[-1] reference negative index
  • {{1},{1,2}} vectors of vectors of different sizes
  • and many others
These are not prevented but we would like to be able to tell whether the user constructs a valid model or not. Therefore, I would like to write a piece of code that validates a model (not all SBML core, just for arrays). My next task is to come up with a list of validation rules and figure out how to implement them in the code.

Monday, June 2, 2014

Weekly Log: May 26 - June 1

For the past week, I have been playing with the math for the arrays package. To fully incorporate the math into JSBML, two steps are needed: implement the functions/types in JSBML and the infix parsing of the math. The math extension for the arrays package is the following:

constructors: vector
element referenced operator: selector
qualifier components: bvar, lowlimit, uplimit, condition
sum product operators: sum, product
quantifier operators: forall, exists
statistics operators: mean, sdev, variance, median, mode, moment, moment about

Right now I am going to focus on vector and selector, and the remaining math is for future releases. Vector, as the name suggests, is used to create a vector. In JSBML, a vector node is a collection of ordered ASTNodes. In order to get an element in an array or vector, the selector function is necessary.  The selector function takes an array/vector and the index math to reference a certain element.

Vector and selector are implemented already. Selector was done by one of the mentors, Nico Rodriguez. I have done the vector. To create a vector ASTNode, you can specify vector(0, 1, 2, 3, 4, 5) and this in MathML is equivalent to:

  <vector>
    <cn type="integer"> 0 </cn>
    <cn type="integer"> 1 </cn>
    <cn type="integer"> 2 </cn>
    <cn type="integer"> 3 </cn>
    <cn type="integer"> 4 </cn>
  </vector>

The vector constructor was tested and it seems to be working fine. Once I got this to work, I moved on to infix parsing. The code is there already, but it needs more testing. More details to come.

Wednesday, May 28, 2014

Group Meeting May 28


Today we had a group meeting and we talked about each student's project. For my presentation, I used the slides that can be found at Slides.


Monday, May 26, 2014

Weekly Log: May 19 - May 26

This week I was mainly doing some testing for the code I implemented the previous week. I created JUnit tests for the arrays plugin, dimension, and index classes. I created tests for the methods I implemented and one that creates a file, save to disk, and the read the file to make sure everything was saved. From the test cases, I found some problems with my code. Namely,

- Should I enforce that the model is always valid? At the current moment no. Users can create models that violate the specs (e.g. can create array dimension 3).  This is something validation should ensure. This is something I would like to do this summer. However, there are some cases where we want to make sure the user does not do something bad such as use the same id for two or more elements. If you use the same id 'x' for multiple objects and wanted to delete 'x,' which one of them are you referring to?

- Ids for dimension are locally scoped. Previously, I didn't allow the same id to be used multiple times for dimension objects. However, we want the id for dimensions to be locally scooped, meaning SBase 'x' can have a dimension with id 'i' and SBase 'y' can also have a dimension with 'i.' To account for this issue, I had to use the IdManager within JSBML to tell that it is okay to use the same id as long the dimensions are referring to different objects.

- The above condition implies that the Dimension class should not implement UniqueNamedSBase anymore.

- I also had issues with listOf attributes. For instance, when I have a list of CHILD, JSBML would normally refer the attribute to be 'listOfChilds' instead of 'listOfChildren.' I had to do a check in the plugin class for the case of listOf<Index> since the list attribute should be listOfIndices instead of listOfIndexs.

For the following week, I will be looking at the math necessary for the arrays package. That is, look at the JSBML compiler and figure out the steps needed to implement infix parsing. More info to come.

Sunday, May 18, 2014

Weekly Log: May 11 - May 17

This week, I implemented the main classes for the arrays package. I think during this process, I was able to understand the class hierarchy much better.  The arrays package is pretty simple:

SBase is extended to have 0 or 1 list of dimensions, where the list contains 0 or more dimension objects and dimension inherits from SBase. Dimension is used to indicate an element is arrayed. The id and name are optional fields. The size of an dimension is an referenced to an Sid object. Currently, the size has to be scalar and constant. The array dimension is used to indicate which dimension you are referring to. Currently, the array dimension is limited to have at most three dimensions.

Similarly, SBase is extended to have 0 or 1 list of indices, where the list contains 0 or more index objects and index inherits from SBase. Index is used to reference an element. You specify which attribute (e.g. variable) you are referencing. Array dimension is the same for dimension. The math is used to determine the index value for the referenced element.

This is easier to understand through an example:

n = 5;

int[] y = new int[n];

for(int i = 0; i < n; i++)
  y[i] = i;

To encode this using the arrays package in SBML, n would be a constant parameter, y would have a dimension of size n and arrayDimension would be 0 (1-D array). In the loop, we have an assignment rule where we index the ith element of y and set it to i.

In order to do this in JSBML, I created a plugin for the arrays package, which is used as a place holder for new attributes. In this case, the the attributes are list of dimensions and indices. I created a dimension object with the required fields shown on the UML diagram. Dimension extends AbstractNamedSBase because it can have id and name and implements UniqueNamedSBase to enforce that the identifier associated with the dimension object is unique. Index extends AbstractMathContainer which is a base class for everything that contains math. For both the dimension and index classes, I created getter/setter methods for each field and implemented the abstract methods.

The next step is to throughly test everything.

Tuesday, May 13, 2014

Project Description

I just realized that I made the mistake of not describing the project I will be working on this summer. I proposed the implementation of the arrays package within JSBML since SBML core lacks an efficient representation of regular structures (elements that are used over and over).  Of course the arrays package is just syntactic sugar to the modeling language, just like the Hierarchical Model Composition package, which is an extension in SBML to construct hierarchical models.
This means that you can construct the exact same models without these packages. However, from the modeling standpoint, it becomes much easier to design models when you can construct models hierarchically and in arrays form, especially when you want to model a population of cells.

The arrays package is used to avoid the tedious work of copying over something multiple times. I think arrays is good when you want to indicate multiple elements share the same attributes since X[0] and X[1] are referring to X where as X_0 and X_1 could be two completely different things (this would be bad practice but name conventions are suggested, not enforced).

The arrays package has been proposed.  In order for the arrays package to be officially integrated into SBML, two modeling tools have to support the package. Hopefully, other tools make use of the arrays package because I think it is a nice feature. Also, I hope that the arrays package helps revive the Dynamic Structures package, which is currently stalled (there are some nice discussion about this package though).

Sunday, May 11, 2014

Weekly Log: May 4 - May 9

I was very excited when I found out I was accepted into the Google Summer of Code program.
Currently, we are in the period that Google calls Community Bonding, which is a period that we get to know our mentors. I had a virtual meeting with my mentors Chris and Nico this past week. It was pretty helpful talking to them, as I was able to ask a couple of questions and also get some directions as to what I am supposed to be doing for the rest of the week. Prior to that, I had a meeting with everyone participating in the JSBML projects for GSoC. We, the students, got to meet with each other and talk about what we will be working on this summer. We also got help setting up the project on our machines.

Last week I was studying the classes for a couple package extensions that were already implemented to SBML core since I will be implementing the arrays package. First impression is that it is going to be straightforward to implement the necessary classes for arrays. However, I expect that there will be some tricky parts in the future. My mentors instructed me to read the user guide for JSBML. The user guide contains the information necessary for implementing extensions for JSBML. I was pretty impressed how detailed the user guide is. I was able to make the skeleton of the arrays extension.

Thursday, May 8, 2014

Introduction

Hello all,

My name is Leandro Watanabe. I recently graduated with a bachelor's degree in Computer Engineering/Computer Science from the University of Utah. This summer, I will be helping the JSBML community with the implementation of the arrays package. This package will allow the to representation of regular constructs more efficiently in SBML models, which is a current limitation of SBML core. I will be helping the implementation of the Java version of SBML.

I am very excited for this opportunity and looking forward to working with the mentors and other students involved in projects related to JSBML. I think it will be a great summer!