Minizinc Placement Model Ex. for vDNS+vFW use case 73/33273/1
authorramkri123 <ramkri123@gmail.com>
Tue, 27 Feb 2018 22:52:49 +0000 (14:52 -0800)
committerramkri123 <ramkri123@gmail.com>
Tue, 27 Feb 2018 23:15:21 +0000 (15:15 -0800)
Issue-ID: OPTFRA-153
Change-Id: I228e638e4c5bfb2cabd970c571077f3ebaf01ece
Signed-off-by: ramkri123 <ramkri123@gmail.com>
examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold-no-min-guarantee.dzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold.dzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/normal-silver-less-pref.dzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement-minizinc.ipynb [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement.mzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver-high-edge-load.dzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver.dzn [new file with mode: 0755]
examples/placement-models-minizinc/vdns-use-case/vDNS-service-gold-customer-model-driven-placement.dzn [moved from minizinc-examples/vDNS-service-gold-customer-model-driven-placement.dzn with 100% similarity]
examples/placement-models-minizinc/vdns-use-case/vDNS-service-model-driven-placement.mzn [moved from minizinc-examples/vDNS-service-model-driven-placement.mzn with 100% similarity]
examples/placement-models-minizinc/vdns-use-case/vDNS-service-no-edge-dc-model-driven-placement.dzn [moved from minizinc-examples/vDNS-service-no-edge-dc-model-driven-placement.dzn with 100% similarity]
examples/placement-models-minizinc/vdns-use-case/vDNS-service-silver-customer-model-driven-placement.dzn [moved from minizinc-examples/vDNS-service-silver-customer-model-driven-placement.dzn with 100% similarity]

diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold-no-min-guarantee.dzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold-no-min-guarantee.dzn
new file mode 100755 (executable)
index 0000000..f1f67e9
--- /dev/null
@@ -0,0 +1,62 @@
+% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\r
+% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\r
+% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\r
+\r
+N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\r
+N_ATTRIBUTES = 4;\r
+N_UTILIZATION_METRICS = 2;\r
+N_CAPACITY_METRICS = 2;\r
+N_VMS = 3;\r
+C_ALLOC_THRESHOLD = 0.65;\r
+CUST_ALLOC_THRESHOLD = 0.95;\r
+AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\r
+PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\r
+\r
+cust_type = GOLD;\r
+N_VNFS = 1;\r
+\r
+w_metrics = [0.9, 0.1];\r
+w_attributes = [0.1, 0.9, 0.05, 0.05]; \r
+\r
+capabilities = [| 0, 1, 1, 1\r
+                | 1, 0, 0, 1\r
+                | 1, 1, 0, 1 |];\r
+\r
+cpu_utilization = [| 0.05, 0.9\r
+                   | 0.1, 0.5\r
+                   | 0.6, 0.8 |];\r
+\r
+c_alloc_capacity = [| 600, 1200\r
+                    | 1200, 2400\r
+                    | 2400, 4800 |];\r
+\r
+c_total_capacity = [| 1000, 2000\r
+                    | 2000, 4000\r
+                    | 4000, 8000 |];\r
+\r
+c_alloc_capacity_norm = [| 0.6, 0.6\r
+                         | 0.6, 0.6\r
+                         | 0.6, 0.6 |];\r
+\r
+cust_alloc_capacity = [| 60, 120\r
+                       | 120, 240\r
+                       | 240, 480 |];\r
+\r
+cust_total_capacity = [| 100, 200\r
+                       | 200, 400\r
+                       | 400, 800 |];\r
+\r
+cust_alloc_capacity_norm = [| 0.6, 0.6\r
+                            | 0.6, 0.6\r
+                            | 0.6, 0.6 |];\r
+\r
+vm_reqs = [| 1, 4\r
+           | 2, 8\r
+           | 4, 16 |];\r
+\r
+%vm_reqs_sums = [ 14, 56 ];\r
+\r
+vm_reqs_sums_norm = [| 0.007, 0.014\r
+                     | 0.0035, 0.007\r
+                     | 0.00175, 0.0035 |];\r
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold.dzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/gold.dzn
new file mode 100755 (executable)
index 0000000..451e795
--- /dev/null
@@ -0,0 +1,62 @@
+% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\r
+% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\r
+% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\r
+\r
+N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\r
+N_ATTRIBUTES = 4;\r
+N_UTILIZATION_METRICS = 2;\r
+N_CAPACITY_METRICS = 2;\r
+N_VMS = 3;\r
+C_ALLOC_THRESHOLD = 0.65;\r
+CUST_ALLOC_THRESHOLD = 0.95;\r
+AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\r
+PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\r
+\r
+cust_type = GOLD;\r
+N_VNFS = 1;\r
+\r
+w_metrics = [0.9, 0.1];\r
+w_attributes = [0.1, 0.9, 0.05, 0.05]; \r
+\r
+capabilities = [| 0, 1, 1, 1\r
+                | 1, 0, 1, 1\r
+                | 1, 1, 0, 1 |];\r
+\r
+cpu_utilization = [| 0.05, 0.9\r
+                   | 0.1, 0.5\r
+                   | 0.6, 0.8 |];\r
+\r
+c_alloc_capacity = [| 600, 1200\r
+                    | 1200, 2400\r
+                    | 2400, 4800 |];\r
+\r
+c_total_capacity = [| 1000, 2000\r
+                    | 2000, 4000\r
+                    | 4000, 8000 |];\r
+\r
+c_alloc_capacity_norm = [| 0.6, 0.6\r
+                         | 0.6, 0.6\r
+                         | 0.6, 0.6 |];\r
+\r
+cust_alloc_capacity = [| 60, 120\r
+                       | 120, 240\r
+                       | 240, 480 |];\r
+\r
+cust_total_capacity = [| 100, 200\r
+                       | 200, 400\r
+                       | 400, 800 |];\r
+\r
+cust_alloc_capacity_norm = [| 0.6, 0.6\r
+                            | 0.6, 0.6\r
+                            | 0.6, 0.6 |];\r
+\r
+vm_reqs = [| 1, 4\r
+           | 2, 8\r
+           | 4, 16 |];\r
+\r
+%vm_reqs_sums = [ 14, 56 ];\r
+\r
+vm_reqs_sums_norm = [| 0.007, 0.014\r
+                     | 0.0035, 0.007\r
+                     | 0.00175, 0.0035 |];\r
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/normal-silver-less-pref.dzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/normal-silver-less-pref.dzn
new file mode 100755 (executable)
index 0000000..1184ece
--- /dev/null
@@ -0,0 +1,57 @@
+N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\r
+N_ATTRIBUTES = 4;\r
+N_UTILIZATION_METRICS = 2;\r
+N_CAPACITY_METRICS = 2;\r
+N_VMS = 3;\r
+C_ALLOC_THRESHOLD = 0.65;\r
+CUST_ALLOC_THRESHOLD = 0.95;\r
+AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\r
+PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\r
+\r
+cust_type = SILVER;\r
+\r
+w_metrics = [0.9, 0.1];\r
+w_attributes = [0, 0.9, 0.05, 0.05];\r
+\r
+%{ CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+capabilities = [| 0, 1, 1, 1\r
+                | 1, 0, 1, 1\r
+                | 1, 1, 0, 1 |];\r
+\r
+cpu_utilization = [| 0.05, 0.9\r
+                   | 0.5, 0.94\r
+                   | 0.5, 0.94 |];\r
+\r
+c_alloc_capacity = [| 600, 1200\r
+                    | 1200, 2400\r
+                    | 2400, 4800 |];\r
+\r
+c_total_capacity = [| 1000, 2000\r
+                    | 2000, 4000\r
+                    | 4000, 8000 |];\r
+\r
+c_alloc_capacity_norm = [| 0.6, 0.6\r
+                         | 0.6, 0.6\r
+                         | 0.6, 0.6 |];\r
+\r
+cust_alloc_capacity = [| 60, 120\r
+                       | 120, 240\r
+                       | 240, 480 |];\r
+\r
+cust_total_capacity = [| 100, 200\r
+                       | 200, 400\r
+                       | 400, 800 |];\r
+\r
+cust_alloc_capacity_norm = [| 0.6, 0.6\r
+                            | 0.6, 0.6\r
+                            | 0.6, 0.6 |];\r
+\r
+vm_reqs = [| 2, 8\r
+           | 4, 16\r
+           | 8, 32 |];\r
+\r
+%vm_reqs_sums = [ 14, 56 ];\r
+\r
+vm_reqs_sums_norm = [| 0.014, 0.028\r
+                     | 0.007, 0.014\r
+                     | 0.0035, 0.007 |];\r
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement-minizinc.ipynb b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement-minizinc.ipynb
new file mode 100755 (executable)
index 0000000..68ab73b
--- /dev/null
@@ -0,0 +1,466 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "int: N_CLOUD_REGIONS;  % number of cloud regions\n",
+      "% set of 1..N_CLOUD_REGIONS: C_REGIONS;\n",
+      "\n",
+      "int: N_ATTRIBUTES; %  number of capability related attributes\n",
+      "% set of 1..N_ATTRIBUTES: ATTRIBS;\n",
+      "array[1..N_ATTRIBUTES] of float: w_attributes; % weights of each attribute\n",
+      "\n",
+      "int: N_UTILIZATION_METRICS; % number of dynamic capacity metrics of interest\n",
+      "% set of 1..N_UTILIZATION_METRICS: U_METRICS;\n",
+      "array[1..N_UTILIZATION_METRICS] of float: w_metrics; % weights of each capacity metric\n",
+      "\n",
+      "int: cust_type;  % customer type, 0 = regular, 1 = silver, 2 = gold\n",
+      "int: N_VMS; % number of VMs in VNF\n",
+      "int: N_CAPACITY_METRICS; % number of metrics for cloud region capacity check\n",
+      "\n",
+      "float: C_ALLOC_THRESHOLD; % allocation threshold for cloud\n",
+      "float: CUST_ALLOC_THRESHOLD; % allocation threshold for customer in cloud\n",
+      "float: AVG_CPU_UTILIZATION_THRESHOLD;\n",
+      "float: PEAK_CPU_UTILIZATION_THRESHOLD;\n",
+      "\n",
+      "enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
+      "enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
+      "enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
+      "enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
+      "enum VNFS_TYPES = { VDNS, VFW };\n",
+      "int: N_VNFS;\n",
+      "\n",
+      "% set of 1..N_CAPACITY_METRICS: CAP_METRICS;\n",
+      "\n",
+      "% whether a cloud region has the corresponding capability -- data will be customer specific\n",
+      "% array[1..N_CLOUD_REGIONS, 1..N_CLOUD_REGIONS] of float: c_dist;\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_ATTRIBUTES] of int: capabilities;\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_UTILIZATION_METRICS] of float: cpu_utilization;  % how much capacity is already dynamically utilized     (fraction)\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_alloc_capacity; % how much percent is already allocated in the cloud\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_total_capacity;  % total cloud capacity\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: c_alloc_capacity_norm;\n",
+      "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",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: cust_total_capacity; % total cloud capacity for customer\n",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: cust_alloc_capacity_norm;\n",
+      "\n",
+      "% VM requirements for each type of capacity (vm cpu, memory, etc.)\n",
+      "% TODO: establish a standard for units (MB RAM, GB disk, N virtual cores, etc.)\n",
+      "array[1..N_VMS, 1..N_CAPACITY_METRICS] of int: vm_reqs;\n",
+      "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",
+      "array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: vm_reqs_sums_norm;\n",
+      "%forall(i in 1..N_CLOUD_REGIONS, j in 1..N_CAPACITY_METRICS) (\n",
+      "%  vm_reqs_sums_norm[i, j] = vm_reqs_sums[j]/c_total_capacity[i, j]\n",
+      "%)\n",
+      "%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",
+      "\n",
+      "array[1..N_VNFS] of var int: s_regions;  % target cloud regions (solution to the problem)\n",
+      "\n",
+      "% custom constraints\n",
+      "constraint forall (s in s_regions) (\n",
+      "    cpu_utilization[s, AVG_CPU_UTILIZATION] <= AVG_CPU_UTILIZATION_THRESHOLD /\\    % hard constraint: need some capacity available\n",
+      "    cpu_utilization[s, PEAK_CPU_UTILIZATION] <= PEAK_CPU_UTILIZATION_THRESHOLD /\\  % hard constraint: need some capacity available\n",
+      "    cust_alloc_capacity[s, CPU_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\\n",
+      "    cust_alloc_capacity[s, MEMORY_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD]) /\\\n",
+      "    c_alloc_capacity[s, CPU_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\\n",
+      "    c_alloc_capacity[s, MEMORY_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD])\n",
+      ");\n",
+      "\n",
+      "% specific constraints based on the VNF\n",
+      "constraint capabilities[s_regions[VDNS], CORE_DC] = 1;  % hard constraint for vDNS: has to be placed in CORE DC\n",
+      "\n",
+      "% custom soft constraint for gold customers -- give a large weight to direct connection\n",
+      "var float: additional_obj = sum(s in s_regions) (bool2int(cust_type = GOLD) * capabilities[s, MIN_GUARANTEE] * 1000);\n",
+      "\n",
+      "% TODO: global constraints (such as data validation)\n",
+      "\n",
+      "% Objective for utilization\n",
+      "var float: obj_c_capacity = sum(k in 1..N_CAPACITY_METRICS, s in s_regions) (\n",
+      "\t\t  (1 - c_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]) +\n",
+      "                  (1 - cust_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]));\n",
+      "\n",
+      "% Objective for utilization\n",
+      "var float: obj_utilization = sum(k in 1..N_UTILIZATION_METRICS, s in s_regions) ( w_metrics[k] * (1 - cpu_utilization[s, k]) );\n",
+      "\n",
+      "% Objective for capabilities\n",
+      "var float: obj_capabilities = sum(k in 1..N_ATTRIBUTES, s in s_regions) ( w_attributes[k] * capabilities[s, k] );\n",
+      "\n",
+      "% Overall objective function\n",
+      "var float: obj = obj_c_capacity + obj_utilization + obj_capabilities + additional_obj;\n",
+      "\n",
+      "solve maximize obj;\n",
+      "\n",
+      "output [ \"Solution: \\nCloud Region for vDNS = \", show(s_regions[VDNS]) ] \n",
+      "++ [ if N_VNFS = 2 then \"\\nCloud Region for vFW = \" ++ show(s_regions[VFW]) ++ \"\\n\" else \"\\n\" endif ]\n",
+      "++ [ \"Objective function value: \", show(obj), \"\\n\", \"Customer type: \", show(cust_type), \"\\n\"];\n"
+     ]
+    }
+   ],
+   "source": [
+    "!cat placement.mzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
+      "% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
+      "% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
+      "% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
+      "\n",
+      "N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\n",
+      "N_ATTRIBUTES = 4;\n",
+      "N_UTILIZATION_METRICS = 2;\n",
+      "N_CAPACITY_METRICS = 2;\n",
+      "N_VMS = 3;\n",
+      "C_ALLOC_THRESHOLD = 0.65;\n",
+      "CUST_ALLOC_THRESHOLD = 0.95;\n",
+      "AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\n",
+      "PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\n",
+      "\n",
+      "cust_type = GOLD;\n",
+      "N_VNFS = 1;\n",
+      "\n",
+      "w_metrics = [0.9, 0.1];\n",
+      "w_attributes = [0.1, 0.9, 0.05, 0.05]; \n",
+      "\n",
+      "capabilities = [| 0, 1, 1, 1\n",
+      "                | 1, 0, 1, 1\n",
+      "                | 1, 1, 0, 1 |];\n",
+      "\n",
+      "cpu_utilization = [| 0.05, 0.9\n",
+      "                   | 0.1, 0.5\n",
+      "                   | 0.6, 0.8 |];\n",
+      "\n",
+      "c_alloc_capacity = [| 600, 1200\n",
+      "                    | 1200, 2400\n",
+      "                    | 2400, 4800 |];\n",
+      "\n",
+      "c_total_capacity = [| 1000, 2000\n",
+      "                    | 2000, 4000\n",
+      "                    | 4000, 8000 |];\n",
+      "\n",
+      "c_alloc_capacity_norm = [| 0.6, 0.6\n",
+      "                         | 0.6, 0.6\n",
+      "                         | 0.6, 0.6 |];\n",
+      "\n",
+      "cust_alloc_capacity = [| 60, 120\n",
+      "                       | 120, 240\n",
+      "                       | 240, 480 |];\n",
+      "\n",
+      "cust_total_capacity = [| 100, 200\n",
+      "                       | 200, 400\n",
+      "                       | 400, 800 |];\n",
+      "\n",
+      "cust_alloc_capacity_norm = [| 0.6, 0.6\n",
+      "                            | 0.6, 0.6\n",
+      "                            | 0.6, 0.6 |];\n",
+      "\n",
+      "vm_reqs = [| 1, 4\n",
+      "           | 2, 8\n",
+      "           | 4, 16 |];\n",
+      "\n",
+      "%vm_reqs_sums = [ 14, 56 ];\n",
+      "\n",
+      "vm_reqs_sums_norm = [| 0.007, 0.014\n",
+      "                     | 0.0035, 0.007\n",
+      "                     | 0.00175, 0.0035 |];\n"
+     ]
+    }
+   ],
+   "source": [
+    "!cat gold.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "23c23\n",
+      "<                 | 1, 0, 1, 1\n",
+      "---\n",
+      ">                 | 1, 0, 0, 1\n"
+     ]
+    }
+   ],
+   "source": [
+    "!diff gold.dzn gold-no-min-guarantee.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "23c23\n",
+      "<                 | 1, 0, 1, 1\n",
+      "---\n",
+      ">                 | 1, 0, 0, 1\n"
+     ]
+    }
+   ],
+   "source": [
+    "!diff gold.dzn gold-no-min-guarantee.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\n",
+      "% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\n",
+      "% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\n",
+      "% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\n",
+      "\n",
+      "N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\n",
+      "N_ATTRIBUTES = 4;\n",
+      "N_UTILIZATION_METRICS = 2;\n",
+      "N_CAPACITY_METRICS = 2;\n",
+      "N_VMS = 3;\n",
+      "C_ALLOC_THRESHOLD = 0.65;\n",
+      "CUST_ALLOC_THRESHOLD = 0.95;\n",
+      "AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\n",
+      "PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\n",
+      "\n",
+      "cust_type = SILVER;\n",
+      "N_VNFS = 2;\n",
+      "\n",
+      "w_metrics = [0.9, 0.1];\n",
+      "w_attributes = [0.1, 0.9, 0.05, 0.05]; \n",
+      "\n",
+      "capabilities = [| 0, 1, 1, 1\n",
+      "                | 1, 0, 1, 1\n",
+      "                | 1, 1, 0, 1 |];\n",
+      "\n",
+      "cpu_utilization = [| 0.05, 0.9\n",
+      "                   | 0.1, 0.5\n",
+      "                   | 0.6, 0.8 |];\n",
+      "\n",
+      "c_alloc_capacity = [| 600, 1200\n",
+      "                    | 1200, 2400\n",
+      "                    | 2400, 4800 |];\n",
+      "\n",
+      "c_total_capacity = [| 1000, 2000\n",
+      "                    | 2000, 4000\n",
+      "                    | 4000, 8000 |];\n",
+      "\n",
+      "c_alloc_capacity_norm = [| 0.6, 0.6\n",
+      "                         | 0.6, 0.6\n",
+      "                         | 0.6, 0.6 |];\n",
+      "\n",
+      "cust_alloc_capacity = [| 60, 120\n",
+      "                       | 120, 240\n",
+      "                       | 240, 480 |];\n",
+      "\n",
+      "cust_total_capacity = [| 100, 200\n",
+      "                       | 200, 400\n",
+      "                       | 400, 800 |];\n",
+      "\n",
+      "cust_alloc_capacity_norm = [| 0.6, 0.6\n",
+      "                            | 0.6, 0.6\n",
+      "                            | 0.6, 0.6 |];\n",
+      "\n",
+      "vm_reqs = [| 1, 4\n",
+      "           | 2, 8\n",
+      "           | 4, 16 |];\n",
+      "\n",
+      "%vm_reqs_sums = [ 14, 56 ];\n",
+      "\n",
+      "vm_reqs_sums_norm = [| 0.007, 0.014\n",
+      "                     | 0.0035, 0.007\n",
+      "                     | 0.00175, 0.0035 |];\n"
+     ]
+    }
+   ],
+   "source": [
+    "!cat silver.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "26c26\n",
+      "< cpu_utilization = [| 0.05, 0.9\n",
+      "---\n",
+      "> cpu_utilization = [| 0.05, 0.96\n"
+     ]
+    }
+   ],
+   "source": [
+    "!diff silver.dzn silver-high-edge-load.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Solution: \n",
+      "Cloud Region for vDNS = 2\n",
+      "Objective function value: 1002.639\n",
+      "Customer type: 3\n",
+      "----------\n",
+      "==========\n"
+     ]
+    }
+   ],
+   "source": [
+    "!mzn-gecode -a placement.mzn gold.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Solution: \n",
+      "Cloud Region for vDNS = 2\n",
+      "Objective function value: 2.589\n",
+      "Customer type: 3\n",
+      "----------\n",
+      "Solution: \n",
+      "Cloud Region for vDNS = 3\n",
+      "Objective function value: 3.0195\n",
+      "Customer type: 3\n",
+      "----------\n",
+      "==========\n"
+     ]
+    }
+   ],
+   "source": [
+    "!mzn-gecode -a placement.mzn gold-no-min-guarantee.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Solution: \n",
+      "Cloud Region for vDNS = 2\n",
+      "Cloud Region for vFW = 1\n",
+      "Objective function value: 6.062\n",
+      "Customer type: 2\n",
+      "----------\n",
+      "Solution: \n",
+      "Cloud Region for vDNS = 3\n",
+      "Cloud Region for vFW = 1\n",
+      "Objective function value: 6.4425\n",
+      "Customer type: 2\n",
+      "----------\n",
+      "==========\n"
+     ]
+    }
+   ],
+   "source": [
+    "!mzn-gecode -a placement.mzn silver.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Solution: \n",
+      "Cloud Region for vDNS = 2\n",
+      "Cloud Region for vFW = 2\n",
+      "Objective function value: 5.278\n",
+      "Customer type: 2\n",
+      "----------\n",
+      "Solution: \n",
+      "Cloud Region for vDNS = 3\n",
+      "Cloud Region for vFW = 2\n",
+      "Objective function value: 5.6585\n",
+      "Customer type: 2\n",
+      "----------\n",
+      "Solution: \n",
+      "Cloud Region for vDNS = 3\n",
+      "Cloud Region for vFW = 3\n",
+      "Objective function value: 6.039\n",
+      "Customer type: 2\n",
+      "----------\n",
+      "==========\n"
+     ]
+    }
+   ],
+   "source": [
+    "!mzn-gecode -a placement.mzn silver-high-edge-load.dzn"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.6.4"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement.mzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/placement.mzn
new file mode 100755 (executable)
index 0000000..ba66a4e
--- /dev/null
@@ -0,0 +1,89 @@
+int: N_CLOUD_REGIONS;  % number of cloud regions\r
+% set of 1..N_CLOUD_REGIONS: C_REGIONS;\r
+\r
+int: N_ATTRIBUTES; %  number of capability related attributes\r
+% set of 1..N_ATTRIBUTES: ATTRIBS;\r
+array[1..N_ATTRIBUTES] of float: w_attributes; % weights of each attribute\r
+\r
+int: N_UTILIZATION_METRICS; % number of dynamic capacity metrics of interest\r
+% set of 1..N_UTILIZATION_METRICS: U_METRICS;\r
+array[1..N_UTILIZATION_METRICS] of float: w_metrics; % weights of each capacity metric\r
+\r
+int: cust_type;  % customer type, 0 = regular, 1 = silver, 2 = gold\r
+int: N_VMS; % number of VMs in VNF\r
+int: N_CAPACITY_METRICS; % number of metrics for cloud region capacity check\r
+\r
+float: C_ALLOC_THRESHOLD; % allocation threshold for cloud\r
+float: CUST_ALLOC_THRESHOLD; % allocation threshold for customer in cloud\r
+float: AVG_CPU_UTILIZATION_THRESHOLD;\r
+float: PEAK_CPU_UTILIZATION_THRESHOLD;\r
+\r
+enum CUST_TYPES = { STANDARD, SILVER, GOLD };\r
+enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\r
+enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\r
+enum VNFS_TYPES = { VDNS, VFW };\r
+int: N_VNFS;\r
+\r
+% set of 1..N_CAPACITY_METRICS: CAP_METRICS;\r
+\r
+% whether a cloud region has the corresponding capability -- data will be customer specific\r
+% array[1..N_CLOUD_REGIONS, 1..N_CLOUD_REGIONS] of float: c_dist;\r
+array[1..N_CLOUD_REGIONS, 1..N_ATTRIBUTES] of int: capabilities;\r
+array[1..N_CLOUD_REGIONS, 1..N_UTILIZATION_METRICS] of float: cpu_utilization;  % how much capacity is already dynamically utilized     (fraction)\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_alloc_capacity; % how much percent is already allocated in the cloud\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: c_total_capacity;  % total cloud capacity\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: c_alloc_capacity_norm;\r
+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\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of int: cust_total_capacity; % total cloud capacity for customer\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: cust_alloc_capacity_norm;\r
+\r
+% VM requirements for each type of capacity (vm cpu, memory, etc.)\r
+% TODO: establish a standard for units (MB RAM, GB disk, N virtual cores, etc.)\r
+array[1..N_VMS, 1..N_CAPACITY_METRICS] of int: vm_reqs;\r
+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 ];\r
+array[1..N_CLOUD_REGIONS, 1..N_CAPACITY_METRICS] of float: vm_reqs_sums_norm;\r
+%forall(i in 1..N_CLOUD_REGIONS, j in 1..N_CAPACITY_METRICS) (\r
+%  vm_reqs_sums_norm[i, j] = vm_reqs_sums[j]/c_total_capacity[i, j]\r
+%)\r
+%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 ];\r
+\r
+array[1..N_VNFS] of var int: s_regions;  % target cloud regions (solution to the problem)\r
+\r
+% custom constraints\r
+constraint forall (s in s_regions) (\r
+    cpu_utilization[s, AVG_CPU_UTILIZATION] <= AVG_CPU_UTILIZATION_THRESHOLD /\    % hard constraint: need some capacity available\r
+    cpu_utilization[s, PEAK_CPU_UTILIZATION] <= PEAK_CPU_UTILIZATION_THRESHOLD /\  % hard constraint: need some capacity available\r
+    cust_alloc_capacity[s, CPU_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\r
+    cust_alloc_capacity[s, MEMORY_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD]) /\\r
+    c_alloc_capacity[s, CPU_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\\r
+    c_alloc_capacity[s, MEMORY_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD])\r
+);\r
+\r
+% specific constraints based on the VNF\r
+constraint capabilities[s_regions[VDNS], CORE_DC] = 1;  % hard constraint for vDNS: has to be placed in CORE DC\r
+\r
+% custom soft constraint for gold customers -- give a large weight to direct connection\r
+var float: additional_obj = sum(s in s_regions) (bool2int(cust_type = GOLD) * capabilities[s, MIN_GUARANTEE] * 1000);\r
+\r
+% TODO: global constraints (such as data validation)\r
+\r
+% Objective for utilization\r
+var float: obj_c_capacity = sum(k in 1..N_CAPACITY_METRICS, s in s_regions) (\r
+                 (1 - c_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]) +\r
+                  (1 - cust_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]));\r
+\r
+% Objective for utilization\r
+var float: obj_utilization = sum(k in 1..N_UTILIZATION_METRICS, s in s_regions) ( w_metrics[k] * (1 - cpu_utilization[s, k]) );\r
+\r
+% Objective for capabilities\r
+var float: obj_capabilities = sum(k in 1..N_ATTRIBUTES, s in s_regions) ( w_attributes[k] * capabilities[s, k] );\r
+\r
+% Overall objective function\r
+var float: obj = obj_c_capacity + obj_utilization + obj_capabilities + additional_obj;\r
+\r
+solve maximize obj;\r
+\r
+output [ "Solution: \nCloud Region for vDNS = ", show(s_regions[VDNS]) ] \r
+++ [ if N_VNFS = 2 then "\nCloud Region for vFW = " ++ show(s_regions[VFW]) ++ "\n" else "\n" endif ]\r
+++ [ "Objective function value: ", show(obj), "\n", "Customer type: ", show(cust_type), "\n"];\r
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver-high-edge-load.dzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver-high-edge-load.dzn
new file mode 100755 (executable)
index 0000000..6323782
--- /dev/null
@@ -0,0 +1,62 @@
+% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\r
+% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\r
+% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\r
+\r
+N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\r
+N_ATTRIBUTES = 4;\r
+N_UTILIZATION_METRICS = 2;\r
+N_CAPACITY_METRICS = 2;\r
+N_VMS = 3;\r
+C_ALLOC_THRESHOLD = 0.65;\r
+CUST_ALLOC_THRESHOLD = 0.95;\r
+AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\r
+PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\r
+\r
+cust_type = SILVER;\r
+N_VNFS = 2;\r
+\r
+w_metrics = [0.9, 0.1];\r
+w_attributes = [0.1, 0.9, 0.05, 0.05]; \r
+\r
+capabilities = [| 0, 1, 1, 1\r
+                | 1, 0, 1, 1\r
+                | 1, 1, 0, 1 |];\r
+\r
+cpu_utilization = [| 0.05, 0.96\r
+                   | 0.1, 0.5\r
+                   | 0.6, 0.8 |];\r
+\r
+c_alloc_capacity = [| 600, 1200\r
+                    | 1200, 2400\r
+                    | 2400, 4800 |];\r
+\r
+c_total_capacity = [| 1000, 2000\r
+                    | 2000, 4000\r
+                    | 4000, 8000 |];\r
+\r
+c_alloc_capacity_norm = [| 0.6, 0.6\r
+                         | 0.6, 0.6\r
+                         | 0.6, 0.6 |];\r
+\r
+cust_alloc_capacity = [| 60, 120\r
+                       | 120, 240\r
+                       | 240, 480 |];\r
+\r
+cust_total_capacity = [| 100, 200\r
+                       | 200, 400\r
+                       | 400, 800 |];\r
+\r
+cust_alloc_capacity_norm = [| 0.6, 0.6\r
+                            | 0.6, 0.6\r
+                            | 0.6, 0.6 |];\r
+\r
+vm_reqs = [| 1, 4\r
+           | 2, 8\r
+           | 4, 16 |];\r
+\r
+%vm_reqs_sums = [ 14, 56 ];\r
+\r
+vm_reqs_sums_norm = [| 0.007, 0.014\r
+                     | 0.0035, 0.007\r
+                     | 0.00175, 0.0035 |];\r
diff --git a/examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver.dzn b/examples/placement-models-minizinc/vdns-plus-vfw-use-case/silver.dzn
new file mode 100755 (executable)
index 0000000..4779a41
--- /dev/null
@@ -0,0 +1,62 @@
+% enum CUST_TYPES = { STANDARD, SILVER, GOLD };\r
+% enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };\r
+% enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };\r
+% enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};\r
+\r
+N_CLOUD_REGIONS = 3;  % e-dc-1, core-dc-1, core-dc-2\r
+N_ATTRIBUTES = 4;\r
+N_UTILIZATION_METRICS = 2;\r
+N_CAPACITY_METRICS = 2;\r
+N_VMS = 3;\r
+C_ALLOC_THRESHOLD = 0.65;\r
+CUST_ALLOC_THRESHOLD = 0.95;\r
+AVG_CPU_UTILIZATION_THRESHOLD = 0.7;\r
+PEAK_CPU_UTILIZATION_THRESHOLD = 0.95;\r
+\r
+cust_type = SILVER;\r
+N_VNFS = 2;\r
+\r
+w_metrics = [0.9, 0.1];\r
+w_attributes = [0.1, 0.9, 0.05, 0.05]; \r
+\r
+capabilities = [| 0, 1, 1, 1\r
+                | 1, 0, 1, 1\r
+                | 1, 1, 0, 1 |];\r
+\r
+cpu_utilization = [| 0.05, 0.9\r
+                   | 0.1, 0.5\r
+                   | 0.6, 0.8 |];\r
+\r
+c_alloc_capacity = [| 600, 1200\r
+                    | 1200, 2400\r
+                    | 2400, 4800 |];\r
+\r
+c_total_capacity = [| 1000, 2000\r
+                    | 2000, 4000\r
+                    | 4000, 8000 |];\r
+\r
+c_alloc_capacity_norm = [| 0.6, 0.6\r
+                         | 0.6, 0.6\r
+                         | 0.6, 0.6 |];\r
+\r
+cust_alloc_capacity = [| 60, 120\r
+                       | 120, 240\r
+                       | 240, 480 |];\r
+\r
+cust_total_capacity = [| 100, 200\r
+                       | 200, 400\r
+                       | 400, 800 |];\r
+\r
+cust_alloc_capacity_norm = [| 0.6, 0.6\r
+                            | 0.6, 0.6\r
+                            | 0.6, 0.6 |];\r
+\r
+vm_reqs = [| 1, 4\r
+           | 2, 8\r
+           | 4, 16 |];\r
+\r
+%vm_reqs_sums = [ 14, 56 ];\r
+\r
+vm_reqs_sums_norm = [| 0.007, 0.014\r
+                     | 0.0035, 0.007\r
+                     | 0.00175, 0.0035 |];\r