Professional Documents
Culture Documents
01 Formulations For The TSP With AMPL
01 Formulations For The TSP With AMPL
01 Formulations For The TSP With AMPL
2
41.0
3
53.0
25.8
4
5
62.9 106.3
17.1 69.6
31.9 67.3
53.9
6
86.2
60.8
72.3
44.2
37.0
7
78.2
48.2
57.9
31.2
32.5
14.5
8
74.5
46.6
58.6
29.9
37.6
14.3
5.1
This is all the data you need to solve the problem exactly.
The problem is easy to describe, but very hard to solve exactly.
A graphical display is on the next page.
9
47.7
36.4
59.3
28.8
67.0
39.5
35.0
30.2
90
60
7
North
30
9
30
East
60
90
i = teacher, j = course.
cij = value if teacher i is assigned to course j.
xij = 1 if teacher i is assigned to course j, else 0.
1) Max i j cijxij subject to
2) j xij = 1, for all i,
3) i xij = 1, for all j,
4) xij {0,1}, for all i,j.
10
We have subtours.
3
8
7
4
5
2n
subtour constraints.
3
The Dantzig, Fulkerson & Johnson (DFJ) model.
Indices, parameters, & decision variables as before.
2
Minimise total cost:
min ij cij xij ,
Enter each city once:
i xij = 1 for all j.
4
Leave each city once:
j xij = 1 for all i.
Subtour breaking constraints: i,jS xij |S| 1, for every subset S.
Binary integrality:
xij {0, 1} for all i, j.
For the subtour shown, add: x3,2 + x2,4 + x4,3 2. What are the others?
After solving again with the new constraints, more subtours appear.
For a large TSP, we may need many subtour breaking constraints.
In the worst case, we may need 2n subtour breaking constraints.
Next week, we will see a way to generate these constraints.
The solution becomes fractional, so we also need to do B&B.
However, every solution gives a lower bound on the optimum.
11
12
3
2
13
:= [*,*] :
2
3
4
26 40 34
.
64 61
64 .
3
61 3
.
59 5
3
78 8
10
54 10 8
47 15 13
50 24 26
29 30 28
28 33 30
33 39 35
5
35
59
5
3
.
13
5
10
29
25
28
33
6
48
78
8
10
13
.
18
23
16
38
39
33
7
30
54
10
8
5
18
.
5
34
20
23
28
8
23
47
15
13
10
23
5
.
38
15
18
23
9
48
50
24
26
29
16
34
38
.
23
21
16
10
17
29
30
28
25
38
20
15
23
.
3
8
11
20
28
33
30
28
39
23
18
21
3
.
5
12:=
29
33
39
35
33
33
28
23
16
8
5
.;
14
AMPL solution
u[1] u[4] u[12] u[6] u[2] u[11] u[9] u[3] u[7] u[10] u[5] u[8]
0
1
2
3
4
5
6
7
8
9
10
11
1,4 4,12 12,6 6,2 2,11 11,9 9,3 3,7 7,10 10,5 5,8 8,1
15
16
1
$3
$3
Indices:
i, j = city.
9
Parameter: cij = cost to go from city i to city j.
Variables: xij = 1 if we drive from city i to city j, else 0,
defined only for i<j. Half as many variables as the asymmetric!
Minimise total cost:
Enter each city once:
Subtour breaking:
Binary integrality:
1 $8
$3
9
The variables into city 5 are: x15, x25, x35, x45, x65, x75, x85, x95.
The variables out of city 5 are: x51, x52, x53, x54, x56, x57, x58, x59.
Since costs are symmetric, cij = cji, let's drop half the variables.
For xij, require i < j. Allow only the variables going out.
We need only variables x15, x25, x35, x45, x56, x57, x58, x59.
The meaning is not Go in or come out, but use this arc.
The summation makes sure that we cover only the variables we need.
x15 + x25 + x35 + x45 + x56 + x57 + x58 + x59 = 2.
17
18
subject to
subject to
sum {(i,j)
subject to
subject to
y3,6
1.05
x3,6
19
AMPL solution
y2,1
1.11
x2,1
20
21
AMPL solution
12,9,6