optimise

optimise(
    command,
    ranges,
    n_start=20,
    n_step=10,
    max_iter=5,
    max_hours=None,
    input_file='sim_input.csv',
    output_file='sim_output.csv',
)

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

Parameters

Name Type Description Default
command str Solver command (e.g. “python solver.py {input} {output}”). required
ranges Dict Input bounds, e.g. {“Length”: (0, 10)}. required
n_start int Initial sample size (only if data is empty). 20
n_step int Batch size for refinement. 10
max_iter int Max refinement loops. 5
max_hours float Physical time limit in hours to safely stop the loop. None
input_file str Temp input filename. 'sim_input.csv'
output_file str Temp output filename. 'sim_output.csv'

Examples

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

study = SimulationStudy(input_cols=["Length", "Angle"], outcome_col="Signal")

# 2. Define a "solver" command.
# We use 'python -c' to simulate an external tool (like Ansys/Abaqus)
# that reads {input}, does math, and saves to {output}.
cmd = (
"python -c "
"'import pandas as pd; "
'df=pd.read_csv("{input}"); '
'df["Signal"] = df["Length"]*2; '
'df.to_csv("{output}", index=False)'
"'"
)

# 3. Run the automated loop
study.optimise(
command=cmd,
ranges=ranges,
max_iter=3
)

# 4. View the results
_ = study.pod()
study.visualise()