No attribute RbfoptBlackBox
nachiket opened this issue · 1 comments
Solver quits with following error for the Minimal Working Example code in the README.
$ rbfopt_cl_interface.py mwe.py
41 6 GlobalStep -7.527563 7.54 100.00
42 6 GlobalStep -9.879860 7.57 100.00
43 6 GlobalStep -8.362085 7.61 100.00
44 6 GlobalStep -9.995397 7.65 100.00
45 6 AdjLocalStep -9.976929 10.08 100.00
46 7 Discarded 10.08
47 7 GlobalStep 1.360124 10.21 100.00
48 7 GlobalStep -3.075917 10.25 100.00
49 7 GlobalStep -8.136047 10.29 100.00
Summary: iters 50 evals 50 noisy_evals 0 cycles 7 opt_time 10.29 tot_time 10.29 obj -10.000000 gap 100.00
Traceback (most recent call last):
File "/usr/local/bin/rbfopt_cl_interface.py", line 228, in <module>
rbfopt_cl_interface(vars(args), bb.RbfoptBlackBox())
AttributeError: 'module' object has no attribute 'RbfoptBlackBox'
Here mwe.py is the following:
import rbfopt
import numpy as np
def obj_funct(x):
return x[0]*x[1] - x[2]
bb = rbfopt.RbfoptUserBlackBox(3, np.array([0] * 3), np.array([10] * 3),
np.array(['R', 'I', 'R']), obj_funct)
settings = rbfopt.RbfoptSettings(max_evaluations=50)
alg = rbfopt.RbfoptAlgorithm(settings, bb)
val, x, itercount, evalcount, fast_evalcount = alg.optimize()
I'm running this on Mac OSX and have installed ipopt and bonmin.
I think there was a misunderstanding regarding the minimal working example: it is supposed to be used as a stand-alone file. That is, you should directly call
python mwe.py
The example already contains everything to execute the algorithm.
rbfopt_cl_interface.py should be called if you define your own RbfoptBlackBox object inside a file. If you call rbfopt_cl_interface.py on mwe.py, it fails because it does not find any class derived from RbfoptBlackBox inside it. But it also executes the code in mwe.py at import time, therefore you also see the output that you were supposed to see.