MCPcopy Index your code
hub / github.com/bayesian-optimization/BayesianOptimization / _is_new_max

Method _is_new_max

bayes_opt/logger.py:205–224  ·  view source on GitHub ↗

Check if the step to log produced a new maximum. Parameters ---------- current_max : dict[str, Any] | None The current maximum target value and its parameters. Returns ------- boolean

(self, current_max: dict[str, Any] | None)

Source from the content-addressed store, hash-verified

203 return line + "\n" + ("-" * self._header_length)
204
205 def _is_new_max(self, current_max: dict[str, Any] | None) -> bool:
206 """Check if the step to log produced a new maximum.
207
208 Parameters
209 ----------
210 current_max : dict[str, Any] | None
211 The current maximum target value and its parameters.
212
213 Returns
214 -------
215 boolean
216 """
217 if current_max is None:
218 # During constrained optimization, there might not be a maximum
219 # value since the optimizer might've not encountered any points
220 # that fulfill the constraints.
221 return False
222 if self._previous_max is None:
223 self._previous_max = current_max["target"]
224 return current_max["target"] > self._previous_max
225
226 def _update_tracker(self, current_max: dict[str, Any] | None) -> None:
227 """Update the tracker.

Callers 3

test_is_new_maxFunction · 0.95
log_optimization_stepMethod · 0.95

Calls

no outgoing calls

Tested by 2

test_is_new_maxFunction · 0.76