bug-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-glpk] lpx_write_cpxlp and lpx_read_cpx_lp are incompatible


From: Bernard Helmstetter
Subject: [Bug-glpk] lpx_write_cpxlp and lpx_read_cpx_lp are incompatible
Date: Mon, 25 Jul 2005 03:00:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

Hi,

There is a problem in the functions lpx_write_cpxlp and lpx_read_cpx_lp. The two operations are not inverses of each other. For instance, when compiling and executing the file cpxlp_bug.c, a linear programming problem is created, is written to disk as "a.cpxlp", then read and written again as "b.cpxlp", and the two files are different.

Also, the program tries to solve the problems with lpx_simplex: the original has a solution, not the modified one.

Perhaps the bound x_1 <= 0 in "a.cpxlp" should have been written -inf <= x_1 <= 0 instead.

I am using GLPK version 4.8.

Regards,

Bernard Helmstetter.

#include <stdio.h>
#include <stdlib.h>
#include "glpk.h"

int main()
{
  LPX *lp;
  int col[1+1];
  double val[1+1];
  
  lp = lpx_create_prob();
  lpx_set_obj_dir(lp, LPX_MIN);
  lpx_add_rows(lp, 1);
  lpx_add_cols(lp, 1);
  lpx_set_row_bnds(lp, 1, LPX_FX, -1, -1);
  lpx_set_col_bnds(lp, 1, LPX_UP, 0, 0);
  lpx_set_obj_coef(lp, 1, 1);
  col[1] = 1;
  val[1] = 1;
  lpx_set_mat_row(lp, 1, 1, col, val);
  
  lpx_simplex(lp);
  
  lpx_write_cpxlp(lp, "a.cpxlp");
  lpx_delete_prob(lp);
  lp = lpx_read_cpxlp("a.cpxlp");
  
  lpx_simplex(lp);
  
  lpx_write_cpxlp(lp, "b.cpxlp");
  lpx_delete_prob(lp);
  
  return 0;
}
\* Problem: Unknown *\

Minimize
 obj: + x_1

Subject To
 r_1: + x_1 = -1

Bounds
 x_1 = 0

End
\* Problem: Unknown *\

Minimize
 obj: + x_1

Subject To
 r_1: + x_1 = -1

Bounds
 x_1 <= 0

End

reply via email to

[Prev in Thread] Current Thread [Next in Thread]