Closed LaksE91 closed 3 years ago
This is just an educated guess, but I believe modelrun(...) is returning the type numpy.ndarray
. I would recommend using https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tolist.html to convert the return value from numpy.ndarray
to a python list, e.g.:
def main(x):
return modelrun(x[0], x[1], x[2]).tolist()
Thank you for your reply. It works.
Hi, I defined my objective function in another file and called my objective function in main()
I'm getting an error,
File "C:\Anaconda2\lib\site-packages\platypus_opt-1.0.2-py2.7.egg\platypus\core.py", line 1010, in unique if not id in unique_ids:
TypeError: unhashable type: 'numpy.ndarray'
Please find the code, I don't know where I made mistake
def main(x): return modelrun(x[0],x[1],x[2])
problem = Problem(3, 2)
x1 = Real(0.014,0.16) x2 = Real(0.06,0.30) x3 = Real(50,100) problem.types[:] = [x1,x2,x3] problem.function = main algorithm = NSGAII(problem) algorithm.run(10000)