help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] Testing glpk-4.26-tab


From: vijay patil
Subject: [Help-glpk] Testing glpk-4.26-tab
Date: Fri, 29 Feb 2008 18:32:50 +0530

I downloaded source code tarball from
ftp://glpk.dyndns.org/glpk/glpk-4.26-tab_r119.tar.gz
I briefly tested table feature being added to MathProg. I could run
example transp_mysql.mod successfully.

Following is procedure in case anyone else wants to test the feature
on Windows XP,
using MS Visual Studio. Hopefully following information is also useful
in case someone wants to use .bat files in directory w32 (which comes
with glpk).

Please note, I am referring to glpk source code
glpk-4.26-tab_r119.tar.gz and not official glpk release tarball.
It is assumed that MySQL database installed on your machine.

I. To create glpk static library
--------------------------------
1. Create static library project for glpk library. Add glpk header
files and source files.
2. Add HAVE_MYSQL in pre-processtor definitions.
3. Since code makes call to MySQL C API, we need to specify relevant
header file location,
Example:
Header file location = C:\Program Files\MySQL\MySQL Server 4.1\include

4. Now try compiling the library. You may get following error:
error C2061: syntax error : identifier 'SOCKET'

5. To overcome above compile error add following two lines to file
glpsql02.c, *above* existing line
#include<mysql.h>.

#include<my_global.h>
#include<my_sys.h>
#include<mysql.h>       /* Existing line */

6. Now you should be able successfully compile glpk library.


II. To create glpsol executable.
--------------------------------
1. Create console app project for glpsol. Add examples/glpsol.c as
source file (comes with glpk tarball).
Now glpsol app depends on glpk library and MySQL library (for table
feature). We need to specify
these dependancies.

2. Specify glpk header files location and glpk static library location
(created above). Specify glpk static
library name to which this app will link.

3. Similarly specify MySQL header file location and MySQL static
libraries location (comes with MySQL).

For example:
Header file location = C:\Program Files\MySQL\MySQL Server 4.1\include
Static libraries location = C:\Program Files\MySQL\MySQL Server 4.1\lib\opt

The MySQL libraries to be specified are, in following order:
libmysql.lib mysqlclient.lib zlib.lib

4. Try compiling the application, if successful you are ready to use glpsol exe.

To test table feature I ran glpsol on modified (to change database
related stuff)
examples/transp_mysql.mod, after using part of transp.sql.

Following is the output:

Reading model section from transp_mysql.mod...
Reading data section from transp_mysql.mod...
71 lines were read
Reading plants...
SELECT PLANT, CAPA AS CAPACITY FROM transp_capa
Reading markets...
SELECT MARKET, DEMAND FROM transp_demand
Reading dist...
SELECT LOC1, LOC2, DIST FROM transp_dist
Generating cost...
Generating supply...
Generating demand...
Model has been successfully generated
glp_simplex: original LP has 6 rows, 6 columns, 18 non-zeros
glp_simplex: presolved LP has 5 rows, 6 columns, 12 non-zeros
lpx_adv_basis: size of triangular part = 5
      0:   objval =  0.000000000e+000   infeas =  1.000000000e+000 (0)
      4:   objval =  1.662750000e+002   infeas =  0.000000000e+000 (0)
*     4:   objval =  1.662750000e+002   infeas =  0.000000000e+000 (0)
*     7:   objval =  1.536750000e+002   infeas =  0.000000000e+000 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (138681 bytes)
Writing result...
DELETE FROM transp_result
INSERT INTO transp_result ( LOC1, LOC2, QUANTITY ) VALUES ( ?, ?, ? )
Model has been successfully processed

mysql> select * from transp_result;
+-----------+----------+----------+
| LOC1      | LOC2     | QUANTITY |
+-----------+----------+----------+
| San Diego | New York |      275 |
| San Diego | Topeka   |      275 |
| Seattle   | Chicago  |      300 |
| Seattle   | New York |       50 |
+-----------+----------+----------+
4 rows in set (0.00 sec)


Thanks Andrew and Xypron for work on this feature.

Xypron:
Please refer to section I.5 above. May be those header files are
needed for Windows.

-- 
Vijay Patil




reply via email to

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