piglot.objectives.fitting.FittingSingleObjective

class FittingSingleObjective(name: str, reference: Reference, prediction: List[str], reduction: Reduction, weight: float = 1.0, bounds: Tuple[float, float] | None = None)[source]

Bases: ResponseSingleObjective

Single objective for curve fitting optimisation objectives.

Methods

evaluate

Evaluate objective value for the given results.

evaluate_from_latent_space

Evaluate the objective value(s) from the latent space representation.

latent_space

Compute latent space representation of the given results (for composite objectives).

plot

Plot the response for this objective.

read

Read the objective spec from the configuration dictionary.

evaluate(params: ndarray, raw_results: Dict[str, OutputResult]) Tuple[float, float]

Evaluate objective value for the given results.

Parameters

paramsnp.ndarray

Parameter values for this evaluation.

raw_resultsDict[str, OutputResult]

Raw responses from the solver.

Returns

Tuple[float, float]

Mean and variance of the objective.

evaluate_from_latent_space(params: Tensor, latent_responses: Tensor) Tensor

Evaluate the objective value(s) from the latent space representation.

Parameters

paramstorch.Tensor

Parameter values for these results.

latent_responsestorch.Tensor

Response(s) in the latent space representation.

Returns

torch.Tensor

Objective value(s) for the response(s).

latent_space(raw_results: Dict[str, OutputResult]) Tuple[ndarray, ndarray]

Compute latent space representation of the given results (for composite objectives).

Parameters

raw_resultsDict[str, OutputResult]

Raw responses from the solver.

Returns

Tuple[np.ndarray, np.ndarray]

Mean and variance of the latent space representation.

plot(axis: Axes, raw_results: Dict[str, OutputResult]) Dict[Line2D, str][source]

Plot the response for this objective.

Parameters

axisplt.Axes

Axis to plot the response on.

raw_resultsDict[str, OutputResult]

Raw responses from the solver.

Returns

Dict[Line2D, str]

Mapping of lines to response names (for dynamically updating plots).

classmethod read(name: str, config: Dict[str, Any], output_dir: str) FittingSingleObjective[source]

Read the objective spec from the configuration dictionary.

Parameters

namestr

Name of the objective.

configDict[str, Any]

Configuration dictionary.

output_dir: str

Output directory.

Returns

ResponseSingleObjective

Single objective to use.