min F(S_1,S_2,):1.25 S_1^2+0.4S_2^2 Min ʄ (S_1,S_2,S_3 ): S_1^2+0.35S_2^2 2S_1^2+0.6S_2^2≤5100000 5S_1^2+3S_2^2 ≤14250000
1 view (last 30 days)
Show older comments
Can you help me solve a bi-level programming problem that contains two levels and two constraints? How do I get the solution? I need the code, the solution, and the algorithm. Can you help me?
minF(s1,s2)=1.25S1^2 +0.4S2^2
minf(s1,s2)=s1^2+035s2^2
s.to 2s1^2+0.6s2^2 <=5100000
5s1^2+3s_2^2<=14250000
s1,s2>=0
9 Comments
Torsten
on 17 May 2023
So you have two minimizations that can be solved independently from each other ? Or what do you want to tell us with your description of the problem ?
Accepted Answer
Torsten
on 17 May 2023
Edited: Torsten
on 17 May 2023
My guess is you want to maximize, not minimize the objective function. The result of mimimizing it is obviously s_1 = s_2 = 0 in both cases.
% Define the upper level objective function
upperLevelObj = @(s) 1.25*s(1)^2 + 0.4*s(2)^2;
% Define the lower level objective function
lowerLevelObj = @(s) s(1)^2 + 0.35*s(2)^2;
% Define the upper level constraint function
upperLevelConstr = @(s) deal([2*s(1)^2 + 0.6*s(2)^2 - 5100000;
5*s(1)^2 + 3*s(2)^2 - 14250000],[]);
% Set up the optimization problem for the upper level
objective = upperLevelObj;
x0 = [0; 0]; % Initial guess for (s_1, s_2)
Aineq = [];
bineq = [];
Aeq = [];
beq = [];
lb = [0;0];
ub = [Inf ;Inf];
nonlcon = upperLevelConstr;
options = optimoptions('fmincon', 'Display', 'off', 'TolX',1e-16,'TolFun',1e-16);
% Solve the upper level problem
[sUpperOptimal, upperOptimalCost] = fmincon(objective,x0,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,options);
% Set up the optimization problem for the lower level
objective = lowerLevelObj;
x0 = sUpperOptimal; % Use upper level optimal solution as initial guess
Aineq = [];
bineq = [];
Aeq = [];
beq = [];
lb = [0;0];
ub = [Inf;Inf];
nonlcon = upperLevelConstr;
options = optimoptions('fmincon', 'Display', 'off', 'TolX',1e-16,'TolFun',1e-16);
% Solve the lower level problem
[sLowerOptimal, lowerOptimalCost] = fmincon(objective,x0,Aineq,bineq,Aeq,beq,lb,ub,nonlcon,options);
% Display the optimal values and costs
disp('Upper Level Optimal Solution:');
disp(['s_1 = ', num2str(sUpperOptimal(1))]);
disp(['s_2 = ', num2str(sUpperOptimal(2))]);
disp(['Upper Level Optimal Cost: ', num2str(upperOptimalCost)]);
disp('Lower Level Optimal Solution:');
disp(['s_1 = ', num2str(sLowerOptimal(1))]);
disp(['s_2 = ', num2str(sLowerOptimal(2))]);
disp(['Lower Level Optimal Cost: ', num2str(lowerOptimalCost)]);
More Answers (0)
See Also
Categories
Find more on Linear Least Squares 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!