Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
570 stars 153 forks source link

[Question] How to use a list of functions? #98

Closed jongyook2 closed 5 years ago

jongyook2 commented 5 years ago

Hello, powerful Platypus

I'm using NSGA2 to minimize many functions like a1x+b1y+c1z+d1 to anx+bny+cnz+dn. I imported a csv file which contains values of an, bn, cn, and dn, and made a list form of functions. (data_list = [a1x+b1y+c1z+d1, ... , anx+bny+cnz+dn ]) And then I added this list to return like this (return [x+y+z, 0.343x+0.413y+0.983z-1.866], data_list) ,but final results(x,y,z) were strange. Fortunately, when I typed in all functions((return [x+y+z, 0.343x+0.413y+0.983z-1.866], a1x+b1y+c1z+d1,... ...), NSGA2 worked very well. How can I solve this problem? Thanks in advance for any help.

dhadka commented 5 years ago

I suspect you'll need to concatenate the two lists using +.

return [x+y+z, 0.343x+0.413y+0.983z-1.866] + data_list

Using

return [x+y+z, 0.343x+0.413y+0.983z-1.866], data_list

will return two separate lists. When this happens, the first list are the objectives and the second list are the constraints.

jongyook2 commented 5 years ago

@dhadka Thank you! Fortunately, I solved it before you gave the solution. 👍 As a layman, I think it is easier to use the platypus than other similar tools