diff options
author | Ramki Krishnan <ramkri123@gmail.com> | 2018-02-18 00:19:55 +0000 |
---|---|---|
committer | Ramki Krishnan <ramkri123@gmail.com> | 2018-02-18 00:23:46 +0000 |
commit | a21bce03b9b475fba5da7ff6a870a62ac4e8fe04 (patch) | |
tree | 8ccc49bc353ba991e509f565e5ea10ebab93687f | |
parent | 5b32883fa5fc1ceb6263adb9fd683c2d604abff0 (diff) |
Minizinc model-driven example for vDNS placement
Issue-ID: OPTFRA-110
Change-Id: I3944c82e387cda15a427005f5eb6527346fc37d5
Signed-off-by: Ramki Krishnan <ramkri123@gmail.com>
-rw-r--r-- | minizinc-examples/vDNS-service-model-driven-placement.mzn | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/minizinc-examples/vDNS-service-model-driven-placement.mzn b/minizinc-examples/vDNS-service-model-driven-placement.mzn new file mode 100644 index 0000000..08292be --- /dev/null +++ b/minizinc-examples/vDNS-service-model-driven-placement.mzn @@ -0,0 +1,40 @@ +int: N_CLOUD_REGIONS; % number of cloud regions + +int: N_ATTRIBUTES; % number of capability related attributes +array[1..N_ATTRIBUTES] of float: W_ATTRIBUTES; % weights of each attribute + +int: N_METRICS; % number of dynamic capacity metrics of interest +array[1..N_METRICS] of float: W_METRICS; % weights of each capacity metric + +int: CUST_TYPE; % customer type, 0 = regular, 1 = silver, 2 = gold + +enum CUST_TYPES = { STANDARD, SILVER, GOLD }; +enum ATTRIBUTES = { CORE_DC, DIRECT_CONN, MIN_GUARANTEE, SRIOV }; +enum METRICS = { AVG_UTILIZATION, PEAK_UTILIZATION }; + +% whether a cloud region has the corresponding capability -- data will be customer specific +array[1..N_CLOUD_REGIONS, 1..N_ATTRIBUTES] of int: capabilities; +array[1..N_CLOUD_REGIONS, 1..N_METRICS] of float: utilization; % how much capacity is already utilized (fraction) + +var int: s; % target cloud region (solution to the problem) + +% custom constraints +constraint capabilities[s, CORE_DC] = 1; % hard constraint: has to be placed in CORE DC +constraint utilization[s, AVG_UTILIZATION] <= 0.85; % hard constraint: need some capacity available +% custom soft constraint for gold customers -- give a large weight to direct connection +var float: additional_obj = bool2int(CUST_TYPE = GOLD) * capabilities[s, DIRECT_CONN] * 1000; + +% TODO: global constraints (such as data validation) + +% Objective for utilization +var float: obj_utilization = sum(k in 1..N_METRICS) ( W_METRICS[k] * (1 - utilization[s, k]) ); + +% Objective for capabilities +var float: obj_capabilities = sum(k in 1..N_ATTRIBUTES) ( W_ATTRIBUTES[k] * capabilities[s, k] ); + +% Overall objective function +var float: obj = obj_utilization + obj_capabilities + additional_obj; % can later add weights to each... + +solve maximize obj; + +output ["Cloud Region: ", show(s), "\n", "Objective function value: ", show(obj), "\n", "Customer type: ", show(CUST_TYPE), "\n"]; |