I am trying to plot the pareto front for a simplified version of my multi-objective optimization problem (trying to figure out how everything works). I am completely new to this and cannot figure out what the error I am getting means:
TypeError: '>' not supported between instances of 'generator' and 'int'
I am using an existing code for the plotting, so I'm pretty sure the error is in how I formulated the problem, but I'm not sure what it is. This is my code:
v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
w=[22.0, 31.0, 0.0, 0.0, 11416.0, 0.0, 0.0, 0.0, 0.0, 15376.6, 977.97, 4324.97, 3264.79, 32.4, 43.02, 0.029, 0.2,0.00185, 0.00185, 0.0001, 0.03, 0.017, 0.0,0,0,0,0,0,0]
e=[562.51, 562.51, 0.0, 0.0, 223.16, 0.0, 0.0, 0.0, 0.0, 1401.63, 411.42, 1401.63, 0.0,312.53, 17195.71, 0.623, 15.14,0.01, 4.5, 23.42, 0.66,0,0,0,0,0,0,0,0]
g=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 840.000,469.000,46.000,18.000,4.000,12.000,0,0,0,0]
class WEN(Problem):
def __init__(self):
super().__init__(n_var=v, n_obj=2, n_ieq_constr=2, xl=np.array(0 for i in range(29)), xu=None)
def _evaluate(self, x, out, *args, **kwargs):
f1=[numpy.dot(v,e)]
f2=[numpy.dot(v,w)]
g1=[(numpy.dot(v*w)/100)-585]
g2=[(numpy.dot(v*g)*0.00001)-1610]
out["F"] = [f1, f2]
out["G"] = [g1, g2]
from pymoo.visualization.scatter import Scatter
from pymoo.algorithms.moo.nsga2 import RankAndCrowdingSurvival
from pymoo.core.mixed import MixedVariableGA
from pymoo.optimize import minimize
problem = WEN()
algorithm = MixedVariableGA(pop_size=20, survival=RankAndCrowdingSurvival())
res = minimize(problem,
algorithm,
('n_gen', 50),
seed=1,
verbose=False)
plot = Scatter()
plot.add(problem.pareto_front(), plot_type="line", color="black", alpha=0.7)
plot.add(res.F, facecolor="none", edgecolor="red")
plot.show()
Any help, tips, advice (on any aspect of Python coding and/or optimization in Python) would be greatly appreciated.