Nested fmincon call to solve min max optimization
Show older comments
Hello, I try to implement a complex min max optimization problem but I have some issues with nested fmincon, so I just tried to code it with a really dummy example that can be solved by hand:

Trivially, the result should be
,
and 
,
and f = @(x, y) x + y;
% Minimize over y
min_fun_1 = @(x) fmincon(@(y) f(x, y), 0, [], [], [], [], -10, 10, [], optimoptions('fmincon', 'Display', 'iter'));
% Minimize over x
initial_x = 0;
[x_opt_minmin, fval_minmin] = fmincon(@(x) min_fun_1(x), initial_x, [], [], [], [], -10, 10, [], optimoptions('fmincon', 'Display', 'iter'));
% Display the results
disp('Optimal minmin x:');
disp(x_opt_minmin);
disp('Optimal minmin value of f:');
disp(fval_minmin);
But the code above gave me something else, so what did I do wrong in my code or did not understand ? Thanks in advance
Optimal minmin x:
0
Optimal minmin value of f:
-10.0000
For info the fminimax function doesn't seem to fit my problem, as I don't want to discretize objective functions.
Accepted Answer
More Answers (1)
To solve
without nested optimization, reformulate as,
without nested optimization, reformulate as,
xlb=-10; xub=+10; %bounds on x
ylb=-10; yub=+10; %bounds on y
lb=[xlb,-inf];
ub=[xub,+inf];
[xt,fval]=fseminf(@(xt) xt(2),[0,1000],1,... %xt=[x,t]
@(xt,s)myinfcon(xt,s,ylb,yub),[],[],[],[],lb,ub);
x=xt(1);
y=fmincon(@(y)-f(x,y) , 0,[],[],[],[], -ylb,+yub );
x,y %min/max solution
function fval=f(x,y)
fval = x+y;
end
function [c,ceq,K,s]=myinfcon(xt,s,ylb,yub)
x=xt(1);
t=xt(2);
% Sample set
if isnan(s)
% Initial sampling interval
s = [0.01 0];
end
y = -ylb:s(1):yub;
c = [];
ceq = [];
K = f(x,y)-t; %seminf constraint
end
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!