gemseo_benchmark / results

Hide inherited members

performance_history module

Class that generates performance measures out of data generated by an algorithm.

Iterative algorithms that solve, for example, optimization problems or equations produce histories of data such as the value of the objective to minimize, or the size of the equation residual, at each iteration. The best value obtained up until each iteration can be generated out of this data. Here we call “performance history” the history of the best values obtained up until each iteration.

Infeasible data can be discarded based upon histories of infeasibility measures or boolean feasibility statuses.

Performance histories can be used to generate target values for a problem, or to generate the data profile of an algorithm.

class gemseo_benchmark.results.performance_history.PerformanceHistory(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: Sequence

A history of performance measures generated by an algorithm.

A PerformanceHistory is a sequence of HistoryItems.

problem_name

The name of the problem.

Type:

str

total_time

The run time of the algorithm.

Type:

float

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. If None 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)[source]

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()[source]

Return the history of the cumulated minimum.

Returns:

The history of the cumulated minimum.

Return type:

PerformanceHistory

static compute_maximum_history(histories)[source]

Return the maximum of several performance histories.

Parameters:

histories (Iterable[PerformanceHistory]) – The performance histories

Returns:

The maximum history.

Return type:

PerformanceHistory

static compute_median_history(histories)[source]

Return the median of several performance histories.

Parameters:

histories (Iterable[PerformanceHistory]) – The performance histories

Returns:

The median history.

Return type:

PerformanceHistory

static compute_minimum_history(histories)[source]

Return the minimum of several performance histories.

Parameters:

histories (Iterable[PerformanceHistory]) – The performance histories

Returns:

The minimum history.

Return type:

PerformanceHistory

count(value) integer -- return number of occurrences of value
extend(size)[source]

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:

PerformanceHistory

classmethod from_file(path)[source]

Create a new performance history from a file.

Parameters:

path (str | Path) – The path to the file.

Returns:

The performance history.

Return type:

PerformanceHistory

classmethod from_problem(problem, problem_name=None)[source]

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:

PerformanceHistory

get_plot_data(feasible=False, minimum_history=False)[source]

Return the data to plot the performance history.

Parameters:
  • feasible (bool) –

    Whether to get only feasible values.

    By default it is set to False.

  • minimum_history (bool) –

    Whether to get the history of the cumulated minimum instead of the history of the objective value.

    By default it is set to False.

Returns:

The abscissas and the ordinates of the plot.

Return type:

tuple[list[int], list[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.

plot(axes, only_feasible, **kwargs)[source]

Plot the performance history.

Parameters:
  • axes (Axes) – The axes on which to plot the performance history.

  • only_feasible (bool) – Whether to plot the feasible items only.

  • **kwargs (str | float) – The options to be passed to Axes.plot.

Return type:

None

remove_leading_infeasible()[source]

Return the history starting from the first feasible item.

Returns:

The truncated performance history.

Return type:

PerformanceHistory

shorten(size)[source]

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:

PerformanceHistory

to_file(path)[source]

Save the performance history in a file.

Parameters:

path (str | Path) – The path where to write the file.

Return type:

None

property infeasibility_measures: list[float]

The infeasibility measures.

property items: list[HistoryItem]

The history items.

Raises:

TypeError – If an item is set with a type different from HistoryItem.

property n_unsatisfied_constraints: list[int]

The numbers of unsatisfied constraints.

property objective_values: list[float]

The objective values.