File formats used by optimization programs.

Formats for min-cost sat

cnf format, extension .cnf

This is based on the cnf format used for satisfiability instances in the Second DIMACS implementation challenge ( http://mat.gsia.cmu.edu/challenge.html ). See, for example, www.cs.ubc.ca/~babic/doc/dimacs_cnf.pdf This format applies when the number of true variables is to be minimized.

cnfx format, extension .cnfx

This is a weighted version of cnf format, where each variable can be assigned a weight (in the unweighted version every weight is 1). All weights are nonnegative integers (fractional numbers can be scaled up and will need to be anyway for the algorithms to work properly).

There are two differences from cnf format:

  1. The tag line is p cnfx VARS CONSTRAINTS
  2. After the tag line and before the list of constraints, there is a list of pairs i1 w1 i2 w2 .... A pair ik wk means that variable ik has weight wk.
    Any variable not appearing among the pairs has weight 0. The list of pairs ends with the pair 0 0.
    Each pair can be on a different line or any number can be on a single line.

lpx format, extension .lpx

This format is used by CPLEX and other linear and integer programming solvers.

There are several fundamental differences between lpx and cnf, since the former needs to address general optimization problems.

A basic expression in lpx format is a linear form, written as a list of variables preceded by coefficients. An example of a linear form is:
-3x1 + 2x2 - x4
which can also be written as
- 3 x1+2 x2 -x4 -- spaces don't matter.

An example showing both cnfx and lpx format

The cnfx format (file sample.cnfx):
c A weighted set cover instance.
c InstanceProfile:  
c   nVars=8, nClauses=5 
c   nLitsPos=5 nLitsNeg=0  nLitsTot=5  ImbalanceOfLits=1   
c 
c Variable weights - x1: 6, x2: 12, x3: 10, x4: 8
c                    x5: 5, x6:  7, x7:  3, x8: 3
p cnfx 8 5 

1 6
2 12
3 10
4 8
5 5
6 7
7 3
8 3
0 0

1 2 4 7  0
1 2 3 5 8  0
2 3 4 6  0
5 7 0
6 8 0
And the corresponding lpx format (created using an automatic conversion program):
\  File sample.lpx, created Wed Jun 06 02:16:47 UTC 2007
\   - created from covering/sat instance sample.cnfx
\  A weighted set cover instance.
\  InstanceProfile:
\  nVars=8, nClauses=5
\  nLitsPos=5 nLitsNeg=0 nLitsTot=5 ImbalanceOfLits=1
\  
\  Variable weights - x1: 6, x2: 12, x3: 10, x4: 8
\  x5: 5, x6: 7, x7: 3, x8: 3
\  5 rows, 8 columns
Min
  obj: +6 x1 +12 x2 +10 x3 +8 x4 +5 x5 +7 x6 +3 x7 +3 x8

st
  c1: +x1 +x2 +x4 +x7 >= 1
  c2: +x1 +x2 +x3 +x5 +x8 >= 1
  c3: +x2 +x3 +x4 +x6 >= 1
  c4: +x5 +x7 >= 1
  c5: +x6 +x8 >= 1
Binary
   x1 x2 x3 x4 x5 x6 x7 x8
End

Matthias F. (Matt) Stallmann, http://people.engr.ncsu.edu/mfms ( Matt_Stallmann AT ncsu.edu)
Last modified: Wed Jun 6 16:09:26 2007