Skip to content

Commit 9bf050c

Browse files
committed
Fix handling of instance maximum for constrained optimization
1 parent a9c45d7 commit 9bf050c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

climada/util/calibrate/bayesian_optimizer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,16 @@ def _append_improvement(self, target):
329329

330330
def _is_new_max(self, instance):
331331
"""Determine if a guessed value is the new maximum"""
332-
if instance.max is None:
332+
instance_max = instance.max
333+
if not instance_max or instance_max.get("target") is None:
333334
# During constrained optimization, there might not be a maximum
334335
# value since the optimizer might've not encountered any points
335336
# that fulfill the constraints.
336337
return False
337338

338-
if instance.max["target"] > self._previous_max:
339+
if instance_max["target"] > self._previous_max:
339340
return True
341+
340342
return False
341343

342344
def _maybe_stop_early(self, instance):

0 commit comments

Comments
 (0)