API Reference¶
- class marsopt.Study(double initial_noise=0.33, str direction='minimize', n_init_points=None, final_noise=None, double epsilon=1.0, elite_window=None, random_state=None, verbose=True)¶
Mixed Adaptive Random Search for Optimization
- __init__()¶
Initialize the Study.
- Parameters:
initial_noise (
float, default= 0.33) – Initial noise level.direction (
str, default ="minimize") – Direction of optimization, either “minimize” or “maximize”.n_init_points (
int, default= None) – Number of initial random points. IfNone, it is set as:max(10, round(sqrt(n_trials)))final_noise (
float, default= None) – Final noise level. IfNone, it is set as:max(1e-7, min(1.0 / n_trials, initial_noise))epsilon (
float, default= 1.0) – Epsilon-greedy exploration constant. At each adaptive trial, with probabilityepsilon / (t + 1)a uniform random sample is drawn instead of the elite-guided step (harmonic decay).elite_window (
int, default= None) – If set, only the most recentelite_windowcompleted trials are considered for elite selection. IfNone, full history is used.random_state (
int, default= None) – Seed for reproducibility. Uses PCG64 BitGenerator internally. IfNone, a random SeedSequence is used.verbose (
bool, default= True) – Whether to print logs during optimization.
- elite_window¶
object
- Type:
- final_noise¶
object
- Type:
- initial_noise¶
‘double’
- Type:
- n_init_points¶
object
- Type:
- class marsopt.Trial(study, trial_id)¶
Represents a single trial in the optimization process.
- Parameters:
study (
Study)trial_id (
int)
- add_attr(self, str name, value)¶
Add a user-defined attribute to the trial.
- Parameters:
name (
str) – The name of the attribute.value (
Any) – The value of the attribute.
- Return type:
None
- suggest_categorical(self, str name, list categories)¶
Suggest a categorical variable value.
- Parameters:
name (
str) – The name of the variable.categories (
List[str]) – A list of valid string categorical values.
- Returns:
The suggested categorical string value.
- Return type:
str
- suggest_float(self, str name, double low, double high, bool log=False)¶
Suggest a floating-point variable value.
- Parameters:
name (
str) – The name of the variable.low (
float) – The lower bound of the variable range.high (
float) – The upper bound of the variable range.log (
bool) – Whether the variable is log-scaled.
- Returns:
The suggested floating-point value.
- Return type:
float
- suggest_int(self, str name, int low, int high, bool log=False)¶
Suggest an integer variable value.
- Parameters:
name (
str) – The name of the variable.low (
int) – The lower bound of the variable range.high (
int) – The upper bound of the variable range.log (
bool) – Whether the variable is log-scaled.
- Returns:
The suggested integer value.
- Return type:
int