piglot.objectives package
Submodules
piglot.objectives.analytical module
Provide analytical functions for optimisation.
- class AnalyticalMultiObjective(parameters: ParameterSet, objectives: Dict[str, AnalyticalSingleObjective], stochastic: bool = False, scalarisation: Scalarisation | None = None, composite: bool = False, output_dir: str | None = None)[source]
Bases:
GenericObjectiveMulti-objective problem derived from a set of analytical expressions.
- plot_case(case_hash: str, options: Dict[str, Any] | None = None) List[Figure][source]
Plot a given function call given the parameter hash.
Parameters
- case_hashstr, optional
Parameter hash for the case to plot.
- optionsDict[str, Any], optional
Options to pass to the plotting function, by default None.
Returns
- List[Figure]
List of figures with the plot.
- classmethod read(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) AnalyticalMultiObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
- output_dirstr
Path to the output directory.
Returns
- SyntheticObjective
Objective function to optimise.
- class AnalyticalObjective(parameters: ParameterSet, expression: str, variance: str | None = None, stochastic: bool = False, random_evals: int = 0, output_dir: str | None = None, maximise: bool = False, weight: float = 1.0, bounds: Tuple[float, float] | None = None)[source]
Bases:
GenericObjectiveObjective function derived from an analytical expression.
- plot_case(case_hash: str, options: Dict[str, Any] | None = None) List[Figure][source]
Plot a given function call given the parameter hash.
Parameters
- case_hashstr, optional
Parameter hash for the case to plot.
- optionsDict[str, Any], optional
Options to pass to the plotting function, by default None.
Returns
- List[Figure]
List of figures with the plot.
- classmethod read(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) AnalyticalObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
- output_dirstr
Path to the output directory.
Returns
- SyntheticObjective
Objective function to optimise.
- class AnalyticalSingleObjective(parameters: ParameterSet, expression: str, variance: str | None = None, random_evals: int = 0, maximise: bool = False, weight: float = 1.0, bounds: Tuple[float, float] | None = None)[source]
Bases:
IndividualObjectiveObjective function derived from an analytical expression.
- evaluate(params: ndarray, use_random: bool = True) Tuple[float, float][source]
Evaluate objective value for the given results.
Parameters
- paramsnp.ndarray
Parameter values for this evaluation.
- use_randombool
Whether to use random evaluations (true by default).
Returns
- Tuple[float, float]
Mean and variance of the objective.
- plot_1d(values: ndarray, append_title: str) Figure[source]
Plot the objective in 1D.
Parameters
- valuesnp.ndarray
Parameter values to plot for.
- append_titlestr
String to append to the title.
Returns
- Figure
Figure with the plot.
- plot_2d(values: ndarray, append_title: str) Figure[source]
Plot the objective in 2D.
Parameters
- valuesnp.ndarray
Parameter values to plot for.
- append_titlestr
String to append to the title.
Returns
- Figure
Figure with the plot
- classmethod read(config: Dict[str, Any], parameters: ParameterSet) AnalyticalSingleObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
Returns
- AnalyticalSingleObjective
Objective function to optimise.
- class ScalarisationComposition(scalarisation: Scalarisation)[source]
Bases:
CompositionComposition for scalarisation of multiple objectives.
piglot.objectives.compositions module
piglot.objectives.design module
Module for curve fitting objectives
- class DesignSingleObjective(name: str, prediction: List[str], quantity: Reduction, maximise: bool = False, weight: float = 1.0, bounds: Tuple[float, float] | None = None, flatten_utility: FlattenUtility | None = None, prediction_transform: ResponseTransformer | None = None)[source]
Bases:
ResponseSingleObjectiveSingle objective for design optimisation objectives.
- 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) DesignSingleObjective[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.
- class ResponseDesignObjective(parameters: ParameterSet, solver: Solver, objectives: List[ResponseSingleObjective], output_dir: str, scalarisation: Scalarisation | None = None, stochastic: bool = False, composite: bool = False, full_composite: bool = True, transformers: Dict[str, ResponseTransformer] | None = None)[source]
Bases:
ResponseObjectiveClass for design of response-based objectives.
- classmethod read(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) ResponseDesignObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
- output_dirstr
Path to the output directory.
Returns
- ResponseDesignObjective
Objective function to optimise.
piglot.objectives.fitting module
Module for curve fitting objectives
- class FittingSingleObjective(name: str, reference: Reference, prediction: List[str], reduction: Reduction, weight: float = 1.0, bounds: Tuple[float, float] | None = None)[source]
Bases:
ResponseSingleObjectiveSingle objective for curve fitting optimisation objectives.
- 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.
- class Reference(filename: str, output_dir: str, x_col: int = 1, y_col: int = 2, skip_header: int = 0, transformer: ResponseTransformer | None = None, filter_tol: float = 0.0, show: bool = False)[source]
Bases:
objectContainer for reference solutions.
- has_filtering() bool[source]
Check if the reference has filtering.
Returns
- bool
Whether the reference has filtering.
- static read(filename: str, config: Dict[str, Any], output_dir: str) Reference[source]
Read the reference from the configuration dictionary.
Parameters
- filenamestr
Path to the reference file.
- configDict[str, Any]
Configuration dictionary.
- output_dir: str
Output directory.
Returns
- Reference
Reference to use for this problem.
- class ResponseFittingObjective(parameters: ParameterSet, solver: Solver, objectives: List[ResponseSingleObjective], output_dir: str, scalarisation: Scalarisation | None = None, stochastic: bool = False, composite: bool = False, full_composite: bool = True, transformers: Dict[str, ResponseTransformer] | None = None)[source]
Bases:
ResponseObjectiveClass for fitting of response-based objectives.
- prepare()[source]
Prepare the objective for optimisation.
For curve fitting, this involves preparing the reference data and updating both the flatten utility and the transformer.
- classmethod read(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) ResponseFittingObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
- output_dirstr
Path to the output directory.
Returns
- ResponseFittingObjective
Objective function to optimise.
piglot.objectives.synthetic module
Provide synthetic test functions
- class SyntheticObjective(parameters: ParameterSet, name: str, output_dir: str, transform: str | None = None, composition: Reduction | None = None, **kwargs)[source]
Bases:
GenericObjectiveObjective function derived from a synthetic test function.
- static get_test_functions() Dict[str, Type[SyntheticTestFunction]][source]
Return available test functions.
Returns
- Dict[str, Type[SyntheticTestFunction]]
Available test functions.
- static read(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) SyntheticObjective[source]
Read the objective from a configuration dictionary.
Parameters
- configDict[str, Any]
Terms from the configuration dictionary.
- parametersParameterSet
Set of parameters for this problem.
- output_dirstr
Path to the output directory.
Returns
- SyntheticObjective
Objective function to optimise.
Module contents
Interface for objectives.
- read_objective(config: Dict[str, Any], parameters: ParameterSet, output_dir: str) Objective[source]
Read the objective from the configuration dictionary.
Parameters
- configDict[str, Any]
Configuration dictionary.
- parametersParameterSet
Parameter set for this problem.
- output_dirstr
Path to the output directory.
Returns
- Objective
Objective to optimise for.