Skip to content

Commit

Permalink
Fixed bugs with uncalculated points
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevIlyaG committed Jan 7, 2025
1 parent 8540f9d commit 50bcc20
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions iOpt/method/index_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ def update_optimum(self, point: SearchDataItem) -> None:
:param point: the point of a new trial.
"""

if self.best is None or self.best.get_index() < point.get_index() or (
self.best.get_index() == point.get_index() and point.get_z() < self.best.get_z()):
self.best = point
self.recalcR = True
self.Z[point.get_index()] = point.get_z()
# self.UpdateZ(point)
self.search_data.solution.best_trials[0] = self.best
if point.get_index() >= 0:
if self.best is None or self.best.get_index() < point.get_index() or (
self.best.get_index() == point.get_index() and point.get_z() < self.best.get_z()):
self.best = point
self.recalcR = True
self.Z[point.get_index()] = point.get_z()
# self.UpdateZ(point)
self.search_data.solution.best_trials[0] = self.best
2 changes: 1 addition & 1 deletion iOpt/method/mixed_integer_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def first_iteration(self) -> list[SearchDataItem]:
else:
for i in range(number_of_points_in_one_interval):
x = id_comb + h * (i + 1)
if not is_init_image_x:
if not is_init_image_x or len(image_x) >= i:
image_x.append(self.evolvent.get_image(x))

y = Point(copy.copy(image_x[i]), self.discreteParameters[id_comb])
Expand Down
2 changes: 1 addition & 1 deletion iOpt/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Solution:
"""
def __init__(self,
problem: Problem,
best_trials: np.ndarray(shape=(1), dtype=Trial) = [Trial([], [])],
best_trials: np.ndarray(shape=(1), dtype=Trial) = np.array([Trial([], [])]),
number_of_global_trials: int = 1,
number_of_local_trials: int = 0,
solving_time: np.double = 0.0,
Expand Down

0 comments on commit 50bcc20

Please sign in to comment.