10 "output_type": "stream",
12 "int: N_CLOUD_REGIONS; % number of cloud regions\n",
13 "% set of 1..N_CLOUD_REGIONS: C_REGIONS;\n",
15 "int: N_ATTRIBUTES; % number of capability related attributes\n",
16 "% set of 1..N_ATTRIBUTES: ATTRIBS;\n",
17 "array[1..N_ATTRIBUTES] of float: w_attributes; % weights of each attribute\n",
19 "int: N_UTILIZATION_METRICS; % number of dynamic capacity metrics of interest\n",
20 "% set of 1..N_UTILIZATION_METRICS: U_METRICS;\n",
21 "array[1..N_UTILIZATION_METRICS] of float: w_metrics; % weights of each capacity metric\n",
23 "int: cust_type; % customer type, 0 = regular, 1 = silver, 2 = gold\n",
24 "int: N_VMS; % number of VMs in VNF\n",
25 "int: N_CAPACITY_METRICS; % number of metrics for cloud region capacity check\n",
27 "float: C_ALLOC_THRESHOLD; % allocation threshold for cloud\n",
28 "float: CUST_ALLOC_THRESHOLD; % allocation threshold for customer in cloud\n",
29 "float: AVG_CPU_UTILIZATION_THRESHOLD;\n",
30 "float: PEAK_CPU_UTILIZATION_THRESHOLD;\n",
32 "enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
33 "enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
34 "enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
35 "enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
36 "enum VNFS_TYPES = { VDNS, VFW };\n",
39 "% set of 1..N_CAPACITY_METRICS: CAP_METRICS;\n",
41 "% whether a cloud region has the corresponding capability -- data will be customer specific\n",
42 "% array[1..N_CLOUD_REGIONS, 1..N_CLOUD_REGIONS] of float: c_dist;\n",
43 "array[1..N_CLOUD_REGIONS, 1..N_ATTRIBUTES] of int: capabilities;\n",
44 "array[1..N_CLOUD_REGIONS, 1..N_UTILIZATION_METRICS] of float: cpu_utilization; % how much capacity is already dynamically utilized (fraction)\n",
45 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_alloc_capacity; % how much percent is already allocated in the cloud\n",
46 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_total_capacity; % total cloud capacity\n",
47 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: c_alloc_capacity_norm;\n",
48 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: cust_alloc_capacity; % how much percent is already allocated in the cloud for the customer\n",
49 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: cust_total_capacity; % total cloud capacity for customer\n",
50 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: cust_alloc_capacity_norm;\n",
52 "% VM requirements for each type of capacity (vm cpu, memory, etc.)\n",
53 "% TODO: establish a standard for units (MB RAM, GB disk, N virtual cores, etc.)\n",
54 "array[1..N_VMS, 1..N_CAPACITY_METRICS] of int: vm_reqs;\n",
55 "array[1..N_CAPACITY_METRICS] of int: vm_reqs_sums = [ sum(k in 1..N_VMS) (vm_reqs[k,j]) | j in 1..N_CAPACITY_METRICS ];\n",
56 "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: vm_reqs_sums_norm;\n",
57 "%forall(i in 1..N_CLOUD_REGIONS, j in 1..N_CAPACITY_METRICS) (\n",
58 "% vm_reqs_sums_norm[i, j] = vm_reqs_sums[j]/c_total_capacity[i, j]\n",
60 "%array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: vm_reqs_sums_norm = [ ((vm_reqs_sums[j]/c_total_capacity[i,j]) | j in 1..N_CAPACITY_METRICS) | i in 1..N_CLOUD_REGIONS ];\n",
62 "array[1..N_VNFS] of var int: s_regions; % target cloud regions (solution to the problem)\n",
64 "% custom constraints\n",
65 "constraint forall (s in s_regions) (\n",
66 " cpu_utilization[s, AVG_CPU_UTILIZATION] <= AVG_CPU_UTILIZATION_THRESHOLD /\\ % hard constraint: need some capacity available\n",
67 " cpu_utilization[s, PEAK_CPU_UTILIZATION] <= PEAK_CPU_UTILIZATION_THRESHOLD /\\ % hard constraint: need some capacity available\n",
68 " cust_alloc_capacity[s, CPU_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\\n",
69 " cust_alloc_capacity[s, MEMORY_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD]) /\\\n",
70 " c_alloc_capacity[s, CPU_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\\n",
71 " c_alloc_capacity[s, MEMORY_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD])\n",
74 "% specific constraints based on the VNF\n",
75 "constraint capabilities[s_regions[VDNS], CORE_DC] = 1; % hard constraint for vDNS: has to be placed in CORE DC\n",
77 "% custom soft constraint for gold customers -- give a large weight to direct connection\n",
78 "var float: additional_obj = sum(s in s_regions) (bool2int(cust_type = GOLD) * capabilities[s, MIN_GUARANTEE] * 1000);\n",
80 "% TODO: global constraints (such as data validation)\n",
82 "% Objective for utilization\n",
83 "var float: obj_c_capacity = sum(k in 1..N_CAPACITY_METRICS, s in s_regions) (\n",
84 "\t\t (1 - c_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]) +\n",
85 " (1 - cust_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]));\n",
87 "% Objective for utilization\n",
88 "var float: obj_utilization = sum(k in 1..N_UTILIZATION_METRICS, s in s_regions) ( w_metrics[k] * (1 - cpu_utilization[s, k]) );\n",
90 "% Objective for capabilities\n",
91 "var float: obj_capabilities = sum(k in 1..N_ATTRIBUTES, s in s_regions) ( w_attributes[k] * capabilities[s, k] );\n",
93 "% Overall objective function\n",
94 "var float: obj = obj_c_capacity + obj_utilization + obj_capabilities + additional_obj;\n",
96 "solve maximize obj;\n",
98 "output [ \"Solution: \\nCloud Region for vDNS = \", show(s_regions[VDNS]) ] \n",
99 "++ [ if N_VNFS = 2 then \"\\nCloud Region for vFW = \" ++ show(s_regions[VFW]) ++ \"\\n\" else \"\\n\" endif ]\n",
100 "++ [ \"Objective function value: \", show(obj), \"\\n\", \"Customer type: \", show(cust_type), \"\\n\"];\n"
110 "execution_count": 2,
115 "output_type": "stream",
117 "% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
118 "% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
119 "% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
120 "% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
122 "N_CLOUD_REGIONS = 3; % e-dc-1, core-dc-1, core-dc-2\n",
123 "N_ATTRIBUTES = 4;\n",
124 "N_UTILIZATION_METRICS = 2;\n",
125 "N_CAPACITY_METRICS = 2;\n",
127 "C_ALLOC_THRESHOLD = 0.65;\n",
128 "CUST_ALLOC_THRESHOLD = 0.95;\n",
129 "AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\n",
130 "PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\n",
132 "cust_type = GOLD;\n",
135 "w_metrics = [0.9, 0.1];\n",
136 "w_attributes = [0.1, 0.9, 0.05, 0.05]; \n",
138 "capabilities = [| 0, 1, 1, 1\n",
140 " | 1, 1, 0, 1 |];\n",
142 "cpu_utilization = [| 0.05, 0.9\n",
146 "c_alloc_capacity = [| 600, 1200\n",
148 " | 2400, 4800 |];\n",
150 "c_total_capacity = [| 1000, 2000\n",
152 " | 4000, 8000 |];\n",
154 "c_alloc_capacity_norm = [| 0.6, 0.6\n",
158 "cust_alloc_capacity = [| 60, 120\n",
162 "cust_total_capacity = [| 100, 200\n",
166 "cust_alloc_capacity_norm = [| 0.6, 0.6\n",
170 "vm_reqs = [| 1, 4\n",
174 "%vm_reqs_sums = [ 14, 56 ];\n",
176 "vm_reqs_sums_norm = [| 0.007, 0.014\n",
177 " | 0.0035, 0.007\n",
178 " | 0.00175, 0.0035 |];\n"
188 "execution_count": 3,
193 "output_type": "stream",
203 "!diff gold.dzn gold-no-min-guarantee.dzn"
208 "execution_count": 4,
213 "output_type": "stream",
223 "!diff gold.dzn gold-no-min-guarantee.dzn"
228 "execution_count": 5,
233 "output_type": "stream",
235 "% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
236 "% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
237 "% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
238 "% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
240 "N_CLOUD_REGIONS = 3; % e-dc-1, core-dc-1, core-dc-2\n",
241 "N_ATTRIBUTES = 4;\n",
242 "N_UTILIZATION_METRICS = 2;\n",
243 "N_CAPACITY_METRICS = 2;\n",
245 "C_ALLOC_THRESHOLD = 0.65;\n",
246 "CUST_ALLOC_THRESHOLD = 0.95;\n",
247 "AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\n",
248 "PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\n",
250 "cust_type = SILVER;\n",
253 "w_metrics = [0.9, 0.1];\n",
254 "w_attributes = [0.1, 0.9, 0.05, 0.05]; \n",
256 "capabilities = [| 0, 1, 1, 1\n",
258 " | 1, 1, 0, 1 |];\n",
260 "cpu_utilization = [| 0.05, 0.9\n",
264 "c_alloc_capacity = [| 600, 1200\n",
266 " | 2400, 4800 |];\n",
268 "c_total_capacity = [| 1000, 2000\n",
270 " | 4000, 8000 |];\n",
272 "c_alloc_capacity_norm = [| 0.6, 0.6\n",
276 "cust_alloc_capacity = [| 60, 120\n",
280 "cust_total_capacity = [| 100, 200\n",
284 "cust_alloc_capacity_norm = [| 0.6, 0.6\n",
288 "vm_reqs = [| 1, 4\n",
292 "%vm_reqs_sums = [ 14, 56 ];\n",
294 "vm_reqs_sums_norm = [| 0.007, 0.014\n",
295 " | 0.0035, 0.007\n",
296 " | 0.00175, 0.0035 |];\n"
306 "execution_count": 6,
311 "output_type": "stream",
314 "< cpu_utilization = [| 0.05, 0.9\n",
316 "> cpu_utilization = [| 0.05, 0.96\n"
321 "!diff silver.dzn silver-high-edge-load.dzn"
326 "execution_count": 7,
331 "output_type": "stream",
334 "Cloud Region for vDNS = 2\n",
335 "Objective function value: 1002.639\n",
336 "Customer type: 3\n",
343 "!mzn-gecode -a placement.mzn gold.dzn"
348 "execution_count": 8,
353 "output_type": "stream",
356 "Cloud Region for vDNS = 2\n",
357 "Objective function value: 2.589\n",
358 "Customer type: 3\n",
361 "Cloud Region for vDNS = 3\n",
362 "Objective function value: 3.0195\n",
363 "Customer type: 3\n",
370 "!mzn-gecode -a placement.mzn gold-no-min-guarantee.dzn"
375 "execution_count": 9,
380 "output_type": "stream",
383 "Cloud Region for vDNS = 2\n",
384 "Cloud Region for vFW = 1\n",
385 "Objective function value: 6.062\n",
386 "Customer type: 2\n",
389 "Cloud Region for vDNS = 3\n",
390 "Cloud Region for vFW = 1\n",
391 "Objective function value: 6.4425\n",
392 "Customer type: 2\n",
399 "!mzn-gecode -a placement.mzn silver.dzn"
404 "execution_count": 10,
409 "output_type": "stream",
412 "Cloud Region for vDNS = 2\n",
413 "Cloud Region for vFW = 2\n",
414 "Objective function value: 5.278\n",
415 "Customer type: 2\n",
418 "Cloud Region for vDNS = 3\n",
419 "Cloud Region for vFW = 2\n",
420 "Objective function value: 5.6585\n",
421 "Customer type: 2\n",
424 "Cloud Region for vDNS = 3\n",
425 "Cloud Region for vFW = 3\n",
426 "Objective function value: 6.039\n",
427 "Customer type: 2\n",
434 "!mzn-gecode -a placement.mzn silver-high-edge-load.dzn"
439 "execution_count": null,
447 "display_name": "Python 3",
448 "language": "python",
456 "file_extension": ".py",
457 "mimetype": "text/x-python",
459 "nbconvert_exporter": "python",
460 "pygments_lexer": "ipython3",