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 simulated Model object. It takes in a Model and returns a scalar value. Often, an optimization may contain multiple Measurable objects, and the objective value returned by each of them is summed together.

  • 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




Return cached baseline values


Return objective value


Return cached baseline values

Similar to get_hard_constraint, sometimes a relative Measurable 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 the Measurable receives an initial Model object and extracts baseline data for subsequent use in get_objective_val.

Thus, the output of this function is paired to its usage in get_objective_val.




The value to pass back to the Measurable during optimization

get_objective_val(model, baseline)[source]

Return objective value

This method should return the _unweighted_ objective value. Note that further transformation may occur

  • model (Model) – A Model object after integration

  • baseline – The baseline variable returned by this Measurable at the start of optimization

Return type



A scalar objective value