Skip to content

Commit

Permalink
Working on Bug Fix
Browse files Browse the repository at this point in the history
New bug with RBFopt when using as executable. Working on fixing. (command window is flashing each iteration)
  • Loading branch information
tsikes committed Nov 8, 2021
1 parent 681051d commit 7b12b8e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
42 changes: 27 additions & 15 deletions src/calculate/optimize/optimize_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,24 +384,36 @@ def rbfopt(self, x0, bnds, options): # noisy, cheap function option. supports d
max_time = options['stop_criteria_val']*60

var_type = ['R']*np.size(x0) # specifies that all variables are continious
bb = rbfopt.RbfoptUserBlackBox(np.size(x0), np.array(bnds[0]), np.array(bnds[1]),
np.array(var_type), self.obj_fcn)
settings = rbfopt.RbfoptSettings(max_iterations=max_eval,
max_evaluations=max_eval,
max_cycles=1E30,
max_clock_time=max_time,
minlp_solver_path=path['bonmin'],
nlp_solver_path=path['ipopt'])
algo = rbfopt.RbfoptAlgorithm(settings, bb, init_node_pos=x0)
val, x, itercount, evalcount, fast_evalcount = algo.optimize()

output = {'success': False, 'message': []}
# Intialize and report any problems to log, not to console window
stdout = io.StringIO()
stderr = io.StringIO()
with contextlib.redirect_stderr(stderr):
with contextlib.redirect_stdout(stdout):
bb = rbfopt.RbfoptUserBlackBox(np.size(x0), np.array(bnds[0]), np.array(bnds[1]),
np.array(var_type), self.obj_fcn)
settings = rbfopt.RbfoptSettings(max_iterations=max_eval,
max_evaluations=max_eval,
max_cycles=1E30,
max_clock_time=max_time,
minlp_solver_path=path['bonmin'],
nlp_solver_path=path['ipopt'])
algo = rbfopt.RbfoptAlgorithm(settings, bb, init_node_pos=x0)
val, x, itercount, evalcount, fast_evalcount = algo.optimize()

obj_fcn, x, shock_output = self.Scaled_Fit_Fun(x, optimizing=False)
obj_fcn, x, shock_output = self.Scaled_Fit_Fun(x, optimizing=False)

output['message'] = 'Optimization terminated successfully.'
output['success'] = True

msg = 'Optimization terminated successfully.'
success = True

ct_out = stdout.getvalue()
ct_err = stderr.getvalue()

print(ct_out)

# opt.last_optimum_value() is the same as optimal obj_fcn
res = {'x': x, 'shock': shock_output, 'fval': obj_fcn, 'nfev': evalcount + fast_evalcount,
'success': success, 'message': msg, 'time': timer() - timer_start}
'success': output['success'], 'message': output['message'], 'time': timer() - timer_start}

return res
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# and licensed under BSD-3-Clause. See License.txt in the top-level
# directory for license and copyright information.

version = '1.2.10'
version = '1.3.0'

import os, sys, platform, multiprocessing, pathlib
# os.environ['QT_API'] = 'pyside2' # forces pyside2
Expand Down

0 comments on commit 7b12b8e

Please sign in to comment.