1 include "globals.mzn";
\r
3 int: NCR; % number of cloud regions
\r
4 int: N_ATTR; % number of capability related attributes
\r
5 array[1..N_ATTR] of float: w_attr; % weights of each attribute
\r
7 int: N_UTILIZATION_METRICS; % number of dynamic capacity metrics of interest
\r
8 % set of 1..N_UTILIZATION_METRICS: U_METRICS;
\r
9 array[1..N_UTILIZATION_METRICS] of float: w_metrics; % weights of each capacity metric
\r
11 int: cust_type; % customer type, 0 = regular, 1 = silver, 2 = gold
\r
12 int: N_VMS; % number of VMs in VNF
\r
13 int: N_CAPM; % number of metrics for cloud region capacity check
\r
14 int: MIN_GUAR_ADDL_WT; % additional weight for min guarantee capability
\r
16 float: C_ALLOC_THRESHOLD; % allocation threshold for cloud
\r
17 float: CUST_ALLOC_THRESHOLD; % allocation threshold for customer in cloud
\r
18 float: AVG_CPU_UTILIZATION_THRESHOLD;
\r
19 float: PEAK_CPU_UTILIZATION_THRESHOLD;
\r
25 array[1..NCR] of int: cr_lat;
\r
26 array[1..NCR] of int: cr_lon;
\r
28 enum CUST_TYPES = { STANDARD, SILVER, GOLD };
\r
29 enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };
\r
30 enum METRICS = { AVG_CPU_UTILIZATION, PEAK_CPU_UTILIZATION };
\r
31 enum CLOUD_REGION_CAPACITY = {CPU_CLOUD, MEMORY_CLOUD};
\r
32 enum WL_TYPES = { W1, W2, W3, W4, W5 };
\r
35 % set of 1..N_CAPM: CAP_METRICS;
\r
37 % whether a cloud region has the corresponding capability -- data will be customer specific
\r
38 array[1..NCR, 1..N_ATTR] of int: capabilities;
\r
39 array[1..NCR, 1..N_UTILIZATION_METRICS] of float: cpu_utilization; % how much capacity is already dynamically utilized (fraction)
\r
40 array[1..NCR, 1..N_CAPM] of int: c_alloc_capacity; % how much percent is already allocated in the cloud
\r
41 array[1..NCR, 1..N_CAPM] of int: c_total_capacity; % total cloud capacity
\r
42 array[1..NCR, 1..N_CAPM] of float: c_alloc_capacity_norm;
\r
43 array[1..NCR, 1..N_CAPM] of int: cust_alloc_capacity; % how much percent is already allocated in the cloud for the customer
\r
44 array[1..NCR, 1..N_CAPM] of int: cust_total_capacity; % total cloud capacity for customer
\r
45 array[1..NCR, 1..N_CAPM] of float: cust_alloc_capacity_norm;
\r
47 % VM requirements for each type of capacity (vm cpu, memory, etc.)
\r
48 % TODO: establish a standard for units (MB RAM, GB disk, N virtual cores, etc.)
\r
49 array[1..N_VMS, 1..N_CAPM] of int: vm_reqs;
\r
50 array[1..N_CAPM] of int: vm_reqs_sums = [ sum(k in 1..N_VMS) (vm_reqs[k,j]) | j in 1..N_CAPM ];
\r
51 array[1..NCR, 1..N_CAPM] of float: vm_reqs_sums_norm;
\r
52 %forall(i in 1..NCR, j in 1..N_CAPM) (
\r
53 % vm_reqs_sums_norm[i, j] = vm_reqs_sums[j]/c_total_capacity[i, j]
\r
55 %array[1..NCR, 1..N_CAPM] of float: vm_reqs_sums_norm = [ ((vm_reqs_sums[j]/c_total_capacity[i,j]) | j in 1..N_CAPM) | i in 1..NCR ];
\r
57 array[1..N_WL] of var int: s_regions; % target cloud regions (solution to the problem)
\r
59 function var float: dist(var int: x1, var int: y1, var int: x2, var int: y2) = (sqrt(pow((x1-x2),2) + pow((y1-y2),2)))/dist_norm;
\r
61 % custom constraints
\r
62 constraint forall (s in s_regions) (
\r
63 cpu_utilization[s, AVG_CPU_UTILIZATION] <= AVG_CPU_UTILIZATION_THRESHOLD /\ % hard constraint: need some capacity available
\r
64 cpu_utilization[s, PEAK_CPU_UTILIZATION] <= PEAK_CPU_UTILIZATION_THRESHOLD /\ % hard constraint: need some capacity available
\r
65 cust_alloc_capacity[s, CPU_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\
\r
66 cust_alloc_capacity[s, MEMORY_CLOUD] <= (CUST_ALLOC_THRESHOLD*(cust_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD]) /\
\r
67 c_alloc_capacity[s, CPU_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, CPU_CLOUD])) - (vm_reqs_sums[CPU_CLOUD]) /\
\r
68 c_alloc_capacity[s, MEMORY_CLOUD] <= (C_ALLOC_THRESHOLD*(c_total_capacity[s, MEMORY_CLOUD])) - (vm_reqs_sums[MEMORY_CLOUD])
\r
71 % specific constraints based on the workload
\r
72 constraint [capabilities[s_regions[x], CORE_DC] | x in WL_TYPES] = [1, 1, 0, 0, 0];
\r
74 constraint forall (x in [W3, W4, W5])
\r
75 (dist(u_lat, u_lon, cr_lat[s_regions[x]], cr_lon[s_regions[x]]) < max_dist_ue/dist_norm);
\r
77 constraint all_different([s_regions[x] | x in WL_TYPES]);
\r
79 % custom soft constraint for gold customers -- give a large weight to Minimum Guarantee
\r
80 var float: additional_obj = sum(s in s_regions) (bool2int(cust_type = GOLD) * capabilities[s, MIN_GUARANTEE] * MIN_GUAR_ADDL_WT);
\r
82 % TODO: global constraints (such as data validation)
\r
84 % Objective for utilization
\r
85 var float: obj_c_capacity = sum(k in 1..N_CAPM, s in s_regions) (
\r
86 (1 - c_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]) +
\r
87 % (1 - cust_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]));
\r
88 (1 - cust_alloc_capacity_norm[s, k] - vm_reqs_sums_norm[s, k]) +
\r
89 (1 - dist(u_lat, u_lon,cr_lat[s], cr_lon[s])));
\r
91 % Objective for utilization
\r
92 var float: obj_utilization = sum(k in 1..N_UTILIZATION_METRICS, s in s_regions) ( w_metrics[k] * (1 - cpu_utilization[s, k]) );
\r
94 % Objective for capabilities
\r
95 var float: obj_capabilities = sum(k in 1..N_ATTR, s in s_regions) ( w_attr[k] * capabilities[s, k] );
\r
97 % Overall objective function
\r
98 var float: obj = obj_c_capacity + obj_utilization + obj_capabilities + additional_obj;
\r
100 solve maximize obj;
\r
102 output [ "Solution: \n"
\r
103 ++ concat(["Cloud Region for W" ++ format(x) ++ " = " ++ format(s_regions[x]) ++ "\n" | x in 1..N_WL]) ]
\r
104 ++ [ "Objective function value: ", show(obj), "\n", "Customer type: ", show(cust_type), "\n"];
\r