target_values module¶
Computation of target values out of algorithms performance histories.
Consider a problem to be solved by an iterative algorithm, e.g. an optimization problem
or a root-finding problem. Targets are values, i.e. values of the objective function or
values of the residual norm, ranging from a first acceptable value to the best known
value for the problem. Targets are used to estimate the efficiency (relative to the
number of problem functions evaluations) of an algorithm to solve a problem (or several)
and computes its data profile (see data_profiles.data_profile
).
- class gemseo_benchmark.data_profiles.target_values.TargetValues(objective_values=None, infeasibility_measures=None, feasibility_statuses=None, n_unsatisfied_constraints=None, problem_name=None, objective_name=None, constraints_names=None, doe_size=None, total_time=None, algorithm_configuration=None, number_of_variables=None)[source]¶
Bases:
PerformanceHistory
Target values of a problem.
- Parameters:
objective_values (Sequence[float] | None) – The history of the quantity to be minimized. If
None
, will be considered empty.infeasibility_measures (Sequence[float] | None) – The history of infeasibility measures. An infeasibility measure is a non-negative real number representing the gap between the design and the feasible space, a zero value meaning feasibility. If
None
and feasibility_statuses is not None then the infeasibility measures are set to zero in case of feasibility, and set to infinity otherwise. IfNone
and feasibility_statuses is None then every infeasibility measure is set to zero.feasibility_statuses (Sequence[bool] | None) – The history of the (boolean) feasibility statuses. If infeasibility_measures is not None then feasibility_statuses is disregarded. If
None
and ‘infeasibility_measures’ is None then every infeasibility measure is set to zero.n_unsatisfied_constraints (Sequence[int] | None) – The history of the number of unsatisfied constraints. If
None
, the entries will be set to 0 for feasible entries and None for infeasible entries.problem_name (str | None) – The name of the problem. If
None
, it will not be set.objective_name (str | None) – The name of the objective function. If
None
, it will not be set.constraints_names (Sequence[str] | None) – The names the scalar constraints. Each name must correspond to a scalar value. If
None
, it will not be set.doe_size (int | None) – The size of the initial design of experiments. If
None
, it will not be set.total_time (float | None) – The total time of the optimization, in seconds. If
None
, it will not be set.algorithm_configuration (AlgorithmConfiguration | None) – The name of the algorithm which generated the history. If
None
, it will not be set.number_of_variables (int | None) – The number of optimization variables. If
None
, it will not be set.
- Raises:
ValueError – If the lengths of the histories do not match.
- apply_infeasibility_tolerance(infeasibility_tolerance)¶
Apply a tolerance on the infeasibility measures of the history items.
Mark the history items with an infeasibility measure below the tolerance as feasible.
- Parameters:
infeasibility_tolerance (float) – the tolerance on the infeasibility measure.
- Return type:
None
- compute_cumulated_minimum()¶
Return the history of the cumulated minimum.
- Returns:
The history of the cumulated minimum.
- Return type:
- static compute_maximum_history(histories)¶
Return the maximum of several performance histories.
- Parameters:
histories (Iterable[PerformanceHistory]) – The performance histories
- Returns:
The maximum history.
- Return type:
- static compute_median_history(histories)¶
Return the median of several performance histories.
- Parameters:
histories (Iterable[PerformanceHistory]) – The performance histories
- Returns:
The median history.
- Return type:
- static compute_minimum_history(histories)¶
Return the minimum of several performance histories.
- Parameters:
histories (Iterable[PerformanceHistory]) – The performance histories
- Returns:
The minimum history.
- Return type:
- compute_target_hits_history(values_history)[source]¶
Compute the history of the number of target hits for a performance history.
- Parameters:
values_history (PerformanceHistory) – The history of values.
- Returns:
The history of the number of target hits.
- Return type:
- count(value) integer -- return number of occurrences of value ¶
- extend(size)¶
Extend the performance history by repeating its last item.
If the history is longer than the expected size then it will not be altered.
- Parameters:
size (int) – The expected size of the extended performance history.
- Returns:
The extended performance history.
- Raises:
ValueError – If the expected size is smaller than the history size.
- Return type:
- classmethod from_file(path)¶
Create a new performance history from a file.
- Parameters:
path (str | Path) – The path to the file.
- Returns:
The performance history.
- Return type:
- classmethod from_problem(problem, problem_name=None)¶
Create a performance history from a solved optimization problem.
- Parameters:
problem (OptimizationProblem) – The optimization problem.
problem_name (str | None) – The name of the problem. If
None
, the name of the problem is not set.
- Returns:
The performance history.
- Return type:
- get_plot_data(feasible=False, minimum_history=False)¶
Return the data to plot the performance history.
- Parameters:
- Returns:
The abscissas and the ordinates of the plot.
- Return type:
tuple[list[int], list[gemseo_benchmark.results.history_item.HistoryItem]]
- index(value[, start[, stop]]) integer -- return first index of value. ¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- remove_leading_infeasible()¶
Return the history starting from the first feasible item.
- Returns:
The truncated performance history.
- Return type:
- shorten(size)¶
Shorten the performance history to a given size.
If the history is shorter than the expected size then it will not be altered.
- Parameters:
size (int) – The expected size of the shortened performance history.
- Returns:
The shortened performance history.
- Return type:
- to_file(path)¶
Save the performance history in a file.
- Parameters:
path (str | Path) – The path where to write the file.
- Return type:
None
- property items: list[gemseo_benchmark.results.history_item.HistoryItem]¶
The history items.
- Raises:
TypeError – If an item is set with a type different from HistoryItem.