estim8.objective#

This module implements the objective functions that are passed to an optimization algorithm.

class estim8.objective.Objective(func: Callable, bounds: Dict[str, List[float]], parameter_mapping: ParameterMapping, mc_sample: int | None = 0)#

Bases: object

Objective function that is passed to an optimization algorithm. When called to evaluate a parameter set theta, conducts a replicate handling step and sends request for loss calculation to federated worker nodes via a compiled pytensor.function

Methods

__call__(theta)

Evaluate the objective function for a given parameter set.

estim8.objective.global_objective(*replicate_par_sets, local_objective: Callable)#

Calculates a global objective as the sum of local objective mapped to replicate parameter sets.

Parameters:
local_objectivecallable

The local objective function.

Returns:
list

The global objective value.

estim8.objective.objective_function_wrapper(theta: array, objective, task_id: str | None = None) float#

A wrapper around the objective. Creates global copy of the objective function in the current process to avoid serialization on every function call, and stores it in a dictionary with a unique task ID.

Parameters:
thetanp.array

The parameter set to evaluate.

objective: tuple

A serialized callable.

task_idstr, optional

The task ID, by default None.

Returns:
float

The loss value.