Closed hangcyelk closed 1 year ago
Hi! It seems you passed the wrong number on inequalities when instantiating the problem n_ieq_constr=1
. Just fix it to 2 and your problem should work well :)
@bruscalia thanks for replying!
Did this resolve the issue?
Thanks for pointing that out @Bruno! However I think the 'res' turned out to be nonetype which gave me another error. "'NoneType' object is not subscriptable" when I run this program
Any idea of what's happening?
Thanks, eli
Julian Blank @.***> 于2023年1月12日周四 00:14写道:
@bruscalia https://github.com/bruscalia thanks for replying!
Did this resolve the issue?
— Reply to this email directly, view it on GitHub https://github.com/anyoptimization/pymoo/issues/364#issuecomment-1379824965, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHEQ22SJC6B6KFLSDZXGQ3WR6HM3ANCNFSM6AAAAAATWDX5UU . You are receiving this because you authored the thread.Message ID: @.***>
Hi @hangcyelk! I'll try to run your code locally to investigate the error. For now, I believe you could try to handle your constraints with a Repair operator. Take a look at how @blankjul did it in this portfolio allocation problem https://pymoo.org/case_studies/portfolio_allocation.html
Hi, I'm just touching the pymoo lib and tried to fit my problem: a three variable two objectives optimization. I've attached my code herein, it basically stopped at the "seed=1" and returned the problem error. Appreciate your help!
import numpy as np
from pymoo.algorithms.moo.nsga2 import NSGA2 from pymoo.core.problem import ElementwiseProblem from pymoo.optimize import minimize from pymoo.visualization.scatter import Scatter
''' mathmatic problem min f1(x)=255x1+255x2-170 min f2(x)=255x2-85 min f3(x)=255x2+255x3-170 s.t. x1+x2+x3 - 1<=0 0.9-(x1+X2+x3)<=0 (I tried to make x1+x2+x3 ==1 but it seems like not doable) 0<=x1<=1 0<=x2<=1 0<=x3<=1 x∈R '''
class MyProblem(ElementwiseProblem):
problem = MyProblem()
algorithm = NSGA2(pop_size=100)
res = minimize(problem, algorithm, ("n_gen", 100), verbose=False, seed=1)
plot = Scatter() plot.add(res.F, edgecolor="red", facecolor="none") plot.show()