-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem1.mod
57 lines (43 loc) · 1.21 KB
/
problem1.mod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#PARAMETERS
#number of requests
param N;
set I := 1..N; #set I of requests
#number of virtual machine
param M;
set J := 1..M; #set J of virtual machines
#request traffic
param w{1..N};
#request CPU requirement
param cpu{1..N} default 1;
#request memory requirement
param m{1..N} default 1;
#VM capacity
param B_c;
#VM max CPU
param B_CPU default N;
#VM max memory
param B_m default N;
### Part 1 ###
#VARIABLES
var y{J}, binary; #1 if VM j is open, 0 otherwise
var x{I,J}, binary; #1 if request i is assigned to VM j, 0 otherwise
#OBJECTIVE FUNCTION
#minimize number of used virtual machines
minimize VMs:
sum{j in J} y[j];
#CONSTRAINTS
#assignment constraints
subject to assignment{i in I}:
sum{j in J} x[i,j] = 1; #every requests must be assigned to one and only one VM
#capacity constraints
subject to VM_capac{j in J}:
sum{i in I} w[i]*x[i,j] <= B_c;
subject to VM_max_CPU{j in J}:
sum{i in I} cpu[i]*x[i,j] <= B_CPU;
subject to VM_max_memory{j in J}:
sum{i in I} m[i]*x[i,j] <= B_m;
#consistency constraints
subject to consistency{i in I, j in J}:
x[i,j] <= y[j];
subject to data_consistency{i in I}:
w[i] <= B_c and cpu[i] <= B_CPU and m[i] <= B_m;