I'm trying to solve the multi-objective optimization problem
%% optimisation multiobjective en utilisant la méthode de pondération%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [f] = objfun2(x,w1,w2)
% X1 : Entrée en électricité
% X2 : Entrée en gaz naturel
% X3 : Entrée en biomasse
% X4 : biogaz à exportation
% X5 : Facteur split 1
% X6 : Facteur split 2
% X7 : Facteur split 3
% X8 : Puissance échangée avec l'élement du stockage d'hydrogène
% X9 : Energie stockée
% D_ch :Demande en chaleur
% D_ele : demande en électricité
% Pour le scenarion 1:
n_ee = 0.90; % Trasformateur
n_EL_H2 = 0.85 ; % Eléctrolyseur
n_EL_TH =0.15 ; % Eléctrolyseur
n_GB_TH = 0.90; % Gas boiler
n_FC_EL = 0.55; % Fuel cell
n_FC_TH = 0.45; % Fuel cell
n_RF_H2 =0.7 ; % Reformer
n_FR_GN = 0.7; % fermenteur
n_H2_CH =0.8 ; % charge H2
n_H2_DE =0.8; % Décharge H2
C1 =0.8; % Cout spécifique Transformateur
C2 =0.20; % Cout spécifique chauddière à gaz
C3 =0.6; % Cout spécifique reformer
C4 =2; % Cout spécifique fermenteur
C5 =2; % Cout spécifique électrolyseur
C6 =2; % Cout spécifique pile à combustible
C7 =2; % Cout spécifique élément du stockage
f1=0;
for j=1:52
f1 = f1 + x(1)*C1+x(2)*x(5)*C2+(x(2)*(1-x(5))+(x(3)*n_FR_GN)*(1-x(6)))*C3+x(3)*C4+(x(1)*n_ee*(1-x(7)))*C5+((x(1)*n_ee*(1-x(7)))+(x(1)*(1-x(5))+x(3)*n_FR_GN*(1-x(6)))*n_FR_GN)*C6+x(8)*C7;
end
e1 =0.8; % facteur d'émission lié à l'usage d'électricité du réseau
e2 =0.20; % facteur d'émission lié à l'usage du gaz naturel dans la chadière
e3 =0.6; % facteur d'émission lié à l'usage du gaz naturel pour le réformage
e4 =2; % facteur d'émission lié à l'usage du la biomasse dans le fermentreur
f2=0;
for j=1:52
f2 = f2 + e1* x(1+9*(j-1))+ e2* x(2+9*(j-1))*x(5) + e3* x(2+9*(j-1))*(1-x(5+9*(j-1)))+e4*x(3+9*(j-1));
end
f = w1*f1+w2*f2;
end
%% Mes contraintes d'égalité et d'inégalité %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Mes contraintes d'égualité:
% Définir mes variables :
% X1 : Entrée en électricité
% X2 : Entrée en gaz naturel
% X3 : Entrée en biomasse
% X4 : biogaz à exportation
% X5 : Facteur split 1
% X6 : Facteur split 2
% X7 : Facteur split 3
% X8 : Puissance échangée avec l'élement du stockage d'hydrogène
% X9 : Energie stockée
% D_ch :Demande en chaleur
% D_ele : demande en électricité
function [c,c_eq] = mycon3(x,vout)
% Pour le scenarion 1:
n_ee = 0.90; % Trasformateur
n_EL_H2 = 0.85 ; % Eléctrolyseur
n_EL_TH =0.15 ; % Eléctrolyseur
n_GB_TH = 0.90; % Gas boiler
n_FC_EL = 0.55; % Fuel cell
n_FC_TH = 0.45; % Fuel cell
n_RF_H2 =0.7 ; % Reformer
n_FR_GN = 0.7; % fermenteur
n_H2_CH =0.8 ; % charge H2
n_H2_DE =0.8; % Décharge H2
% c_eq1 = x(1)*(n_ee*x(7)+n_ee*(1-x(7))*n_EL_H2) + x(2)*(1-x(5))*n_FR_GN*n_FC_EL + x(3)*(n_FR_GN*(1-x(6))*n_FC_EL*n_RF_H2);
% c_eq2 = x(1)*(n_ee*(1-x(7))*n_EL_TH+n_ee*(1-x(7))*n_EL_H2) + x(2)*(x(5)*n_GB_TH+n_RF_H2*(1-x(5)))+ x(3)*((1-x(6)*n_RF_H2*n_FR_GN) +x(8);
% c_eq3 = x(3)* n_FR_GN * x(6);
for j = 1:52
c_eq(j) = vout(j)-x(1+9*(j-1))*(n_ee*x(7+9*(j-1))+n_ee*(1-x(7+9*(j-1)))*n_EL_H2) - x(2+9*(j-1))*(1-x(5+9*(j-1)))*n_FR_GN*n_FC_EL - x(3+9*(j-1))*(n_FR_GN*(1-x(6+9*(j-1)))*n_FC_EL*n_RF_H2);
end
for i = 1:52
if x(8+9*(i-1)) >= 0
eh = n_H2_CH;
else
eh = 1/n_H2_DE;
c_eq(52+i) = vout(52+i)-x(1+9*(i-1))*(n_ee*(1-x(7+9*(i-1)))*n_EL_TH+n_ee*(1-x(7+9*(i-1)))*n_EL_H2) - x(2+9*(i-1))*(x(5+9*(i-1))*n_GB_TH+n_RF_H2*(1-x(5+9*(i-1))))- x(3+9*(i-1))*((1-x(6+9*(i-1))*n_RF_H2*n_FR_GN) +x(8+9*(i-1)))*eh;
end
for j = 1:52
c_eq(104+j) = x(4+9*(j-1))-x(3+9*(j-1))* n_FR_GN * x(6+9*(j-1));
end
% contraintes sur l'évolution de la charge des stockages
if x(8) >= 0
eh = n_H2_CH;
else
eh = 1/n_H2_DE;
end
c_eq(157) = x(9) - x(468) + 0.05 - eh*x(8);
for j=2:52
if x(8+9*(j-1)) >= 0
eh = n_H2_CH;
else
eh = 1/n_H2_DE;
end
c_eq(156+j) = x(9+9*(j-1)) - x(9+9*(j-2)) + 0.05 - eh*x(8+8*(j-2));
end
c = [];
end
%% Optimimisation %%%% Optimimisation %%
clear allclc
%% scénario demande en électricité et en chaleur par les batiments A-D
%demande en Electricité batiments A B C D scenario= [1 208816.92 164334.53 63948.44 14547.17; 2 208816.92 164334.53 63948.44 14547.17; 3 208816.92 164334.53 63948.44 14547.17; 4 208816.92 164334.53 63948.44 14547.17; 5 208816.92 164334.53 63948.44 14547.17; 6 208816.92 164334.53 63948.44 14547.17; 7 208816.92 164334.53 63948.44 14547.17; 8 208816.92 164334.53 63948.44 14547.17; 9 208816.92 164334.53 63948.44 14547.17; 10 208816.92 164334.53 63948.44 14547.17; 11 208816.92 164334.53 63948.44 14547.17; 12 208816.92 164334.53 63948.44 14547.17; 13 208816.92 164334.53 63948.44 14547.17; 14 208816.92 164334.53 63948.44 14547.17; 15 208816.92 164334.53 63948.44 14547.17; 16 208816.92 164334.53 63948.44 14547.17; 17 208816.92 164334.53 63948.44 14547.17; 18 208816.92 164334.53 63948.44 14547.17; 19 208816.92 164334.53 63948.44 14547.17; 20 208816.92 164334.53 63948.44 14547.17; 21 208816.92 164334.53 63948.44 14547.17; 22 208816.92 164334.53 63948.44 14547.17; 23 208816.92 164334.53 63948.44 14547.17; 24 208816.92 164334.53 63948.44 14547.17; 25 208816.92 164334.53 63948.44 14547.17; 26 208816.92 164334.53 63948.44 14547.17; 27 208816.92 164334.53 63948.44 14547.17; 28 208816.92 164334.53 63948.44 14547.17; 29 208816.92 164334.53 63948.44 14547.17; 30 208816.92 164334.53 63948.44 14547.17; 31 208816.92 164334.53 63948.44 14547.17; 32 208816.92 164334.53 63948.44 14547.17; 33 208816.92 164334.53 63948.44 14547.17; 34 208816.92 164334.53 63948.44 14547.17; 35 208816.92 164334.53 63948.44 14547.17; 36 208816.92 164334.53 63948.44 14547.17; 37 208816.92 164334.53 63948.44 14547.17; 38 208816.92 164334.53 63948.44 14547.17; 39 208816.92 164334.53 63948.44 14547.17; 40 208816.92 164334.53 63948.44 14547.17; 41 208816.92 164334.53 63948.44 14547.17; 42 208816.92 164334.53 63948.44 14547.17; 43 208816.92 164334.53 63948.44 14547.17; 44 208816.92 164334.53 63948.44 14547.17; 45 208816.92 164334.53 63948.44 14547.17; 46 208816.92 164334.53 63948.44 14547.17; 47 208816.92 164334.53 63948.44 14547.17; 48 208816.92 164334.53 63948.44 14547.17; 49 208816.92 164334.53 63948.44 14547.17; 50 208816.92 164334.53 63948.44 14547.17; 51 208816.92 164334.53 63948.44 14547.17; 52 208816.92 164334.53 63948.44 14547.17];
%demande en chaleur batiments A B C D scenario2 = [1 1427594.60 1284109.59 523483.67 190031.15 2 982931.18 872385.05 368411.96 134151.09 3 1135105.91 966735.18 413340.25 149325.03 4 1495313.57 1299812.17 503369.62 188862.93 5 1325288.52 1059053.42 417684.96 151609.55 6 995935.34 729842.68 326075.69 110981.31 7 895859.46 748401.59 324866.08 114330.22 8 1064518.63 897955.07 376706.41 134196.02 9 884647.89 701571.18 300466.56 108722.74 10 800896.54 531547.79 265629.86 93068.54 11 690779.38 574932.49 284292.38 95440.39 12 630955.39 491976.27 218766.20 71651.09 13 451613.74 302690.85 182270.61 59536.17 14 282668.92 188690.11 127527.22 39082.41 15 365144.19 231710.71 164852.26 49844.24 16 375957.22 212325.89 141524.11 44132.92 17 300533.75 182593.74 146811.82 44003.12 18 279095.43 189308.38 150077.76 42990.65 19 139571.14 69729.07 83462.93 23753.89 20 199881.76 83818.97 115863.14 31542.06 21 85175.05 52589.89 70917.57 18691.59 22 93955.75 44086.60 45412.13 12980.27 23 131220.95 0 15552.10 3115.26 24 108755.75 0 17107.31 2076.84 25 116913.61 59.38 15552.10 2076.84 26 53402.44 0 12441.68 3115.26 27 47767.21 0 12441.68 2336.45 28 24543.93 0 12441.68 0 29 110250.54 0 12441.68 1038.42 30 151976.55 0 12441.68 3115.26 31 69422.12 0 12441.68 3115.26 32 86918.05 0 12441.68 3115.26 33 34192.03 0 12441.68 4672.90 34 20738.80 0 12441.68 6230.53 35 39519.77 0 12441.68 4153.69 36 68539.80 0 12441.68 3115.26 37 55234.83 0 12441.68 3115.26 38 292989.19 0 30482.12 3115.26 39 187184.72 126185.65 18662.52 23260.64 40 183608.26 143900.02 154789.13 48286.60 41 287919.61 240537.02 122083.98 56464.17 42 677292.12 605297.97 280715.40 112409.14 43 884163.86 742486.71 368584.76 123831.78 44 661414.79 501422.13 273999.72 89304.26 45 775772.10 632838.22 276827.37 110072.69 46 714229.28 673670.97 298859.51 108870.31 47 1109646.28 1082949.28 386823.13 169781.93 48 1387665.61 1405851.38 538102.64 214330.22 49 1178721.87 1101958.19 481832.32 169781.93 50 1500936.04 1296977.48 495889.80 213914.85 51 1437692.34 1143034.01 554765.61 182717.05 52 1504741.00 1394642.85 497874.55 192951.71];
for i = 1:52 vout(i) = scenario(i,2)+scenario(i,3)+scenario(i,4)+scenario(i,5);end
for i = 1:52 vout(52+i) = scenario2(i,2)+scenario2(i,3)+scenario2(i,4)+scenario2(i,5);end
% contraintes d'inégalités linéaires% A*X