gemseo_benchmark / data_profiles

Hide inherited members

targets_generator module

Generation of targets for a problem to be solved by an iterative algorithm.

The targets are generated out of algorithms histories considered to be of reference: the median of the reference histories is computed and a uniformly distributed subset (of the required size) of this median history is extracted.

class gemseo_benchmark.data_profiles.targets_generator.TargetsGenerator[source]

Bases: object

Compute the target values for an objective to minimize.

add_history(objective_values=None, infeasibility_measures=None, feasibility_statuses=None, history=None)[source]

Add a history of objective values.

Parameters:
  • objective_values (Sequence[float] | None) – A history of objective values. If None, a performance history must be passed. N.B. the value at index i is assumed to have been obtained with i+1 evaluations.

  • infeasibility_measures (Sequence[float] | None) – A history of infeasibility measures. If None then measures are set to zero in case of feasibility and set to infinity otherwise.

  • feasibility_statuses (Sequence[bool] | None) – A history of (boolean) feasibility statuses. If None then feasibility is always assumed.

  • history (PerformanceHistory | None) – A performance history. If None, objective values must be passed.

Raises:

ValueError – If neither a performance history nor objective values are passed, or if both are passed.

Return type:

None

compute_target_values(targets_number, budget_min=1, feasible=True, show=False, file_path=None, best_target_objective=None, best_target_tolerance=0.0)[source]

Compute the target values for a function from the histories of its values.

Parameters:
  • targets_number (int) – The number of targets to compute.

  • budget_min (int) –

    The number of functions evaluations to be used to define the first target. If argument feasible is set to True, this argument will be disregarded and the evaluation budget defining the easiest target will be the budget of the first item in the histories reaching the best target value.

    By default it is set to 1.

  • feasible (bool) –

    Whether to generate only feasible targets.

    By default it is set to True.

  • show (bool) –

    Whether to show the plot.

    By default it is set to False.

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

  • best_target_objective (float | None) – The objective value of the best target value. If None, it will be inferred from the performance histories.

  • best_target_tolerance (float) –

    The relative tolerance for comparison with the best target value.

    By default it is set to 0.0.

Returns:

The target values of the function.

Raises:

RuntimeError – If feasibility is required but the best target value is not feasible.

Return type:

TargetValues

plot_histories(best_target_value=None, show=False, file_path=None)[source]

Plot the histories used as a basis to compute the target values.

Parameters:
  • best_target_value (float | None) – The best target value to be represented with a horizontal line. If None, no best target value will be plotted.

  • show (bool) –

    Whether to show the figure.

    By default it is set to False.

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

Returns:

The histories figure.

Return type:

Figure