Skip to content

Commit

Permalink
silence scipy 'out of bounds' warning
Browse files Browse the repository at this point in the history
  • Loading branch information
knipknap committed Aug 26, 2023
1 parent 81dc5ae commit 15e058a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions btl/feeds/calc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
import warnings
from scipy.optimize import minimize
import numpy as np
import random
Expand Down Expand Up @@ -292,14 +293,16 @@ def optimize(self):
(self.woc.min, self.woc.limit),
(self.doc.min, self.doc.limit)]
np.set_printoptions(formatter={'float': lambda x: "{0:0.10f}".format(x)})
result = minimize(self._evaluate_point,
point,
bounds=bounds,
method='SLSQP', # evaluated fastest
#method='Powell',
#method='Nelder-Mead',
#method='TNC',
tol=0.001)
with warnings.catch_warnings(): # ignore "out-of bounds" warning
warnings.simplefilter("ignore", category=RuntimeWarning)
result = minimize(self._evaluate_point,
point,
bounds=bounds,
method='SLSQP', # evaluated fastest
#method='Powell',
#method='Nelder-Mead',
#method='TNC',
tol=0.001)

# Load & recalculate the best result.
self.speed.v, self.chipload.v, self.woc.v, self.doc.v = result.x
Expand Down

0 comments on commit 15e058a

Please sign in to comment.