physbo.search.utility module

class physbo.search.utility.Simulator(test_X, test_function, negate=False)[source]

Bases: object

Simulator class wrapping the test function for discrete search space.

Parameters:
  • test_X (numpy.ndarray) – The test points. Each row is a candidate.

  • test_function (physbo.test_functions.base.TestFunction) – The test function.

  • negate (bool, default=False) – If True, the test function value is negated before returning.

physbo.search.utility.is_learning(n, interval)[source]
physbo.search.utility.length_vector(t)[source]
physbo.search.utility.make_grid(min_X: list[float] | ndarray, max_X: list[float] | ndarray, num_X: int | list[int] | ndarray, constraint=None) ndarray[source]

Make a grid of points in the search space.

Parameters:
  • min_X (np.ndarray | list[float] | float) – Minimum value of search space for each dimension

  • max_X (np.ndarray | list[float] | float) – Maximum value of search space for each dimension

  • num_X (int | list[int] | np.ndarray) – Number of points in each dimension

Returns:

The grid of points in the search space The output is a numpy array of shape (N, d), where N is the number of points and d is the dimension of the search space

Return type:

np.ndarray

Raises:

ValueError – If min_X and max_X have different number of dimensions If num_X has different number of dimensions from min_X and max_X

physbo.search.utility.plot_pareto_front(history, x=0, y=1, steps_begin=0, steps_end=None, ax=None, xlim=None, ylim=None, grid=True, style_common: dict = {}, style_pareto_front: dict = {}, style_dominated: dict = {})[source]

Plot the Pareto front of the history in the projection to the (x, y)-plane (objective x and y).

Parameters:
  • history (History) – The history of the search.

  • x (int, default=0) – The index of the objective to plot on the x-axis.

  • y (int, default=1) – The index of the objective to plot on the y-axis.

  • steps_begin (int, default=0) – The index (inclusive) of the step to begin plotting.

  • steps_end (int, optional) – The index (exclusive) of the step to end plotting. If None, plot until the end.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If None, a new figure is created.

  • xlim (tuple, optional) – The x-axis limits. If None, the limits are determined automatically.

  • ylim (tuple, optional) – The y-axis limits. If None, the limits are determined automatically.

  • grid (bool, default=True) – Whether to plot the grid.

  • style_common (dict, optional) – The common setting for plotting the points.

  • style_pareto_front (dict, optional) – The setting for plotting the Pareto front.

  • style_dominated (dict, optional) – The setting for plotting the dominated points.

Note

  • Items in style_* are passed to the scatter method of matplotlib.pyplot.

  • For each item, style_pareto_front and style_dominated are higher priority than style_common.

  • By default, the marker is “o”.

  • By default, the color is “blue” for dominated points and “red” for Pareto front.

physbo.search.utility.plot_pareto_front_all(history, steps_begin=0, steps_end=None, ax=None, xlim=None, ylim=None, grid=True, style_common: dict = {}, style_pareto_front: dict = {}, style_dominated: dict = {})[source]

Plot the Pareto front of the history for all pairs of objectives.

Parameters:
  • history (History) – The history of the search.

  • steps_begin (int, optional) – The index (inclusive) of the step to begin plotting. If None, plot from the beginning.

  • steps_end (int, optional) – The index (exclusive) of the step to end plotting. If None, plot until the end.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If None, a new figure is created.

  • xlim (tuple, optional) – The x-axis limits. If None, the limits are determined automatically.

  • ylim (tuple, optional) – The y-axis limits. If None, the limits are determined automatically.

  • grid (bool, default=True) – Whether to plot the grid.

  • style_common (dict, optional) – The common setting for plotting the points.

  • style_pareto_front (dict, optional) – The setting for plotting the Pareto front.

  • style_dominated (dict, optional) – The setting for plotting the dominated points.

Note

  • Items in style_* are passed to the scatter method of matplotlib.pyplot.

  • For each item, style_pareto_front and style_dominated are higher priority than style_common.

  • By default, the marker is “o”.

  • By default, the color is “blue” for dominated points and “red” for Pareto front.

physbo.search.utility.show_interactive_mode(simulator, history)[source]
physbo.search.utility.show_search_results(history, N)[source]
physbo.search.utility.show_search_results_mo(history, N, disp_pareto_set=False)[source]