atomica.optimization.Measurable¶
- class atomica.optimization.Measurable(measurable_name, t, pop_names=None, weight=1.0)[source]¶
Bases:
object
Optimization objective
A
Measurable
is a class that returns an objective value based on a simulatedModel
object. It takes in aModel
and returns a scalar value. Often, an optimization may contain multipleMeasurable
objects, and the objective value returned by each of them is summed together.- Parameters:
measurable_name – The base measurable class accepts the name of a program (for spending) or a quantity supported by
Population.get_variable()
t – Single year, or a list of two start/stop years. If specifying a single year, that year must appear in the simulation output. The quantity will be summed over all simulation time points
pop_names – The base Measurable class takes in the names of the populations to use. If multiple populations are provided, the objective will be added across the named populations
weight – The weight factor multiplies the quantity
Methods
eval
Return cached baseline values
Return objective value
- get_baseline(model)[source]¶
Return cached baseline values
Similar to
get_hard_constraint
, sometimes a relativeMeasurable
might be desired e.g. ‘Reduce deaths by at least 50%’. In that case, we need to perform a procedure similar to getting a hard constraint, where theMeasurable
receives an initialModel
object and extracts baseline data for subsequent use inget_objective_val
.Thus, the output of this function is paired to its usage in
get_objective_val
.- Parameters:
model
- Returns:
The value to pass back to the
Measurable
during optimization