Uploaded by Ace Duy

Building-Constraints

advertisement
Miniguide for Building Constraints in Mathematical Linear Model
Phan Nguyen Ky Phuc
October 14, 2021
Contents
1 Open Facility Decision
2
2 Binary Inference
2
3 Inference Condition
2
4 Max Constraint
3
4.1
Max Constraint: X = max(A, 0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
4.2
Max Constraint: X = max(A,B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
4.3
Extension of Max Constraint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
5 Min Constraint
4
5.1
The min constraint: X=min(A,0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
5.2
The Min Constraint: X=min(A,B) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
6 And Condition
5
7 Or Condition
5
8 XOR Condition
5
9 Imply Condition
6
10 Z=X ⇥ Y Constraint
6
11 Conflicted Condition when Starting and Finishing Time are parameters
6
12 Conflicted Condition when Starting and Finishing Times are Variables
7
13 Another Approach For Handling Conflict Constraint
7
14 Absolute Values for Binary Variables
8
1
Ho Chi Minh City International University
Industrial Systems Engineering Department
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
15 Piece-wise Linear Constraints
8
16 Belong to The Range Constraints
9
17 Belong to the range constraint: Discrete case
9
18 Other Inference
9
19 Jobs Use Multiple Resources
1
10
Open Facility Decision
Let:
Cj : be the capacity regarding to facility j
BigM : be the very large number
Oj : be the binary decision variable, Oj = 1 if the facility j is opened; otherwise Oj = 0
It is often that, there are at least one of 2 following constraints
X
i
X
i
2
()  Cj ⇥ Oj
()  BigM ⇥ Oj
Binary Inference
If X = 1 then Y = 1: Y
X
If X = 1 then Y = 0: Y  1 X
If X = 0 then Y = 0: Y  X
If X = 0 then Y = 1: Y
3
1
X
Inference Condition
The inference condition is under the form:
• If (X = 1) then A  B:
• If (X = 0) then A
BigM ⇥ (X
1) + A  B
B:
• If (X = 1) then A = B
Guide to Construct Linear Constraint
BigM ⇥ X + A
B
8
<BigM ⇥ (X 1) + A  B
:BigM ⇥ (1 X) + A
B
Page 2
Ho Chi Minh City International University
Industrial Systems Engineering Department
4
4.1
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
Max Constraint
Max Constraint: X = max(A, 0)
Consider the following constraint:
X = max(A, 0)
where X, A are variables. This constraint can be transformed to linear form:
Let Y be the index variable:
8
<1 , if A 0
Y =
:0 , if A  0
The constraints between A and Y can be expressed as:
8
<A
BigM ⇥ (Y
1)
:A  BigM ⇥ Y
Now the constraints between X = max(A, 0) can be transformed as linear :
4.2
8
<0  X  0 + BigM ⇥ Y
:A  X  A + BigM ⇥ (1
Y)
Max Constraint: X = max(A,B)
Consider the following constraints:
X = max(A, B)
where X, A, B are variables. This constraint can be transformed to linear form as follow:
Let Y be the index variable:
The constraints between (A
8
<1 , if (A
Y =
:0 , if (A
B)
0
B)  0
B) and Y can be expressed as:
8
<(A
:(A
B)
B)
BigM ⇥ (Y
1)
 BigM ⇥ Y
Now the constraints X = max(A, B) can be transformed to linear form as :
4.3
8
<B  X  B + BigM ⇥ Y
:A  X  A + BigM ⇥ (1
Y)
Extension of Max Constraint
Given a threshold R for a resource , if the usage of this resource is higher than R it will incur an extra cost
for each extra usage resource.
In short the following constraints need to be transform into linear constraint:
Guide to Construct Linear Constraint
Page 3
Ho Chi Minh City International University
Industrial Systems Engineering Department
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
X
X = max
!
C i Yi
R, 0
i
Let Z be the index variable:
8
<1 , if (P C Y
i i i
Z=
:0 , if (P C Y
P
i
Ci Yi
Now the constraints X = max (
5
5.1
P
i
0
R)  0
i i
i
The constraints between (
R)
R) and Z can be expressed as:
8
<(P C Y
i i i
:(P C Y
i i i
C i Yi
BigM ⇥ (Z
R)
1)
 BigM ⇥ Z
R)
R, 0) can be transformed to linear form as :
8
<0  X  0 + BigM ⇥ Z
P
:(P C Y
R)  X  ( i Ci Yi
i i i
R) + BigM ⇥ (1
Z)
Min Constraint
The min constraint: X=min(A,0)
Consider the following constraints:
X = min(A, 0)
where X, A are variables. This constraint can be transformed to linear as follow:
Let Y be the index variable:
8
<1 , if A 0
Y =
:0 , if A  0
The constraints between A and Y can be expressed as:
8
<A
BigM ⇥ (Y
1)
:A  BigM ⇥ Y
Now the constraints between X = min(A, 0) can be transformed to linear form:
8
<0
5.2
:A
X
0
X
A
BigM ⇥ (1
BigM ⇥ Y
The Min Constraint: X=min(A,B)
Consider the following constraints:
X = min(A, B)
Guide to Construct Linear Constraint
Page 4
Y)
Ho Chi Minh City International University
Industrial Systems Engineering Department
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
where X, A, B are variables. This constraint can be transformed to linear form as follow:
Let Y be the binary variable:
8
<1 , if A B 0
Y =
:0 , if A B  0
The constraints between (A
B) and Y can be expressed as:
8
<(A
BigM ⇥ (Y
B)
:(A
B)
1)
 BigM ⇥ Y
Now the constraint X = min(A, B) can be transformed to linear form:
8
<B
6
And Condition
:A
X
B
BigM ⇥ (1
X
A
BigM ⇥ Y
Y)
Given Xi , Y are binary variable Y relates to Xi through AND operator
Y = X1 \ X2 \ X3 ... \ Xn
This constraint can be transformed to linear form as
8
<Y  X ,8i, i = 1...n
i
P
:Y
n+1
i Xi
7
Or Condition
Given Xi , Y are binary variable Y relates to Xi through OR operator
Y = X1 [ X2 [ X3 ... [ Xn
This constraint can be transformed to linear form as
8
<Y
Xi ,8i, i = 1...n
:Y  P X
i
8
i
XOR Condition
Y = X1 XOR X2
Guide to Construct Linear Constraint
8
>
>
Y
X1 + X2 1
>
>
>
>
<Y
1 X1 X2
>
>
Y  1 X1 + X2
>
>
>
>
:Y  1 X + X
2
1
Page 5
Ho Chi Minh City International University
Industrial Systems Engineering Department
X
1
0
0
1
9
Y
1
0
1
0
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
¬X
1
1
1
0
Z=X!Y
1
1
1
0
¬X [ Y
1
1
1
0
Imply Condition
10
Z=X ⇥ Y Constraint
Given X is binary variable, Y
8
>
>
Z 1
>
<
Z Y
>
>
>
:Z  1
X
X +Y
0
This constraint can be transformed to linear form as
8
>
>
Z  BigM ⇥ X
>
<
Z  Y + BigM ⇥ (1
>
>
>
:Z
Y BigM ⇥ (1
11
X)
X)
Conflicted Condition when Starting and Finishing Time are pa-
rameters
Parameters
sj : starting time of job j
fj : finishing time of job j
Ejm = {0, 1}. Ejm = 1 if job j is possible to be assigned to machine m; otherwise Ejm = 0
Cjk = {0, 1}. Cjk = 1 if job j and job k cannot be assigned to the same machine m due to overlap constraint;
otherwise Cjk = 0
Decision variables
Xjm = {0, 1}. Xjm = 1 if job j is assigned to machine m; otherwise Xjm = 0
Constraints
Ejm Xjm + Ekm Xkm  2 Cjk ,
X
Xjm = 1, 8i
8i, j, m
m
Xjm  Ejm ,
8j, m
Note
In general, we need only consider variables Xjm which having Ejm = 1
Let E be the set which containing tuples of possible assignment < j, m > of job j to machine m
Let C be the set which containing tuples of conflict jobs < j, k > due to overlap
Constraints
X<j,m> + X<k,m>  2 C<j,k> ,
X
X<j,m> = 1, 8j
8 < j, m >, < k, m >2 E, 8 < j, k >2 C
m
Guide to Construct Linear Constraint
Page 6
Ho Chi Minh City International University
Industrial Systems Engineering Department
12
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
Conflicted Condition when Starting and Finishing Times are
Variables
Parameters
Ejm = {0, 1}. Ejm = 1 if job j is possible to be assigned to machine m; otherwise Eim = 0
Variables
sj : starting time of job j
fj : finishing time of job j
Xjm = {0, 1}. Xjm = 1 if job j is assigned to machine m, otherwise Xjm = 0
Rkj = {0, 1}. Rkj = 1 if job k finishes before job j starts, i.e. fk  sj , otherwise Rkj = 0
BigM ⇥ (Rkj
1) + fk  sj
BigM ⇥ Rkj + fk
sj
To avoid the overlap, following constraint is applied
Ejm Xjm + Ekm Xkm  1 + Rkj + Rjk
Xim  Ejm
8j, k, m
8j, m
If both Rkj and Rjk are zero then only one Xjm or Xkm are allowed
13
Another Approach For Handling Conflict Constraint
Index
i: index of job
j: index of job
m: index of machine
Parameters
BigM : Very large number
P roim : be the processing time if job i on machine m
Setkjm : be the setup time of job j on on machine m if job k is an immediate precedence job of job j on
machine m
Enim = {0, 1}. Enim = 1 if job i is able to be assigned to worker w;otherwise Enij = 0
Bm and Fm are two values identify the time window of machine m
Decision Variables
Xim = {0, 1}. Xim = 1 if job i is assigned to machine m; otherwise Xim = 0
Ykj = {0, 1}. Ykj = 1 if job j is the immediate successor job of job k on the same machine, otherwise Ykj = 0
sj starting time of job j
fj finishing time of job j
Guide to Construct Linear Constraint
Page 7
Ho Chi Minh City International University
Industrial Systems Engineering Department
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
Ykj + Yjk  1,
Xjm + Xkm
Yjk  1,
Ykj
Xkm + Xjn + Ykj + Yjk  2,
sj +
M
X
P rojm Xjm = fj ,
m=1
fk +
M
X
Xim Setkjm
Ykj )  sj ,
BigM (1
m=1
14
8k, j
8i, j, m
8j, k, m, n
8j, m
8k, j, m
Absolute Values for Binary Variables
Consider the case
X = |A
B|
where X, A, B are binary variables
X
A
B
X
B
A
X A+B
X2
15
A
B
Piece-wise Linear Constraints
Given several ranges [ai ; bi ] , i = 1...n and decision variable X, Y . If ai  X  bi then Y = fi (X)
Let ri be the index variable if X 2 [ai ; bi ] then ri = 1 otherwise ri = 0.
Basic constraints include:
ai  Xi + BigM ⇥ (1
ri )
Xi  bi + BigM ⇥ (1
Xi  BigM ⇥ ri
I
X
ri = 1,
i=1
Y =
X
i
ri )
8i = 1...I
8i = 1...I
8i = 1...I
ri ⇥ fi (Xi )
8i = 1...I
Using Z = X ⇥ Y constraint the above can be transformed
Y =
X
Zi
i
8i = 1...I
Zi  BigM ⇥ ri
8i = 1...I
Zi  fi (Xi ) + BigM ⇥ (1
ri )
8i = 1...I
BigM ⇥ (1
ri )
8i = 1...I
Zi
fi (Xi )
Guide to Construct Linear Constraint
Page 8
Ho Chi Minh City International University
Industrial Systems Engineering Department
16
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
Belong to The Range Constraints
Let ri be the index variable if Xi 2 [ai ; bi ] then ri = 1 otherwise ri = 0.
ai  Xi + BigM ⇥ (1
Xi  bi + BigM ⇥ (1
ri )
ri )
Xi  BigM ⇥ ri
17
Belong to the range constraint: Discrete case
D departure time
S starting time
p processing time
Ut binary variable, Ut = 1 if t
S, otherwise; Ut = 0
Vt binary variable, Vt = 1 if t  D
1, otherwise; Vt = 0
Rt binary variable, Rt = 1 if S  t  D
1, otherwise; Rt = 0
D
S+p
t
S
BigM ⇥ (1
Ut )
tS
1 + BigM ⇥ Ut
tD
1 + BigM ⇥ (1
t
BigM ⇥ Vt
D
Vt )
Rt  U t
Rt  V t
Rt
18
U t + Vt
1
Other Inference
Given A
0 and ↵ is constant. Assume that the following inferences should be satisfied
If X = 1 then A
↵
If X = 0 then A = 0
These constraints can be expressed as
Another way
8
<A
↵⇥X
:A  BigM ⇥ X
8
<↵
 A + BigM (1
:A  BigM ⇥ X
X)
If Lower Bound and Upper Bound for A can be estimated, i.e. A 2 [LBA ;
↵;
U BA
↵]
In this case the constraints can be rewritten as
8
<(↵ LB ) ⇥ (1
A
:U B ⇥ X
X) + A
A
Guide to Construct Linear Constraint
Page 9
↵
0
A
U BA ] and A
↵ 2 [LBA
Ho Chi Minh City International University
Industrial Systems Engineering Department
Deterministic Models in Operation Research
Lecturer: Phan Nguyen Ky Phuc
In case BigM coefficient can affect the computation time, this analysis can be used to estimate the values
of some BigM
19
Jobs Use Multiple Resources
Given the following data
Table 1: Job Parameters
1
1
0
5
{1,3}
Job
wj
sj
fi
Resources
2
1
4
6
{2,3}
3
2
3
8
{2,3}
4
3
7
12
{1}
Parameters
wj weight of job j
sj starting time of job j
fj finishing time of job j
Ojt parameters, if sj  t  fj then Ojt = 1 otherwise Ojt = 0
Rjs number of resource s using by job j
Ns be the maximum number of resource s
Decision variable
Xj if job j is selected
Mathematical model
max
J
X
w j Xj
j=1
Constraints:
I
X
i=1
Guide to Construct Linear Constraint
Oit ⇥ Ris ⇥ Xi  Ns ,
Page 10
8t, s
5
3
6
10
{3}
Download