# min and max optimization as a single minimization function

2 views (last 30 days)
sastra university on 15 Oct 2021
Commented: Matt J on 15 Oct 2021
Hello all..
I have two questions.
1) I have a minimization and maximization objective function. Am using pso to solve the problem. However, i have a confusion that how to merge the both the function together to solve it.
for example,
f1=maximization
f2=minimization
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?
2) I have 15 variables that are ranges from 1 to 25. I am using PSO to solve the problem. 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?
if length(x)==length(unique(x))
%proceed with the function
else
f1=0;
end
I am using this logic for solving the problem. Will it be correct?
Muthukannan

Matt J on 15 Oct 2021
Edited: Matt J on 15 Oct 2021
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)
ceq=0;
c=1-diff(sort(x));
end
##### 2 CommentsShowHide 1 older comment
Matt J on 15 Oct 2021
You' re quite welcome, but please Accept-click the answer if the question is resolved.

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!