######################################################################## # # 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. # ######################################################################## import numpy as np import midaco def network_data(): # 30-bus network of the CEC 2020 power system problems (data set # FunctionPS11). 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, -5, 15], [1, 3, -1.2953368, 4.9222798], [2, 4, -1.8461538, 5.2307692], [2, 5, -1.1764706, 4.7058824], [2, 6, -1.6666667, 5], [3, 4, -5.8823529, 23.529412], [4, 6, -5.8823529, 23.529412], [4, 12, 0, 3.8461538], [5, 7, -2.9585799, 7.1005917], [6, 7, -4.109589, 10.958904], [6, 8, -5.8823529, 23.529412], [6, 9, 0, 4.7619048], [6, 10, 0, 1.7857143], [6, 28, -5, 15], [8, 28, -1.3761468, 4.587156], [9, 10, 0, 9.0909091], [9, 11, 0, 4.7619048], [10, 17, -4.109589, 10.958904], [10, 20, -1.7241379, 4.0229885], [10, 21, -5.1724138, 12.068966], [10, 22, -2.5547445, 5.4744526], [12, 13, 0, 7.1428571], [12, 14, -1.4634146, 3.1707317], [12, 15, -3.2110092, 5.9633028], [12, 16, -1.8711019, 4.1580042], [14, 15, -2.4886878, 2.2624434], [15, 18, -1.8181818, 3.6363636], [15, 23, -2, 4], [16, 17, -1.8823529, 4.4705882], [18, 19, -2.9268293, 6.3414634], [19, 20, -5.1724138, 12.068966], [21, 22, -20, 40], [22, 24, -2.5641026, 3.8461538], [23, 24, -1.4476615, 3.0066815], [24, 25, -1.3103448, 2.2758621], [25, 26, -1.2083132, 1.8366361], [25, 27, -1.9572954, 3.7366548], [27, 28, 0, 2.5], [27, 29, -0.97864769, 1.8683274], [27, 30, -0.69204152, 1.2975779], [29, 30, -0.92272203, 1.7301038]] # ... and the diagonal [G(i,i), B(i,i)] of the buses DI = [[6.2953368, -19.89728], [9.6892911, -29.891652], [7.1776897, -28.441692], [13.61086, -56.125747], [4.1350505, -11.789574], [22.540962, -84.545347], [7.0681689, -18.049496], [7.2584997, -28.106568], [0, -18.614719], [13.560885, -43.401934], [0, -4.7619048], [6.5455257, -24.28105], [0, -7.1428571], [3.9521024, -5.4331751], [9.5178788, -15.86211], [3.7534548, -8.6285924], [5.991942, -15.429492], [4.7450111, -9.9778271], [8.0992431, -18.410429], [6.8965517, -16.091954], [25.172414, -52.068966], [25.118847, -49.320606], [3.4476615, -7.0066815], [5.3221089, -9.1282974], [4.4759534, -7.8491529], [1.2083132, -1.8366361], [3.6279846, -9.4025601], [6.3761468, -22.072156], [1.9013697, -3.5984312], [1.6147636, -3.0276817]] # loads of the buses: active and reactive power PL = np.array([0, 0.217, 0.024, 0.076, 0, 0, 0.228, 0.3, 0, 0.058, 0, 0.112, 0, 0.062, 0.082, 0.035, 0.09, 0.032, 0.095, 0.022, 0.175, 0, 0.032, 0.087, 0, 0.035, 0, 0, 0.024, 0.106]) QL = np.array([0, 0.127, 0.012, 0.016, 0, 0, 0.109, 0.3, 0, 0.02, 0, 0.075, 0, 0.016, 0.025, 0.018, 0.058, 0.009, 0.034, 0.007, 0.112, 0, 0.016, 0.067, 0, 0.023, 0, 0, 0.009, 0.019]) Y = np.zeros((30,30), dtype=complex) for i, j, g, b in BR: Y[i-1,j-1] = Y[j-1,i-1] = complex(g, b) for i, (g, b) in enumerate(DI): Y[i,i] = complex(g, b) return Y, PL, QL Y, PL, QL = network_data() ######################################################################## def problem_function(x): x = np.array(x[:126], dtype=float) V = np.concatenate(([1.0], x[0:29] + 1j*x[29:58])) # bus voltages, slack bus 1 at 1.0 Psp = np.concatenate(([0.0], x[58:87])) # active power injections Qsp = np.concatenate(([0.0], x[87:116])) # reactive power injections GEN = [1, 12, 21, 22, 26] # generator buses (besides slack) Pg = np.zeros(30); Pg[GEN] = x[116:121] # active power of the generators Qg = np.zeros(30); Qg[GEN] = x[121:126] # reactive power of the generators I = Y @ V # bus currents spI = np.conj((Psp + 1j*Qsp)/V) # currents of the injections dP = Psp - Pg + PL # active power balance dQ = Qsp - Qg + QL # reactive power balance dI = (I - spI)[1:] # Equality constraints G(X) = 0: the 4 x 29 power flow equations g = np.concatenate((dI.real, dI.imag, dP[1:], dQ[1:])) # Objective: fuel cost of the 6 generators (slack bus included) plus # the weighted active power loss Pg[0] = (V[0]*np.conj(I[0])).real P6 = Pg[[0] + GEN] b = np.array([2.0, 1.75, 1.0, 3.25, 3.0, 3.0]) c = np.array([0.02, 0.0175, 0.0625, 0.00834, 0.025, 0.0025]) f = np.sum(b*P6 + c*P6**2) + 0.75*np.sum(Pg - PL) return [float(f)], g.tolist() ######################################################################## key = b'************************************************************' problem = {} option = {} problem['@'] = problem_function problem['o'] = 1 # Number of objectives problem['n'] = 126 # Number of variables (in total) problem['ni'] = 0 # Number of integer variables (0 <= ni <= n) problem['m'] = 116 # Number of constraints (in total) problem['me'] = 116 # Number of equality constraints (0 <= me <= m) problem['xl'] = [-1.0]*116 + [0.0]*10 problem['xu'] = [ 1.0]*126 problem['x'] = list(problem['xl']) # Starting point: lower bounds option['maxeval'] = 1000000 option['maxtime'] = 60*60*24 option['printeval'] = 5000 option['save2file'] = 1 option['resumable'] = 0 option['param1'] = 0.0001 # ACCURACY option['param2'] = 0.0 # SEED option['param3'] = 2.7515909 + 2.7515909*1e-4 # FSTOP option['param4'] = 0.0 # ALGOSTOP option['param5'] = 0.0 # EVALSTOP option['param6'] = 0.0 # FOCUS option['param7'] = 0.0 # ANTS option['param8'] = 0.0 # KERNEL option['param9'] = 0.0 # ORACLE option['param10'] = 0.0 # PARETOMAX option['param11'] = 0.0 # EPSILON option['param12'] = 0.0 # BALANCE option['param13'] = 0.0 # CHARACTER option['param14'] = 0.0 # SURROGATE option['param15'] = 2.0 # PMISQP option['parallel'] = 0 # Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8... option['paradigm'] = 0 # Parallel mode: 0 = multiprocessing, 1 = mpi4py, 2 = vectorized ######################################################################## if __name__ == '__main__': solution = midaco.run(problem, option, key)