@@ -157,6 +157,28 @@ def suggest(self, num_points: Optional[int]) -> List[dict]:
157
157
points .append (point )
158
158
return points
159
159
160
+ def _ignore_out_of_bounds (self , trial : Trial ) -> None :
161
+ """Check if trial parameters are within their bounds."""
162
+ for var , value in zip (
163
+ trial .varying_parameters , trial .parameter_values
164
+ ):
165
+ if value < var .lower_bound or value > var .upper_bound :
166
+ if not self ._fit_out_of_design :
167
+ ignore_reason = (
168
+ f"Parameter { var .name } value { value } is outside "
169
+ f"allowed range [{ var .lower_bound } , { var .upper_bound } ]. "
170
+ "Set `fit_out_of_design=True` if you want "
171
+ "the model to use these data."
172
+ )
173
+ trial .ignore (reason = ignore_reason )
174
+
175
+ def ignore_trials (self , trials : List [Trial ]) -> None :
176
+ """Ignore trials as determined by the generator."""
177
+ for trial in trials :
178
+ if not hasattr (trial , "ax_trial_id" ):
179
+ # Handle unknown trial
180
+ self ._ignore_out_of_bounds (trial )
181
+
160
182
def ingest (self , results : List [dict ]) -> None :
161
183
"""Send the results of evaluations to the generator."""
162
184
for result in results :
@@ -168,7 +190,7 @@ def ingest(self, results: List[dict]) -> None:
168
190
custom_parameters = self ._custom_trial_parameters ,
169
191
)
170
192
try :
171
- trial_id = trial ._ax_trial_id
193
+ trial_id = trial .ax_trial_id
172
194
ax_trial = self ._ax_client .get_trial (trial_id )
173
195
except AttributeError :
174
196
params = {}
@@ -188,15 +210,6 @@ def ingest(self, results: List[dict]) -> None:
188
210
ax_trial .add_arm (Arm (parameters = params ))
189
211
ax_trial .mark_running (no_runner_required = True )
190
212
trial_id = ax_trial .index
191
- else :
192
- ignore_reason = (
193
- f"The parameters { params } are outside of the "
194
- "range of the varying parameters. "
195
- "Set `fit_out_of_design=True` if you want "
196
- "the model to use these data."
197
- )
198
- trial .ignore (reason = ignore_reason )
199
- continue
200
213
else :
201
214
raise error
202
215
ax_trial = self ._ax_client .get_trial (trial_id )
0 commit comments