optimise

optimise(
    executor,
    ranges,
    outcome_col=None,
    n_start=20,
    n_step=10,
    max_iter=5,
    max_hours=None,
    max_gap_ratio=MAX_GAP_RATIO,
    min_r2_score=MIN_R2_SCORE,
    max_avg_cv=MAX_AVG_CV,
    max_max_cv=MAX_MAX_CV,
    output_csv=None,
    max_allowed_vif=MAX_ALLOWED_VIF,
    seed=None,
)

Runs the automated Active Learning loop (Initialize -> Execute -> Diagnose -> Refine).

Parameters

Name Type Description Default
executor Executor | str The solver adapter to use (e.g., PythonExecutor, MatlabExecutor). Accepts a legacy command string for backward compatibility. required
ranges Dict Input bounds, e.g. {“Length”: (0, 10)}. The keys must match the study’s input columns. required
outcome_col str Name of the outcome column. Required when the study has no data yet (cold start), in which case the inputs are taken from the keys of ranges; ignored otherwise. Defaults to None. None
n_start int Initial sample size (only if data is empty). Defaults to 20. 20
n_step int Batch size for refinement. Defaults to 10. 10
max_iter int Max refinement loops. Defaults to 5. 5
max_hours float Wall-clock time limit in hours after which the loop stops. Defaults to None (no limit). None
max_gap_ratio float Largest allowed coverage gap, as a fraction of each input’s range. MAX_GAP_RATIO
min_r2_score float Minimum cross-validated R² for the model-fit check. MIN_R2_SCORE
max_avg_cv float Maximum average bootstrap spread (relative to the response std). MAX_AVG_CV
max_max_cv float Maximum bootstrap spread at any probe point. MAX_MAX_CV
output_csv str Path to write the output CSV results incrementally. None
max_allowed_vif float Collinearity (VIF) threshold. Collinearity cannot be fixed by sampling, so a failure stops the loop with a warning. MAX_ALLOWED_VIF
seed int Seed for reproducible designs and refinements. None

Returns

Name Type Description
None None data (and the cleaned data) are replaced with all inputs and
None outcomes collected by the loop, existing rows included.

Raises

Name Type Description
ValueError If outcome_col is missing on a cold start, or the keys of ranges do not match the study’s inputs.

Examples

from digiqual.core import SimulationStudy
from digiqual.executors import PythonExecutor

# 1. Define the variable ranges
ranges = {"Length": (0, 10), "Angle": (-45, 45)}
study = SimulationStudy()

# 2. Define a simple Python solver
def my_solver(row):
    return row['Length'] * 2 + row['Angle']

my_exec = PythonExecutor(solver_func=my_solver, outcome_col="Signal")

# 3. Run the automated loop
study.optimise(
    executor=my_exec,
    ranges=ranges,
    outcome_col="Signal",
    max_iter=3
)

# 4. View the results
_ = study.pod(poi_col="Length", threshold=4.0)
study.visualise()