필터 지우기
필터 지우기

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
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 ?
othman warde
othman warde 2023년 5월 17일
% 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) [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
upperLevelProblem.objective = upperLevelObj;
upperLevelProblem.x0 = [0, 0]; % Initial guess for (s_1, s_2)
upperLevelProblem.Aineq = [];
upperLevelProblem.bineq = [];
upperLevelProblem.Aeq = [];
upperLevelProblem.beq = [];
upperLevelProblem.lb = [];
upperLevelProblem.ub = [];
upperLevelProblem.nonlcon = [];
upperLevelProblem.options = optimoptions('fmincon', 'Display', 'off');
% Solve the upper level problem
[sUpperOptimal, upperOptimalCost] = fmincon(upperLevelProblem);
% Set up the optimization problem for the lower level
lowerLevelProblem.objective = lowerLevelObj;
lowerLevelProblem.x0 = sUpperOptimal; % Use upper level optimal solution as initial guess
lowerLevelProblem.Aineq = [];
lowerLevelProblem.bineq = [];
lowerLevelProblem.Aeq = [];
lowerLevelProblem.beq = [];
lowerLevelProblem.lb = [];
lowerLevelProblem.ub = [];
lowerLevelProblem.nonlcon = upperLevelConstr;
lowerLevelProblem.options = optimoptions('fmincon', 'Display', 'off');
% Solve the lower level problem
[sLowerOptimal, lowerOptimalCost] = fmincon(lowerLevelProblem);
% 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)]);
Is that correct.........................؟؟؟؟؟؟؟؟؟؟؟

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
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:');
Upper Level Optimal Solution:
disp(['s_1 = ', num2str(sUpperOptimal(1))]);
s_1 = 7.037e-08
disp(['s_2 = ', num2str(sUpperOptimal(2))]);
s_2 = 1.2715e-07
disp(['Upper Level Optimal Cost: ', num2str(upperOptimalCost)]);
Upper Level Optimal Cost: 1.2657e-14
disp('Lower Level Optimal Solution:');
Lower Level Optimal Solution:
disp(['s_1 = ', num2str(sLowerOptimal(1))]);
s_1 = 8.6229e-08
disp(['s_2 = ', num2str(sLowerOptimal(2))]);
s_2 = 1.4824e-07
disp(['Lower Level Optimal Cost: ', num2str(lowerOptimalCost)]);
Lower Level Optimal Cost: 1.5127e-14
  댓글 수: 4
Torsten
Torsten 2023년 5월 17일
편집: Torsten 2023년 5월 17일
I've never heard of this algorithm, but you might be interested to study the Wikipedia article
where also a link to MATLAB/Octave code is given.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by