%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MIDACO solves Multi-Objective Mixed-Integer Non-Linear Problems: % % % Minimize F_1(X),... F_O(X) where X(1,...N-NI) is CONTINUOUS % and X(N-NI+1,...N) is DISCRETE % % subject to G_j(X) = 0 (j=1,...ME) equality constraints % G_j(X) >= 0 (j=ME+1,...M) inequality constraints % % and bounds XL <= X <= XU % % % The problem statement of this example is given below. You can use % this example as template to run your own problem. To do so: Replace % the objective functions 'F' (and in case the constraints 'G') given % here with your own problem and follow the below instruction steps. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function rc36_dg_capacitor key = '************************************************************'; problem.func = @problem_function; problem.o = 1; % Number of objectives problem.n = 158; % Number of variables (in total) problem.ni = 0; % Number of integer variables (0 <= ni <= n) problem.m = 148; % Number of constraints (in total) problem.me = 148; % Number of equality constraints (0 <= me <= m) problem.xl = -ones(1,158); problem.xu = ones(1,158); problem.x = problem.xl; % Starting point: lower bounds option.maxeval = 1000000; option.maxtime = 60*60*24; option.printeval = 100; option.save2file = 1; option.resumable = 0; option.param( 1) = 1e-4; % ACCURACY option.param( 2) = 0; % SEED option.param( 3) = 0.047733529 + 0.047733529*1e-4; % FSTOP option.param( 4) = 0; % ALGOSTOP option.param( 5) = 0; % EVALSTOP option.param( 6) = 0; % FOCUS option.param( 7) = 0; % ANTS option.param( 8) = 0; % KERNEL option.param( 9) = 0; % ORACLE option.param(10) = 0; % PARETOMAX option.param(11) = 0; % EPSILON option.param(12) = 0; % BALANCE option.param(13) = 0; % CHARACTER option.param(14) = 0; % SURROGATE option.param(15) = 2; % PMISQP option.parallel = 0; % Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8... option.paradigm = 0; % Parallel mode: 0 = parfor, 1 = vectorized [F,G] = func(X) [ solution ] = midaco( problem, option, key ); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [ f, g ] = problem_function( x ) persistent Y PL PE QL QE if isempty(Y) [Y, PL, PE, QL, QE] = network_data; end x = x(:); V = [1; complex(x(1:37), x(38:74))]; % bus voltages, slack bus 1 at 1.0 Psp = [0; x(75:111)]; % active power injections Qsp = [0; x(112:148)]; % reactive power injections Pdg = zeros(38,1); Pdg(34:38) = x(149:153); % active power of the 5 DG units Qdg = zeros(38,1); Qdg(34:38) = x(154:158); % reactive power of DG and capacitors I = Y*V; % bus currents spI = conj((Psp + 1i*Qsp)./V); % currents of the injections Va = abs(V); dP = Psp - Pdg + PL.*Va.^PE; % active power balance (voltage dQ = Qsp - Qdg + QL.*Va.^QE; % dependent loads) and reactive k = 2:38; % Equality constraints G(X) = 0: the 4 x 37 power flow equations g = [real(I(k) - spI(k)); imag(I(k) - spI(k)); dP(k); dQ(k)].'; % Objective: active and reactive power drawn from the grid at the slack bus S1 = V(1)*conj(I(1)); f(1) = 0.5*(real(S1) + sum(Psp(k))) + 0.5*(imag(S1) + sum(Qsp(k))); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [ Y, PL, PE, QL, QE ] = network_data % 38-bus distribution network of the CEC 2020 power system problems % (data set FunctionPS2). Admittance matrix Y = G + jB: the branches give % the off-diagonal entries [bus i, bus j, G(i,j), B(i,j)] ... BR = [ ... 1 2 -1382.0502 705.47162; 2 3 -258.61351 131.74969; 2 19 -512.7775 489.17266; 3 4 -348.37709 177.47512; 3 23 -242.63876 165.84778; 4 5 -334.56416 170.45431; 5 6 -112.36548 96.986834; 6 7 -71.643816 237.96864; 6 26 -628.09576 320.01081; 7 8 -203.50791 67.25408; 8 9 -101.93804 74.223486; 8 34 -40.150968 40.150968; 9 10 -102.38333 72.570741; 9 35 -40.150968 40.150968; 10 11 -736.37304 243.65284; 11 12 -386.69529 127.90308; 12 13 -67.569593 53.16273; 12 36 -40.150968 40.150968; 13 14 -108.5113 142.84747; 14 15 -151.63986 134.95124; 15 16 -140.33405 102.49489; 16 17 -44.77562 59.78265; 17 18 -135.86163 106.53125; 18 37 -160.61677 160.61677; 19 20 -58.92213 53.096603; 20 21 -165.83272 193.73164; 21 22 -82.439504 108.99795; 23 24 -110.15965 86.973328; 24 25 -111.16381 86.994299; 25 38 -160.61677 160.61677; 26 27 -448.70321 228.40768; 27 28 -85.322298 75.229578; 28 29 -113.5449 98.918085; 29 30 -251.2383 128.00433; 30 31 -83.383149 82.407344; 31 32 -219.34757 255.65963; 32 33 -137.82376 214.29874 ]; % ... and the diagonal [G(i,i), B(i,i)] of the 38 buses DI = [ ... 1382.0502 -705.47162; 2153.4412 -1326.394; 849.62936 -475.07259; 682.94125 -347.92943; 446.92964 -267.44114; 812.10505 -654.96629; 275.15172 -305.22272; 345.59691 -181.62853; 244.47234 -186.94519; 838.75637 -316.22358; 1123.0683 -371.55592; 494.41585 -221.21677; 176.08089 -196.0102; 260.15116 -277.7987; 291.97391 -237.44613; 185.10967 -162.27754; 180.63725 -166.3139; 296.4784 -267.14802; 571.69963 -542.26926; 224.75485 -246.82824; 248.27223 -302.72959; 82.439504 -108.99795; 352.7984 -252.82111; 221.32346 -173.96763; 271.78058 -247.61107; 1076.799 -548.41849; 534.02551 -303.63726; 198.8672 -174.14766; 364.7832 -226.92241; 334.62145 -210.41167; 302.73072 -338.06698; 357.17133 -469.95838; 137.82376 -214.29874; 40.150968 -40.150968; 40.150968 -40.150968; 40.150968 -40.150968; 160.61677 -160.61677; 160.61677 -160.61677 ]; Y = complex(diag(DI(:,1)), diag(DI(:,2))); for k = 1:size(BR,1) Y(BR(k,1),BR(k,2)) = complex(BR(k,3), BR(k,4)); Y(BR(k,2),BR(k,1)) = complex(BR(k,3), BR(k,4)); end % Voltage dependent loads P = PL*|V|^PE, Q = QL*|V|^QE of the 38 buses LD = [ ... 0 0 0 0; 0.1 0.92 0.06 4.04; 0.09 0.18 0.04 6; 0.12 1.51 0.08 3.4; 0.06 0.92 0.03 4.04; 0.06 0.18 0.02 6; 0.2 1.51 0.1 3.4; 0.2 1.51 0.1 3.4; 0.06 0.18 0.02 6; 0.06 1.51 0.02 3.4; 0.045 1.51 0.03 3.4; 0.06 0.92 0.035 4.04; 0.06 1.51 0.035 3.4; 0.12 0.92 0.08 4.04; 0.06 1.51 0.01 3.4; 0.06 0.18 0.02 6; 0.06 1.51 0.02 3.4; 0.09 0.18 0.04 6; 0.09 0.92 0.04 4.04; 0.09 1.51 0.04 3.4; 0.09 0.18 0.04 6; 0.09 0.92 0.04 4.04; 0.09 1.51 0.05 3.4; 0.42 1.51 0.2 3.4; 0.42 1.51 0.2 3.4; 0.06 1.51 0.025 3.4; 0.06 0.18 0.025 6; 0.06 1.51 0.02 3.4; 0.12 1.51 0.07 3.4; 0.2 1.51 0.6 3.4; 0.15 0.92 0.07 4.04; 0.21 0.92 0.1 4.04; 0.06 1.51 0.04 3.4; 0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0 ]; PL = LD(:,1); PE = LD(:,2); QL = LD(:,3); QE = LD(:,4); end