Computing the facets of the Knapsack Polytope using lrs

Example: 9x1 + 8x2 + 6x3 + 6x4 + 5x5 <= 14,   x1,...,x5 binary

The files below can be found here. Other examples are here.

1. Create an H-representation of the LP-relaxation and store in lp.ine.
(Note: in lrs the inequality ax <= b is stored as b - ax >=b )
mune% cat lp.ine

*9x1 + 8x2 + 6x3 + 6x4 + 5x5 <= 14
H-representation
nonnegative
begin
6 6 integer
14 -9 -8 -6 -6 -5
1 -1 0 0 0 0
1 0 -1 0 0 0
1 0 0 -1 0 0
1 0 0 0 -1 0
1 0 0 0 0 -1
end

2. Run lrs to get the V-representation of the LP-relaxation


mune% lrs lp.ine lp.ext

*lrs:lrslib v.4.2c, 2009.12.2(32bit,lrsmp.h)
*Copyright (C) 1995,2009, David Avis avis@cs.mcgill.ca
*Input taken from file lp.ine
*Output sent to file lp.ext

mune% cat lp.ext

V-representation
begin
***** 6 rational
1 0 0 0 0 0
1 1 0 0 0 0
1 1 5/8 0 0 0
1 1 0 5/6 0 0
1 1 0 0 5/6 0
1 0 1 0 0 0
1 2/3 1 0 0 0
1 0 0 1 0 0
1 8/9 0 1 0 0
1 0 1 1 0 0
1 0 0 0 1 0
1 8/9 0 0 1 0
1 0 1 0 1 0
1 0 0 1 1 0
1 2/9 0 1 1 0
1 0 1/4 1 1 0
1 0 0 1 1 2/5
1 0 0 0 0 1
1 1 0 0 0 1
1 0 1 0 0 1
1 1/9 1 0 0 1
1 0 1 1/6 0 1
1 0 1 0 1/6 1
1 0 0 1 0 1
1 1/3 0 1 0 1
1 0 3/8 1 0 1
1 0 0 1 1/2 1
1 0 0 0 1 1
1 1/3 0 0 1 1
1 0 3/8 0 1 1
1 0 0 1/2 1 1
end
*Totals: vertices=31 rays=0 bases=40 integer_vertices=13
*lrs:lrslib v.4.2c, 2009.12.2(32bit,lrsmp.h) max digits=8/100
*0.000u 0.000s 0Kb 0 flts 0 swaps 8 blks-in 8 blks-out

3. Extract the 13 integer vertices and save in a file int.ext

mune% cat int.ext

*9x1 + 8x2 + 6x3 + 6x4 + 5x5 <= 14
V-representation
begin
13 6 rational
1 0 0 0 0 0
1 1 0 0 0 0
1 0 1 0 0 0
1 0 0 1 0 0
1 0 1 1 0 0
1 0 0 0 1 0
1 0 1 0 1 0
1 0 0 1 1 0
1 0 0 0 0 1
1 1 0 0 0 1
1 0 1 0 0 1
1 0 0 1 0 1
1 0 0 0 1 1
end

4. Compute the H-representation of the integer points.

mune% lrs int.ext

*lrs:lrslib v.4.2c, 2009.12.2(32bit,lrsmp.h)
*Copyright (C) 1995,2009, David Avis avis@cs.mcgill.ca
*Input taken from file int.ext
H-representation
begin
***** 6 rational
0 1 0 0 0 0
0 0 1 0 0 0
2 -1 -1 -1 -1 -1
1 0 0 0 0 -1
0 0 0 1 0 0
1 -1 0 0 -1 0
0 0 0 0 0 1
2 -2 -1 -1 -1 0
1 -1 -1 0 0 0
0 0 0 0 1 0
1 -1 0 -1 0 0
end
*Volume= 17/120
*Totals: facets=11 bases=17
*lrs:lrslib v.4.2c, 2009.12.2(32bit,lrsmp.h) max digits=8/100
*0.000u 0.000s 0Kb 0 flts 0 swaps 0 blks-in 0 blks-out

5. These are the facets of the knapsack polytope:

x1 >= 0 , x2 >= 0, x1 +x2+x3+x4+x5 <= 2, etc.