Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug when defining "problem.types" #25

Closed
ivan-marroquin opened this issue Nov 20, 2017 · 3 comments
Closed

Potential bug when defining "problem.types" #25

ivan-marroquin opened this issue Nov 20, 2017 · 3 comments

Comments

@ivan-marroquin
Copy link

Hi ther,

I have the following issue. If I use this command (between lines 582 - 583):

problem.types[:]= [Real(logs_min[0], logs_max[0]), Real(logs_min[1], logs_max[1]),

Real(logs_min[2], logs_max[2]), Real(logs_min[3], logs_max[3])]

the script works but the variable values are not in the expected range.

So, I replace the above command by this one (between lines 584 - 587):
problem.types[0]= Real(logs_min[0], logs_max[0])
problem.types[1]= Real(logs_min[1], logs_max[1])
problem.types[2]= Real(logs_min[2], logs_max[2])
problem.types[0]= Real(logs_min[3], logs_max[3])

I get the following error (see below): 'NoneType' object has no attribute 'rand'. According to the documentation, I should be able to do it.

I attached a copy of the script for your reference.

Traceback (most recent call last):
File "New_Platypus_TPE55_Full_Optimization_Class_1.py", line 683, in
rstate= np.random.RandomState(seed),
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 307, in fmin
return_argmin=return_argmin,
File "C:\Anaconda3\lib\site-packages\hyperopt\base.py", line 635, in fmin
return_argmin=return_argmin)
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 320, in fmin
rval.exhaust()
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 199, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.async)
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 173, in run
self.serial_evaluate()
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 92, in serial_eva
luate
result = self.domain.evaluate(spec, ctrl)
File "C:\Anaconda3\lib\site-packages\hyperopt\base.py", line 840, in evaluate
rval = self.fn(pyll_rval)
File "New_Platypus_TPE55_Full_Optimization_Class_1.py", line 612, in optimize_
parameters_inverse_second_layer_round_1
algorithm.run(n_iter)
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\core.py",
line 302, in run
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 64, in step
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 390, in initialize
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 71, in initialize
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 71, in
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\operators
.py", line 38, in generate
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\operators
.py", line 38, in
AttributeError: 'NoneType' object has no attribute 'rand'

Many thanks

Ivan

Script.zip

@ivan-marroquin
Copy link
Author

I tried the following:

problem.types[0]= [Real(logs_min[0], logs_max[0])]
problem.types[1]= [Real(logs_min[1], logs_max[1])]
problem.types[2]= [Real(logs_min[2], logs_max[2])]
problem.types[0]= [Real(logs_min[3], logs_max[3])]

The error still occurs but I got a different message: 'list' object has no attribute 'rand'

Traceback (most recent call last):
File "New_Platypus_TPE55_Full_Optimization_Class_1.py", line 685, in
rstate= np.random.RandomState(seed),
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 307, in fmin
return_argmin=return_argmin,
File "C:\Anaconda3\lib\site-packages\hyperopt\base.py", line 635, in fmin
return_argmin=return_argmin)
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 320, in fmin
rval.exhaust()
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 199, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.async)
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 173, in run
self.serial_evaluate()
File "C:\Anaconda3\lib\site-packages\hyperopt\fmin.py", line 92, in serial_eva
luate
result = self.domain.evaluate(spec, ctrl)
File "C:\Anaconda3\lib\site-packages\hyperopt\base.py", line 840, in evaluate
rval = self.fn(pyll_rval)
File "New_Platypus_TPE55_Full_Optimization_Class_1.py", line 612, in optimize_
parameters_inverse_second_layer_round_1
algorithm.run(n_iter)
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\core.py",
line 302, in run
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 64, in step
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 390, in initialize
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 71, in initialize
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\algorithm
s.py", line 71, in
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\operators
.py", line 38, in generate
File "C:\Anaconda3\lib\site-packages\platypus-0.1-py3.6.egg\platypus\operators
.py", line 38, in
AttributeError: 'list' object has no attribute 'rand'

@dhadka
Copy link
Member

dhadka commented Nov 20, 2017

I think the last line has a copy-paste error. Should be problem.types[3] instead of problem.types[0].

problem.types[0]= Real(logs_min[0], logs_max[0])
problem.types[1]= Real(logs_min[1], logs_max[1])
problem.types[2]= Real(logs_min[2], logs_max[2])
problem.types[3]= Real(logs_min[3], logs_max[3])

@ivan-marroquin
Copy link
Author

You are totally correct! I didn't pay attention to my typo. Thanks!

I would like to ask you this question: is there a difference between the commands (A) and (B)?
Command A:
problem.types[:]= [Real(logs_min[0], logs_max[0]), Real(logs_min[1], logs_max[1]),
Real(logs_min[2], logs_max[2]), Real(logs_min[3], logs_max[3])]

Command B:
problem.types[0]= Real(logs_min[0], logs_max[0])
problem.types[1]= Real(logs_min[1], logs_max[1])
problem.types[2]= Real(logs_min[2], logs_max[2])
problem.types[3]= Real(logs_min[3], logs_max[3])

I am hoping that Command B will constraint better the range of values for the variables.

Once again, thanks a lot

@dhadka dhadka closed this as completed Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants