if i am adding these function together like as follows min(f)=(1/f1)+f2 will it be correct? can i get the proper result?
The solver can return only a single solution x. If you know that f1(x) is maximimized at the same solution x=xmin where f2(x) is minimized, then yes it will work. Otherwise, no, it will not work. Also, if you were fortunate enough for that to be true, you would not need to co-optimize the functions. You could simply minimize f2 and, if you needed the maximum value of f1, simply evaluate f1(xmin).
What you could do is have two sets of variables x
and y
and minimize 1/f1(x) +f2(y)
as a function of [x,y]
, but I doubt it will be better than just optimizing each function separately.
I need a 15 unique numbers for a set to solve my problem. how can i ensure the unique values of the variables for each iterations?
Such a constraint only makes sense if your variables are also integer constrained, and pso() does not allow you to impose integer constraints. If you use ga(), you could apply integer constraints and then possibly also the nonlinear constraint,
function [c,ceq]=nonlcon(x)