Constraint__Integer_programming
Constraint__Integer_programming
Constraint Programming
In this method, we first model the problem and use the help of
ortools library to solve it.
The following is how we model and implement the code:
(1) Firstly, we set variables for our problem:
x [ i , j ] =1 , means thebus move ¿ point i¿ point j ( x [ i , j ] =0 otherwise ) ∀ i , j∈[0 , 2 n]
u [ i ] =l, means the load of bus after leaving point i isl with l∈ [ 1 , k ] , ∀ i ∈[1 , n]
u [ i ] =l, means the load of bus after leaving point i isl with l∈ [ 0 , k−1 ] , ∀ i∈[n+1 , 2 n]
index [ i ] =p ,means the order of visiting point iis p with p ∈ [ 1 , 2n ] , ∀ i∈[1, 2 n]
Constraint 4: can not return to point 0 from a pick up point and can not move to a
drop point from start point
x [ i , 0 ] =x [ 0 , i+n ] =0 ∀ i∈[1 , n]
Constraint 5: index of a pickup point < index of its corresponding drop point
index [ i+ n ] >index [ i ] ∀ i ∈[1 , n]
{ M ( 1−x [ i, j ]) +u [ i ] −u [ j ] ≥−1 ∀ i∈ [ 0 ,2 n ] , j ∈ [ 1 ,n ]
M ( 1−x [ i, j ]) +u [ j ] −u [ i ] ≥ 1
{ M ( 1−x [ i, j ] ) +u [ i ] −u [ j ] ≥ 1 ∀ i∈ [ 1 , 2 n ] , j∈ [ n+1 ,2 n ]
M ( 1−x [ i, j ] ) +u [ j ]−u [ i ] ≥−1
x [ i , 0 ] =x [ 0 , i+n ] =0 ∀ i∈ [ 1, n ]
index [ i+ n ] −index [ i ] −h ≥ 0 ∀ i ∈ [ 1 ,n ] ;(h ∈ N , h ≥1 is a slack variable )
{ M ( 1−x [ i, j ]) +index [ i ] −index [ j ] ≥−1 ∀ i ∈ [ 1 ,2 n ] , j∈ [ 1 ,2 n ]
M ( 1−x [ i, j ]) +index [ j ]−index [ i ] ≥ 1
(3) And finally, the objective function:
2n 2n
Total=∑ ∑ x [ i, j ]∗distance [ i , j ] if i≠ j
i=0 j=0