gemseo_benchmark / data_profiles

Hide inherited members

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. 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)

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:

PerformanceHistory

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:

PerformanceHistory

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:

PerformanceHistory

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:

PerformanceHistory

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:

list[int]

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:

PerformanceHistory

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:

PerformanceHistory

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:

PerformanceHistory

get_plot_data(feasible=False, minimum_history=False)

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(show=True, file_path=None)[source]

Plot the target values.

Parameters:
  • show (bool) –

    Whether to show the plot.

    By default it is set to True.

  • file_path (str | Path | None) – The path where to save the plot. If None, the plot is not saved.

Returns:

A figure showing the target values.

Return type:

Figure

remove_leading_infeasible()

Return the history starting from the first feasible item.

Returns:

The truncated performance history.

Return type:

PerformanceHistory

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:

PerformanceHistory

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 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.