hgourvest / glpk.js

GNU Linear Programming Kit for Javascript
GNU General Public License v2.0
147 stars 22 forks source link

Clique cuts #6

Open kozak opened 7 years ago

kozak commented 7 years ago

Hi, I've got a question about clique cuts and the expected behaviour of glpk.js vs glpk.

Using the glpsol command line utility, the result is:

test master % glpsol -m offer.mod --clique
GLPSOL: GLPK LP/MIP Solver, v4.61
Parameter(s) specified in the command line:
 -m offer.mod --clique
Reading model section from offer.mod...
966 lines were read
Generating ...
Model has been successfully generated
GLPK Integer Optimizer, v4.61
898 rows, 64 columns, 1920 non-zeros
64 integer variables, all of which are binary
Preprocessing...
897 rows, 64 columns, 1856 non-zeros
64 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 897
Solving LP relaxation...
GLPK Simplex Optimizer, v4.61
897 rows, 64 columns, 1856 non-zeros
      0: obj =  -0.000000000e+00 inf =   8.000e+00 (1)
     21: obj =   8.000000000e+00 inf =   0.000e+00 (0)
*   112: obj =   3.200000000e+01 inf =   0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
Clique cuts enabled
Constructing conflict graph...
Conflict graph has 64 + 0 = 64 vertices
+   112: mip =     not found yet <=              +inf        (1; 0)
Cuts on level 0: clq = 12;
Cuts on level 6: clq = 12;
+   263: >>>>>   8.000000000e+00 <=   8.000000000e+00   0.0% (7; 0)
+   263: mip =   8.000000000e+00 <=     tree is empty   0.0% (0; 13)
INTEGER OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 2.0 Mb (2109139 bytes)

when using the glpk.js, with the following settings:

    glpk.glp_scale_prob(lp);
    var smcp = new glpk.SMCP({presolve: glpk.GLP_ON});
    glpk.glp_simplex(lp, smcp);
    var iocp = new glpk.IOCP({
        presolve: glpk.GLP_ON,
        clq_cuts: glpk.GLP_ON
    });
    glpk.glp_intopt(lp, iocp);

I am getting a very different result:

Model has been successfully generated
GLPK Integer Optimizer, v4.49
898 rows, 64 columns, 1920 non-zeros
64 integer variables, all of which are binary
Preprocessing...
897 rows, 64 columns, 1856 non-zeros
64 integer variables, all of which are binary
Scaling...
 A: min|aij| = 1  max|aij| = 1  ratio = 1
Problem data seem to be well scaled
Constructing initial basis...
Size of triangular part = 897
Solving LP relaxation...
GLPK Simplex Optimizer, v4.49
897 rows, 64 columns, 1856 non-zeros
 0: obj = 0  infeas = 8 (0)
*21: obj = 8  infeas = 0 (0)
*110: obj = 32  infeas = 0 (0)
OPTIMAL SOLUTION FOUND
Integer optimization begins...
Clique cuts enabled
Creating the conflict graph...
The conflict graph has 2*64 vertices and 960 edges
+110: mip = not found yet <= +inf  (1; 0)
+199: >>>>> 8 <= 31   287.5% (22; 0)
+8021: mip = 8 <= 19   137.5% (925; 169)
+15011: mip = 8 <= 18   125.0% (1897; 353)
+21823: mip = 8 <= 16   100.0% (2830; 570)
+27829: mip = 8 <= 16   100.0% (3696; 763)
+34634: mip = 8 <= 15   87.5% (4526; 1005)
+40533: mip = 8 <= 15   87.5% (5352; 1238)
+46379: mip = 8 <= 14   75.0% (6175; 1468)
+52400: mip = 8 <= 14   75.0% (6911; 1717)
+58431: mip = 8 <= 14   75.0% (7582; 1998)
+64195: mip = 8 <= 14   75.0% (8254; 2268)
+69699: mip = 8 <= 13   62.5% (8973; 2521)
Time used: 60.003 secs
...

Are clique cuts implemented ? The glpsol version outputs the following conflict graph:

Constructing conflict graph...
Conflict graph has 64 + 0 = 64 vertices
+   112: mip =     not found yet <=              +inf        (1; 0)
Cuts on level 0: clq = 12;
Cuts on level 6: clq = 12;

while glpkjs:

Clique cuts enabled
Creating the conflict graph...
The conflict graph has 2*64 vertices and 960 edges

Notice the different in conflict graph vertices.

Is this a bug or should I pass additional arguments to the glpk.js solver?

Here is the model: offer.mod.zip

Thanks !