Minizinc Placement Model Ex. for vDNS+vFW use case
[optf/osdf.git] / examples / placement-models-minizinc / vdns-use-case / vDNS-service-model-driven-placement.mzn
1 int: N_CLOUD_REGIONS;  % number of cloud regions 
2
3 int: N_ATTRIBUTES; %  number of capability related attributes
4 array[1..N_ATTRIBUTES] of float: W_ATTRIBUTES; % weights of each attribute
5
6 int: N_METRICS; % number of dynamic capacity metrics of interest
7 array[1..N_METRICS] of float: W_METRICS; % weights of each capacity metric
8
9 int: CUST_TYPE;  % customer type, 0 = regular, 1 = silver, 2 = gold
10
11 enum CUST_TYPES = { STANDARD, SILVER, GOLD };
12 enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV };
13 enum METRICS = { AVG_UTILIZATION, PEAK_UTILIZATION };
14  
15 % whether a cloud region has the corresponding capability -- data will be customer specific
16 array[1..N_CLOUD_REGIONS, 1..N_ATTRIBUTES] of int: capabilities; 
17 array[1..N_CLOUD_REGIONS, 1..N_METRICS] of float: utilization;  % how much capacity is already utilized (fraction)
18
19 var int: s;  % target cloud region (solution to the problem)
20
21 % custom constraints
22 constraint capabilities[s, CORE_DC] = 1;   % hard constraint: has to be placed in CORE DC
23 constraint utilization[s, AVG_UTILIZATION] <= 0.85;   % hard constraint: need some capacity available
24 % custom soft constraint for gold customers -- give a large weight to direct connection
25 var float: additional_obj = bool2int(CUST_TYPE = GOLD) * capabilities[s, DIRECT_CONN] * 1000;
26
27 % TODO: global constraints (such as data validation)
28
29 % Objective for utilization
30 var float: obj_utilization = sum(k in 1..N_METRICS) ( W_METRICS[k] * (1 - utilization[s, k]) );
31
32 % Objective for capabilities
33 var float: obj_capabilities = sum(k in 1..N_ATTRIBUTES) ( W_ATTRIBUTES[k] * capabilities[s, k] );
34
35 % Overall objective function
36 var float: obj = obj_utilization + obj_capabilities + additional_obj;  % can later add weights to each...
37
38 solve maximize obj;
39
40 output ["Cloud Region: ", show(s), "\n", "Objective function value: ", show(obj), "\n", "Customer type: ", show(CUST_TYPE), "\n"];