Open-Systems-Pharmacology / OSPSuite.Core

Core functionalities of the Open Systems Pharmacology Suite
Other
5 stars 8 forks source link

Formulas are resolved before applying PV - unwanted behavior #2297

Closed PavelBal closed 3 months ago

PavelBal commented 3 months ago

formula-resolved-before-pb.zip

In the attached project, the module Test2 defines a parameter Organism|Param by an invalid formula (the referenced parameter foo is not present).

image

Additionally, the value of the parameter is defined in the PV BB

image

When trying to create a simulation, an error is thrown that foo is not found. This behavior is unwanted, as I want the value defined in the PV BB to be applied without the formula being evaluated. This is how it worked in MoBi 11, and it was a way to overwrite parameters that otherwise would not be resolved.

msevestre commented 3 months ago

this worked before?

PavelBal commented 3 months ago

Yes, V11.

msevestre commented 3 months ago

ok moving to core

msevestre commented 3 months ago

@PavelBal I don't think this worked before. PSV were applied after validation . But anyways

msevestre commented 3 months ago

hum nevermind. It's validating the configuration and not the updated model

msevestre commented 3 months ago

ok so this is because of this code here

  var actualParameterValue = parameterValue.Value.Value;
  if (parameter.Formula is ConstantFormula constantFormula)
     constantFormula.Value = actualParameterValue;
  else
     parameter.Value = actualParameterValue;

We say that if the formula is constant, we overwrite the constant value with the value Otherwise we simply let the formula and let the isFixedValue= true in the simulation

@Yuri05 and @PavelBal I tired to skp validation if the value is overwritten. But this does not work because then we try to resolve references later on So we need to OVERWRITTE WRONG FORMULAS with constant somehow. That means that we need to evaluate them all again.... doable but a bit of a pain

PavelBal commented 3 months ago

I don't think this worked before. PSV were applied after validation . But anyways

This definitely worked, I relied on this concept a lot in my projects and now I cannot create the simulations because of this changed behavior :)