Using "fminimax" in Matlab to solve the Max-Min programming problem
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
JacobsonRadical
le 24 Avr 2022
Commenté : JacobsonRadical
le 24 Avr 2022
Consider the following function defined in the following picture.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975905/image.png)
Define a finite set of points as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975910/image.png)
I want to solve the following programing problem:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975915/image.png)
My idea is the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975920/image.png)
This programing is the first step of a general programing I am studying at. So it should not give trivial solution like 0 or something like this. However, when I attempted it in Matlab, the solution is not desirable.
The following is my code:
fun = @(x)[-log(max(1,0.1037))+x(1)*log(abs(poly1(0.1037)))+x(2)*log(abs(poly2(0.1037)))...
+x(3)*log(abs(poly3(0.1037)))+...
x(4)*log(abs(poly4(0.1037)));
-log(max(1,0.0259))+x(1)*log(abs(poly1(0.0259)))+x(2)*log(abs(poly2(0.0259)))...
+x(3)*log(abs(poly3(0.0259)))+...
x(4)*log(abs(poly4(0.0259)));
-log(max(1,0.2288))+x(1)*log(abs(poly1(0.2288)))+x(2)*log(abs(poly2(0.2288)))...
+x(3)*log(abs(poly3(0.2288)))+...
x(4)*log(abs(poly4(0.2288)));
-log(max(1,0.0938))+x(1)*log(abs(poly1(0.0938)))+x(2)*log(abs(poly2(0.0938)))...
+x(3)*log(abs(poly3(0.0938)))+...
x(4)*log(abs(poly4(0.0938)));
-log(max(1,0.0917))+x(1)*log(abs(poly1(0.0917)))+x(2)*log(abs(poly2(0.0917)))...
+x(3)*log(abs(poly3(0.0917)))+...
x(4)*log(abs(poly4(0.0917)));
-log(max(1,0.2386))+x(1)*log(abs(poly1(0.2386)))+x(2)*log(abs(poly2(0.2386)))...
+x(3)*log(abs(poly3(0.2386)))+...
x(4)*log(abs(poly4(0.2386)));
-log(max(1,0.2003))+x(1)*log(abs(poly1(0.2003)))+x(2)*log(abs(poly2(0.2003)))...
+x(3)*log(abs(poly3(0.2003)))+...
x(4)*log(abs(poly4(0.2003)));];
A= [];
b= [];
Aeq = [];
beq = [];
x0 = [0,0,0,0];
lb = [0,0,0,0];
up = [1000,1000,1000,1000];
[x,fval] = fminimax(fun,x0,A,b,Aeq,beq,lb,ub)
where in the code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975925/image.png)
The solution that Matlab provides is the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/975930/image.png)
I don't quite understand why this happens. Is there anything wrong in my idea or code? Thank you so much for your help!
0 commentaires
Réponse acceptée
Torsten
le 24 Avr 2022
Modifié(e) : Torsten
le 24 Avr 2022
Yes, [0 0 0 0] is the correct solution to your problem.
For all other c vectors >= 0, min g(x,c) would be negative.
Since your problem is linear in the c's, here is an easier way to solve your problem:
poly1=@(x)x.^2-x-1;
poly2=@(x)x.^4-x.^3-3*x.^2+x+1;
poly3=@(x)x.^8-x.^7-7*x.^6+4*x.^5+13*x.^4-4*x.^3-7*x.^2+x+1;
poly4=@(x)x.^3+x.^2-2*x-1;
X = [0.1037;0.0259;0.2288;0.0938;0.0917;0.2386;0.2003];
A = [log(abs(poly1(X))),log(abs(poly2(X))),log(abs(poly3(X))),log(abs(poly4(X))),ones(numel(X),1)] b = zeros(numel(X),1);
f = [0 0 0 0 -1].';
lb = [0 0 0 0 -Inf].';
ub = [1000 1000 1000 1000 Inf].';
c = linprog(f,A,b,[],[],lb,ub)
3 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!