I am using CVXOPT to solve a very simple problem:
min -7890424934354.171875*x1 -7890424934354.274414*x2 -7890424934354.246093*x3
s.t:
x1 + x2 + x3 = 1
x1,x2,x3 are binary
We can see that the optimal solution should be obviously:
x1 =0; x2 = 1; x3 = 0
However I didn't get a correct answer using ILP from CVXOPT(I know the above problem is too simple to use ILP, but I am just curious). A detailed description about ILP of CVXOPT is here.
My program is like this:
from cvxopt.glpk import ilp
from cvxopt import matrix
c = matrix([-7890424934354.171875,-7890424934354.274414,-7890424934354.246093],tc='d')
G = matrix(0.0, (1,3)) #since I do not have a constraint like G*x <= h, I make them zeros here
h = matrix(0.0, (1,1))
A = matrix([1,1,1],tc='d')
b = matrix(1,tc='d')
(status, x) = ilp(c,G,h,A.T,b,B=set([0,1,2]))
The result is:
GLPK Integer Optimizer, v4.61
2 rows, 3 columns, 3 non-zeros
3 integer variables, all of which are binary
Preprocessing...
1 row, 3 columns, 3 non-zeros
3 integer variables, all of which are binary
Scaling...
A: min|aij| = 1.000e+00 max|aij| = 1.000e+00 ratio = 1.000e+00
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part is 1
Solving LP relaxation...
GLPK Simplex Optimizer, v4.61
1 row, 3 columns, 3 non-zeros
* 0: obj = -7.890424934e+12 inf = 0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+ 0: mip = not found yet >= -inf (1; 0)
+ 0: >>>>> -7.890424934e+12 >= -7.890424934e+12 0.0% (1; 0)
+ 0: mip = -7.890424934e+12 >= tree is empty 0.0% (0; 1)
INTEGER OPTIMAL SOLUTION FOUND
optimal
[ 0.00e+00]
[ 0.00e+00]
[ 1.00e+00]
which doesn't return the optimal solution.
But if I change my objective function to -171875*x1 - 274414*x2 - 246093 * x3, I can get a correct answer which is x1 = 0, x2 = 1, x3 = 0.
I am really confused why this happen:
I guessed firstly whether floating-point values like -7890424934354.171875 lose precision when passed to ILP, but it seems this is not the reason.
Another guess is that I shouldn't make G and h zeros if I don't have a constraint like G*x <= h. But what should I do if I want to use ILP when G and h are empty since it requires
G: mxn dense or sparse 'd' matrix with m>=1
I'd appreciate any advice. Many thanks in advance.