adaptive.run_adaptive_search
run_adaptive_search(
command,
input_cols,
outcome_col,
ranges,
existing_data=None,
n_start=20,
n_step=10,
max_iter=5,
max_hours=None,
input_file='sim_input.csv',
output_file='sim_output.csv',
)
Orchestrates the Active Learning loop on raw DataFrames.
Parameters
| command |
str |
Solver command template. |
required |
| input_cols |
List[str] |
Input names. |
required |
| outcome_col |
str |
Outcome name. |
required |
| ranges |
Dict |
Input bounds. |
required |
| existing_data |
pd.DataFrame |
Start data. |
None |
| n_start |
int |
Init batch size. |
20 |
| n_step |
int |
Points added per refinement step. |
10 |
| max_iter |
int |
Max loops. |
5 |
| max_hours |
float |
Physical time limit in hours. |
None |
| input_file |
str |
Temporary file for solver input. |
'sim_input.csv' |
| output_file |
str |
Temporary file for solver output. |
'sim_output.csv' |
Returns
|
pd.DataFrame |
pd.DataFrame: Final dataset containing all successful runs. |
Examples
# 1. Define bounds
ranges = {'Length': (0, 10), 'Angle': (-45, 45)}
# 2. Define a command that reads {input} and writes {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 with a 1.5 hour time limit
final_df = run_adaptive_search(
command=cmd,
input_cols=['Length', 'Angle'],
outcome_col='Signal',
ranges=ranges,
max_iter=10,
max_hours=1.5
)
print(f"Collected {len(final_df)} samples.")