linearization_mixin.py 1 KB
Newer Older
1 2
import logging

Jorn Baayen's avatar
Jorn Baayen committed
3 4
from .optimization_problem import OptimizationProblem

5 6 7 8 9 10 11 12 13 14 15 16 17
logger = logging.getLogger("rtctools")


class LinearizationMixin(OptimizationProblem):
    """
    Adds linearized equation parameter bookkeeping to your optimization aproblem.  If your model contains 
    linearized equations, this mixin will set the parameters of these equations based on the t0 value of an associated
    timeseries.

    The mapping between linearization parameters and time series is provided in the ``linearization_parameters`` method.
    """

    def parameters(self, ensemble_member):
18
        parameters = super().parameters(ensemble_member)
19

20
        for parameter, timeseries_id in self.linearization_parameters().items():
21 22 23 24 25 26 27 28 29 30
            parameters[parameter] = self.timeseries_at(timeseries_id, self.initial_time, ensemble_member)

        return parameters

    def linearization_parameters(self):
        """
        :returns: A dictionary of parameter names mapping to time series identifiers.
        """

        return {}