simopt.experiment_base
Base classes for problem-solver pairs and I/O/plotting helper functions.
Module Contents
- simopt.experiment_base.model_directory
- simopt.experiment_base.problem_directory
- simopt.experiment_base.solver_directory
- simopt.experiment_base.read_experiment_results(file_name_path: pathlib.Path | str) simopt.experiment.ProblemSolver
Reads a ProblemSolver object from a .pickle file.
- Parameters:
file_name_path (Path | str) – Path to the .pickle file.
- Returns:
- Loaded problem-solver pair that was previously run or
post-processed.
- Return type:
- Raises:
ValueError – If the file does not exist.
- simopt.experiment_base.read_group_experiment_results(file_path: pathlib.Path | str) simopt.experiment.ProblemsSolvers
Reads a ProblemsSolvers object from a .pickle file.
- Parameters:
file_path (Path) – Path to the .pickle file.
- Returns:
- A group of problem-solver experiments that were run
or post-processed.
- Return type:
- Raises:
FileNotFoundError – If the file does not exist.
- simopt.experiment_base.find_unique_solvers_problems(experiments: list[simopt.experiment.ProblemSolver]) tuple[list[simopt.base.Solver], list[simopt.base.Problem]]
Finds unique solvers and problems from a list of ProblemSolver experiments.
- Parameters:
experiments (list[ProblemSolver]) – List of problem-solver pairs.
- Returns:
- A tuple containing:
A list of unique solvers.
A list of unique problems.
- Return type:
- simopt.experiment_base.find_missing_experiments(experiments: list[simopt.experiment.ProblemSolver]) tuple[list[simopt.base.Solver], list[simopt.base.Problem], list[tuple[simopt.base.Solver, simopt.base.Problem]]]
Finds missing problem-solver pairs from a list of experiments.
- Parameters:
experiments (list[ProblemSolver]) – List of problem-solver pairs.
- Returns:
- A tuple containing:
list[Solver]: Unique solvers present in the experiments.
list[Problem]: Unique problems present in the experiments.
list[tuple[Solver, Problem]]: Problem-solver pairs that are missing.
- Return type:
tuple
- simopt.experiment_base.make_full_metaexperiment(existing_experiments: list[simopt.experiment.ProblemSolver], unique_solvers: list[simopt.base.Solver], unique_problems: list[simopt.base.Problem], missing_experiments: list[tuple[simopt.base.Solver, simopt.base.Problem]]) simopt.experiment.ProblemsSolvers
Creates experiments for missing problem-solver pairs.
- Parameters:
existing_experiments (list[ProblemSolver]) – Existing problem-solver experiments.
unique_solvers (list[Solver]) – Solvers present in the existing experiments.
unique_problems (list[Problem]) – Problems present in the existing experiments.
missing_experiments (list[tuple[Solver, Problem]]) – Problem-solver pairs that have not yet been run.
- Returns:
A new ProblemsSolvers object containing the completed set.
- Return type:
- simopt.experiment_base.create_design_list_from_table(design_table: pandas.DataFrame) list[dict[str, Any]]
Create a list of solver or problem objects for each design point.
- Parameters:
design_table (DataFrame) – DataFrame containing the design table. Each row represents a design point, and each column represents a factor.
- Returns:
List of dictionaries, where each list entry corresponds to a design point, and each dictionary contains the name and values for each factor in that design point.
- Return type:
list[dict[str, Any]]
- simopt.experiment_base.create_design(name: str, factor_headers: list[str], factor_settings: list[tuple[float, float, int]] | pathlib.Path, fixed_factors: dict | None = None, cross_design_factors: dict | None = None, design_type: Literal['nolhs'] = 'nolhs', n_stacks: int = 1) list[dict[str, Any]]
Creates a design of solver, problem, or model factors.
Please ensure the indexing of the factor_headers argument matches the indexing of the factor_settings argument.
- Parameters:
name (str) – Name of the solver, problem, or model.
factor_headers (list[str]) – Names of factors that vary in the design.
factor_settings (list[tuple[float, float, int]] | Path) – A list of tuples, each of the form (min, max, # decimals) or a Path to a .txt file containing those factor settings.
fixed_factors (dict, optional) – Dictionary of fixed factor values that override defaults.
cross_design_factors (dict, optional) – Dictionary of lists of cross-design factor values. Defaults to None.
design_type (Literal["nolhs"], optional) – Type of design. Defaults to “nolhs”.
n_stacks (int, optional) – Number of stacks. Defaults to 1.
- Returns:
- A list of dictionaries, where each dictionary represents
a design.
- Return type:
list[dict[str, Any]]
- Raises:
ValueError – If input validation fails.
Exception – If the design type is unsupported.