Hello,

If I construct a matrix for a problem to feed glp_simplex() and run,
[code]
  glp_smcp parm;
  glp_init_smcp(&parm);
  int retval = glp_simplex(lp, &parm);
  double *x = calloc(vectorSize(data)+1, sizeof(double));
  double z = glp_get_obj_val(lp);
  fprintf(stdout, "\nZ=%lf\n", z);
[/code]
I get the following:

GLPK Simplex Optimizer 5.0
15 rows, 17 columns, 33 non-zeros
      0: obj =   0.000000000e+00 inf =   1.168e+03 (4)
     13: obj =   2.720000000e+01 inf =   1.743e+02 (1)
LP HAS NO PRIMAL FEASIBLE SOLUTION
Z=27.200000

But if I use the same matrix information to generate a CPLEX format file
and run $ glpsol --lp  cplex.lp -o out, I get:

GLPSOL--GLPK LP/MIP Solver 5.0
Reading problem data from 'cplex.lp'...
15 rows, 17 columns, 33 non-zeros
36 lines were read
GLPK Simplex Optimizer 5.0
15 rows, 17 columns, 33 non-zeros
Preprocessing...
1 row, 2 columns, 2 non-zeros
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  8.218e+02  ratio =  8.218e+02
GM: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
EQ: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Constructing initial basis...
Size of triangular part is 1
*     0: obj =   1.714000000e+02 inf =   0.000e+00 (1)
*     1: obj =   2.720000000e+01 inf =   0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.0 Mb (40400 bytes)
Writing basic solution to 'out'...

And the optimal solution is Z=27.2

I suppose I am missing something in the call to glp_simplex(), but what?

This is the CPLEX format:

MINIMIZE Z :  + x11 + x12 + x13 + x14
SUBJECT TO
  r1 : + 821.800000 x1 + 821.800000 x2 + 821.800000 x9 = 821.800000
  r2 : + 174.300000 x3 + 174.300000 x4 + 174.300000 x10 = 174.300000
  r3 : + 27.200000 x5 + 27.200000 x6 = 27.200000
  r4 : + 144.200000 x7 + 144.200000 x8 = 144.200000
  r5 : + 821.800000 x1 + 174.300000 x3 - 27.200000 x5 - 144.200000 x7 +
1.000000 x11 + 1.000000 x13 - 1.000000 x16 = 0.000000
  r6 : + 821.800000 x2 + 174.300000 x4 - 27.200000 x6 - 144.200000 x8 +
1.000000 x12 + 1.000000 x14 - 1.000000 x17 = 0.000000
  r7 : - 28.000000 x3 >= 0.000000
  r8 : - 40.000000 x4 >= 0.000000
  r9 : - 7.200000 x7 >= 0.000000
  r10 : - 34.700000 x11 >= 0.000000
  r11 : - 46.700000 x12 >= 0.000000
  r12 : - 0.165000 x1 >= 0.000000
  r13 : - 0.232000 x3 >= 0.000000
  r14 : - 0.067000 x4 >= 0.000000
  r15 : - 0.016000 x6 >= 0.000000
BOUNDS
 0 <= x1 <= 1
 0 <= x2 <= 1
 0 <= x3 <= 1
 0 <= x4 <= 1
 0 <= x5 <= 1
 0 <= x6 <= 1
 0 <= x7 <= 1
 0 <= x8 <= 1
 0 <= x9 <= 1
 0 <= x10 <= 1
 0 <= x11
 0 <= x12
 0 <= x13
 0 <= x14
 0 <= x15
 0 <= x16
 0 <= x17
END

And this is the matrix information from which the CPLEX format is
constructed:
\* GLPK matrix:
\* ia[1]=1, ja[1]=1, ra[1]=821.800000
\* ia[2]=1, ja[2]=2, ra[2]=821.800000
\* ia[3]=1, ja[3]=9, ra[3]=821.800000
\* ia[4]=2, ja[4]=3, ra[4]=174.300000
\* ia[5]=2, ja[5]=4, ra[5]=174.300000
\* ia[6]=2, ja[6]=10, ra[6]=174.300000
\* ia[7]=3, ja[7]=5, ra[7]=27.200000
\* ia[8]=3, ja[8]=6, ra[8]=27.200000
\* ia[9]=4, ja[9]=7, ra[9]=144.200000
\* ia[10]=4, ja[10]=8, ra[10]=144.200000
\* ia[11]=5, ja[11]=15, ra[11]=0.000000
\* ia[12]=5, ja[12]=1, ra[12]=821.800000
\* ia[13]=5, ja[13]=3, ra[13]=174.300000
\* ia[14]=5, ja[14]=11, ra[14]=1.000000
\* ia[15]=5, ja[15]=13, ra[15]=1.000000
\* ia[16]=5, ja[16]=5, ra[16]=-27.200000
\* ia[17]=5, ja[17]=7, ra[17]=-144.200000
\* ia[18]=5, ja[18]=16, ra[18]=-1.000000
\* ia[19]=6, ja[19]=2, ra[19]=821.800000
\* ia[20]=6, ja[20]=4, ra[20]=174.300000
\* ia[21]=6, ja[21]=12, ra[21]=1.000000
\* ia[22]=6, ja[22]=14, ra[22]=1.000000
\* ia[23]=6, ja[23]=6, ra[23]=-27.200000
\* ia[24]=6, ja[24]=8, ra[24]=-144.200000
\* ia[25]=6, ja[25]=17, ra[25]=-1.000000
\* ia[26]=7, ja[26]=3, ra[26]=-28.000000
\* ia[27]=8, ja[27]=4, ra[27]=-40.000000
\* ia[28]=9, ja[28]=7, ra[28]=-7.200000
\* ia[29]=10, ja[29]=11, ra[29]=-34.700000
\* ia[30]=11, ja[30]=12, ra[30]=-46.700000
\* ia[31]=12, ja[31]=1, ra[31]=-0.165000
\* ia[32]=13, ja[32]=3, ra[32]=-0.232000
\* ia[33]=14, ja[33]=4, ra[33]=-0.067000
\* ia[34]=15, ja[34]=6, ra[34]=-0.016000

What am I missing in the glp_simplex call?  Or maybe I should just stick
with creating the cplex format and do an execlp()?

Any clues are warmly appreciated.




-- 
------------------------------------------------------------------------------------
Dr. Edscott Wilson Garcia
Reservoir Engineering
Mexican Petroleum Institute

Reply via email to