Project-Platypus / Platypus

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

Problem in handling of Constraints in a list base input problem. #181

Closed danial-amin closed 1 year ago

danial-amin commented 2 years ago

Hey. Thank you for the lovely architecture for MOO. I am working on a MOO with a list based input containing 33 elements. A series of predictors are implemented as objective functions while the constraints are defined for these predictors and list. Now I am getting a numpy error in the core file where it states to use a.any or a.all for cases where more than 1 elements exist in the list. I want to know, is there any way around of this. Here is the code I am operating

from platypus import NSGAII, Problem, Real

def final(vars):
  var=np.array(vars).reshape(1,-1)
  return [dt_c.predict(var), dt_l.predict(var),dt_v.predict(var)], [sum(var)-1]

problem = Problem(33, 3, 1)
problem.types[:] = [Real(0, 1)]*33
problem.constraints[:] = "<=0"
problem.function = final

algorithm = NSGAII(problem)
algorithm.run(50000)

I am attaching the snapshot of the error as well

Screenshot 2022-02-23 at 12 56 18 AM

.

github-actions[bot] commented 1 year ago

This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.