Azzera filtri
Azzera filtri

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 visualizzazioni (ultimi 30 giorni)
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 Commenti
Torsten
Torsten il 17 Mag 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 ?
othman warde
othman warde il 17 Mag 2023
% 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.........................؟؟؟؟؟؟؟؟؟؟؟

Accedi per commentare.

Risposta accettata

Torsten
Torsten il 17 Mag 2023
Modificato: Torsten il 17 Mag 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:');
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 Commenti
Torsten
Torsten il 17 Mag 2023
Modificato: Torsten il 17 Mag 2023
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.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by