atomica.optimization.DecreaseByMeasurable¶
- class atomica.optimization.DecreaseByMeasurable(measurable_name, t, decrease, pop_names=None, target_type='frac')[source]¶
Bases:
Measurable
Decrease quantity by percentage
This Measurable stores the value of a quantity using the original instructions. It then requires that there is a minimum increase in the value of the quantity during optimization. For example
>>> DecreaseByMeasurable('deaths',2030,0.05)
This Measurable would correspond to an decrease of 5% in the number of deaths in 2030.
The measurable returns
np.inf
if the condition is violated, and0.0
otherwise.- 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
decrease – The amount by which to decrease the measurable (e.g. 0.05 for a 5% decrease). Use
target_type='abs'
to specify an absolute decreasepop_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
target_type – Specify fractional ‘frac’ or absolute ‘abs’ decrease (default is fractional)
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
- Return type:
- Returns:
The value to pass back to the
Measurable
during optimization