ciemss / pyciemss

Causal and probabilistic reasoning with continuous time dynamical systems
Other
17 stars 6 forks source link

Remove mira placeholder parameters from MiraPetriNetODESystem #252

Closed djinnome closed 1 year ago

djinnome commented 1 year ago
parameters = {param: value for param, value in self.G.parameters.items()
                               if value and value.placeholder == False}
VigneshSella commented 1 year ago

@SamWitty Changes to the parameters (by removing placeholders) causes multiple test cases to fail. First error is a getattr issue:

            flux = getattr(self, get_name(transition.rate)) * functools.reduce(
                operator.mul, [states[k] for k in transition.consumed], 1
            )
>       raise AttributeError("'{}' object has no attribute '{}'".format(
            type(self).__name__, name))
E       AttributeError: 'ScaledBetaNoisePetriNetODESystem' object has no attribute '(('Susceptible', ('identity', 'ido:0000514')), ('Exposed', ('identity', 'apollosv:00000154')), ('Infectious', ('identity', 'ido:0000511'), ('disease_severity', 'ncit:C25269'), ('hospitalization', 'ncit:C68851')), 'ControlledConversion', 'rate')'

The transitions in getattr(self, get_name(transition.rate)) come from self.G.transitions.values() - the transitions.rates are mira.modeling.ModelParameters and utilize placeholder parameters. Even if we drop mass_action_deriv, other tests fail.

Instead, I've committed the following:

        self.Gparameters = {param: value for param, value in self.G.parameters.items()
            if value and value.placeholder == False}

which can be used to output parameters which are not placeholders in the output.