######################################################################## # # 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 math import midaco def problem_function(x): f = [0.0]*1 g = [0.0]*13 # variables: x1..x7 = x[0..6] continuous, b8..b11 = x[7..10] binary x1, x2, x3, x4, x5, x6, x7 = x[0], x[1], x[2], x[3], x[4], x[5], x[6] b8, b9, b10, b11 = x[7], x[8], x[9], x[10] # Objective f[0] = ((x4 - 1.0)**2 + (x5 - 2.0)**2 + (x6 - 1.0)**2 - math.log(1.0 + x7) + (x1 - 1.0)**2 + (x2 - 2.0)**2 + (x3 - 3.0)**2) # Equality constraints G(X) = 0: link the continuous parts to the binaries g[0] = x4 - b8 g[1] = x5 - b9 g[2] = x6 - b10 g[3] = x7 - b11 # Inequality constraints G(X) >= 0 g[4] = -(x1 + x2 + x3 + b8 + b9 + b10 - 5.0) g[5] = -(x6**2 + x1**2 + x2**2 + x3**2 - 5.5) g[6] = -(x1 + b8 - 1.2) g[7] = -(x2 + b9 - 1.8) g[8] = -(x3 + b10 - 2.5) g[9] = -(x1 + b11 - 1.2) g[10] = -(x5**2 + x2**2 - 1.64) g[11] = -(x6**2 + x3**2 - 4.25) g[12] = -(x5**2 + x3**2 - 4.64) return f, g ######################################################################## key = b'************************************************************' problem = {} option = {} problem['@'] = problem_function problem['o'] = 1 # Number of objectives problem['n'] = 11 # Number of variables (in total) problem['ni'] = 4 # Number of integer variables (0 <= ni <= n) problem['m'] = 13 # Number of constraints (in total) problem['me'] = 4 # Number of equality constraints (0 <= me <= m) problem['xl'] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] problem['xu'] = [1000.0, 1000.0, 1000.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] problem['x'] = list(problem['xl']) # Starting point: lower bounds option['maxeval'] = 2000 option['maxtime'] = 60*60*24 option['printeval'] = 1 option['save2file'] = 1 option['resumable'] = 0 option['param1'] = 0.0001 # ACCURACY option['param2'] = 1.0 # SEED option['param3'] = 4.5795824 + 4.5795824*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'] = 1.0 # SURROGATE option['param15'] = 0.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)