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
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Torsten
2023년 5월 17일
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 ?
채택된 답변
Torsten
2023년 5월 17일
편집: Torsten
2023년 5월 17일
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)]);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!