Open-Systems-Pharmacology / OSPSuite.SimModel

Calculation engine for models built with PK-Sim® or MoBi®
Other
5 stars 3 forks source link

Add id field to ExplicitFormulaExtender #44

Closed PavelBal closed 5 years ago

PavelBal commented 6 years ago

A fix for correctly updating scale factors after finalization of the simulation (as required for the respective functionality in R and Matlab-Toolbox, see https://github.com/Open-Systems-Pharmacology/R-Toolbox/issues/52) can be implemented by adding a list of referenced formulas to a species object. This requires each formula to have a valid id, which is true for all formulas created.

However, ExplicitFormulaExtender does not possess an id, and unit tests utilizing ExplicitFormulaExtender would fail. Please add a respective field.

To clarify: the proposed fix adds a TObjectList<Formula> _allFormulaList; to the species class. Upon finalization of a formula, the formula is added to _allFormulaList of each species referenced by the formula:

   for (unsigned int i = 0; i < _quantityRefs.size(); i++)
   {
      QuantityReference quantityRef = _quantityRefs[i];
      if (quantityRef.IsSpecies())
      {
         SimModelNative::Species * species = quantityRef.GetSpecies();
         species->AddFormulaReference(this);
      }
   }

with

void Species::AddFormulaReference(Formula * formula)
{
   _allFormulaList.Add(formula);
   _allFormulaListSize = _allFormulaList.size();
}

_allFormulaList.Add(formula); fails if formula has no ID, which is the case with ExplicitFormulaExtender used in unit tests.

PavelBal commented 6 years ago

Whats the statut on this one?