atomica.optimization.AtLeastMeasurable

class atomica.optimization.AtLeastMeasurable(measurable_name, t, threshold, pop_names=None)[source]

Bases: Measurable

Enforce quantity exceeds a value

This Measurable imposes a penalty if the quantity is smaller than some threshold The initial points should be ‘valid’ in the sense that the quantity starts out above the threshold (and during optimization it will never be allowed to cross the threshold)

Typically, this Measurable would be used in money minimization in conjunction with measurables that aim to minimize spending.

The measurable returns np.inf if the condition is violated, and 0.0 otherwise.

Methods

eval

get_baseline

Return cached baseline values

get_objective_val

Return objective value

get_baseline(model)

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.

Parameters:

model

Returns:

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

Parameters:
  • model – A Model object after integration

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

Returns:

A scalar objective value