Collabo documentation#
Main Module#
- class collabo.main.Collaborator(data_location: str | None, bounds: List[List[float]], fun: Callable | None = None)#
Bases:
objectA class for collaborative optimization experiments.
This class provides functionality for designing experiments, proposing solutions, and managing the optimization process in a collaborative setting.
- Parameters:
data_location (str, optional) – The file path for storing and loading experiment data.
bounds (List[List[float]]) – The bounds of the problem.
fun (Callable, optional) – The objective function to use for optimization.
- static aq(x, args)#
- design_experiments(n_experiments: int, fixed_solutions: List[List[float]] | None = None)#
Design of experiments either using Latin hypercube sampling or by optimally distributing around fixed solutions.
- Parameters:
n_experiments (int) – The total number of experiments to distribute (including fixed solutions).
fixed_solutions (List[List[float]], optional) – A list of fixed solutions. Each solution should have the same dimensions as self.d.
- Returns:
None
- load_data()#
Load experiment data from the specified file location.
- Raises:
FileNotFoundError – If the specified file is not found.
- make_choice(choice)#
Make a choice from the proposed solutions.
- Parameters:
choice (int) – The index of the choice to make, starting from 1.
- Returns:
None
- static parse_data(data)#
Parse the data into solutions and objectives.
- Parameters:
data (dict) – The data to parse.
- Returns:
Tuple[np.array, np.array] of solutions and objectives in row-major order.
- plot_current_choices(path)#
Plot the proposed solutions and previous data, alongside the current Gaussian process. NOTE: Only available for 1D functions, and can only be accessed between propose_solutions() and make_choice().
- Parameters:
path (str) – The path to save the plot.
- Returns:
None
- propose_solutions(n_solutions)#
Proposes alternate solutions via multi-objective approach to high-throughput Bayesian optimization.
- Parameters:
n_solutions (int) – The number of alternate solutions to propose.
- Returns:
List[List[float]] of proposed solutions.
- return_choices()#
Returns the proposed choices.
- Returns:
List[List[float]] of proposed solutions.
- save_data()#
Saves the data to a file.
This method saves the data stored in the data attribute to a file specified by the data_location attribute.
- Returns:
None
Utils Module#
- class collabo.utils.GP(train_x, train_y, likelihood)#
Bases:
ExactGP- forward(x)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- collabo.utils.distribute_solutions(fixed_solutions: ndarray | None, bounds: ndarray, required: int)#
A small optimization problem to optimally space solutions around the expert solutions.
required solutions are distributed around the fixed_solutions in the solution space defined by bounds. If there are no fixed solutions, the solutions are distributed using Latin Hypercube Sampling.
- Parameters:
fixed_solutions (np.ndarray, optional) – Expert-defined solutions to be used as fixed points within the solution space.
bounds (np.ndarray) – The bounds of the solution space.
required (int) – The number of solutions to distribute.
- collabo.utils.train_gp(train_x, train_y, noise=None, gp_iter=1000)#