Hello Marcello, it seems that in your MySQL 5.1 client library the flag NUM_FLAG is not set for the column shifts.
Please, run mysql -u _your_user_ -p --column-type-info and report the result of SELECT * FROM shifts; See http://bugs.mysql.com/bug.php?id=42980 http://dev.mysql.com/doc/refman/5.1/en/c-api-data-structures.html An alternative test for a numeric column is: if (IS_NUM(field->type)) printf("Field is numeric\n"); Please, download the GLPK source from ftp://ftp.gnu.org/gnu/glpk/glpk-4.44.tar.gz and apply the following patch: --- glpk-4.44/src/glpsql.c 2010-09-05 09:02:46.000000000 +0000 +++ glpk-4.44_NUM/src/glpsql.c 2010-09-05 09:05:53.000000000 +0000 @@ -1511,7 +1511,7 @@ len = 255; strncpy(buf, (const char *) row[i-1], len); buf[len] = 0x00; - if (0 != (fields[i-1].flags & NUM_FLAG)) + if (IS_NUM(fields[i-1].type)) { strspx(buf); /* remove spaces*/ if (str2num(buf, &num) != 0) { xprintf("'%s' cannot be converted to a number.\n", buf); Please, also apply the following patch which addresses a problem with SQL statements split over multiple lines --- glpk-4.44/src/glpsql.c 2010-06-03 08:00:00.000000000 +0000 +++ glpk-4.44-sql/src/glpsql.c 2010-07-16 20:32:07.000000000 +0000 @@ -117,9 +117,10 @@ arg = mpl_tab_get_arg(dca, j); len = strlen(arg); lentot += len; + lentot++; if (arg[len-1] == ';' || j == narg) { /* Join arguments for a single SQL statement */ - sqllines[i] = xmalloc(lentot+1); + sqllines[i] = xmalloc(lentot); sqllines[i+1] = NULL; sqllines[i][0] = 0x00; for (j1 = j0; j1 <= j; j1++) Please, build GLPK again and report if this fixes your problem. Best regards Xypron -------- Original-Nachricht -------- > Datum: Sat, 4 Sep 2010 22:16:47 -0300 > Betreff: Re: [Help-glpk] Error: requires numeric data. > Hello Xypron, > > $ echo $LANG > pt_BR.UTF-8 > > But I tested changed to C, en_US.UTF-8 and not worked. > > $ glpsol -m nurse.mod > GLPSOL: GLPK LP/MIP Solver, v4.43 > Parameter(s) specified in the command line: > -m nurse.mod > Reading model section from nurse.mod... > 20 lines were read > Reading shifts_cost... > SELECT id,cost FROM shifts > Display statement at line 19 > I: > (1,'1.000') > (2,'1.200') > (3,'1.300') > Model has been successfully generated > GLPK Simplex Optimizer, v4.43 > 0 rows, 0 columns, 0 non-zeros > ~ 0: obj = 0.000000000e+00 infeas = 0.000e+00 > OPTIMAL SOLUTION FOUND > Time used: 0.0 secs > Memory used: 0.1 Mb (70106 bytes) > > Thanks for you agility. > > On Sat, Sep 4, 2010 at 22:01, glpk xypron <[email protected]> wrote: > > Hello Marcello, > > > > please, run the following: > > > > set I, dimen 2; > > table shifts_cost IN "MySQL" 'Database=nsp;UID=nsp;PWD=nurseproblem' > > 'SELECT id,cost FROM shifts' : > > I <- [id, cost]; > > display I; > > end; > > > > and send the result. > > > > What is the output of system command locale? > > > > Best regards > > > > Xypron > > > > > > -------- Original-Nachricht -------- > >> Datum: Sat, 4 Sep 2010 20:53:14 -0300 > >> Betreff: Re: [Help-glpk] Error: requires numeric data. > > > >> Hello Xypron, > >> > >> mysql> desc shifts; > >> > +-------------------+------------------+------+-----+---------+----------------+ > >> | Field | Type | Null | Key | > Default | Extra > >> | > >> > +-------------------+------------------+------+-----+---------+----------------+ > >> | id | int(11) unsigned | NO | PRI | NULL > | > >> auto_increment | > >> | shift | varchar(100) | YES | | > | > >> | > >> | duration_in_hours | tinyint(4) | NO | | NULL | > >> | > >> | cost | double | YES | | > NULL | > >> | > >> > +-------------------+------------------+------+-----+---------+----------------+ > >> 4 rows in set (0.00 sec) > >> > >> mysql> select * from shifts; > >> +----+--------+-------------------+------------------+ > >> | id | shift | duration_in_hours | cost | > >> +----+--------+-------------------+------------------+ > >> | 1 | turno1 | 8 | 1 | > >> | 2 | turno2 | 8 | 1.20000004768372 | > >> | 3 | turno3 | 8 | 1.29999995231628 | > >> +----+--------+-------------------+------------------+ > >> 3 rows in set (0.00 sec) > >> > >> $ mysql --version > >> mysql Ver 14.14 Distrib 5.1.49, for debian-linux-gnu (i486) using > >> readline 6.1 > >> > >> $ dpkg -l|grep mysql > >> ii libaprutil1-dbd-mysql 1.3.9+dfsg-3 The Apache Portable > Runtime > >> Utility Library - MySQL Dri > >> ii libdbd-mysql-perl 4.016-1 Perl5 database interface to the > MySQL > >> database > >> ii libmysql-ruby 2.8.2-1 MySQL module for Ruby > >> ii libmysql-ruby1.8 2.8.2-1 MySQL module for Ruby 1.8 > >> ii libmysqlclient15-dev 5.0.51a-24+lenny2 MySQL database > development > >> files > >> ii libmysqlclient15off 5.0.51a-24+lenny2 MySQL database client > >> library > >> ii libmysqlclient16 5.1.49-1 MySQL database client library > >> ii libqt4-sql-mysql 4:4.6.3-1 Qt 4 MySQL database driver > >> ii mysql-client-5.1 5.1.49-1 MySQL database client binaries > >> ii mysql-common 5.1.49-1 MySQL database common files, e.g. > >> /etc/mysql/my.cnf > >> ii mysql-server 5.1.49-1 MySQL database server (metapackage > >> depending on the lat > >> ii mysql-server-5.1 5.1.49-1 MySQL database server binaries and > >> system database setu > >> ii mysql-server-core-5.1 5.1.49-1 MySQL database server > binaries > >> ii php5-mysql 5.3.2-2 MySQL module for php5 > >> > >> $ glpsol -m nurse.mod > >> GLPSOL: GLPK LP/MIP Solver, v4.43 > >> Parameter(s) specified in the command line: > >> -m nurse.mod > >> Reading model section from nurse.mod... > >> Reading data section from nurse.mod... > >> 30 lines were read > >> Reading shifts_cost... > >> SELECT shift, cost FROM shifts > >> nurse.mod:12: Shifts_cost requires numeric data > >> MathProg model processing error > >> > >> I was careful to restart mysql, do not you think that strange? > >> I await your advice. > >> > >> Thanks. > >> > >> On Sat, Sep 4, 2010 at 19:01, glpk xypron <[email protected]> wrote: > >> > Hello Marcello, > >> > > >> > your examples runs fine, when I use the following to create the > >> > MySQL table: > >> > > >> > USE nsp; > >> > > >> > DROP TABLE IF EXISTS shifts; > >> > > >> > CREATE TABLE shifts ( > >> > id INT, > >> > cost DOUBLE, > >> > PRIMARY KEY ( id ) > >> > ); > >> > > >> > INSERT INTO shifts ( id, cost ) VALUES > >> > ( 1, 1. ), > >> > ( 2, 2. ), > >> > ( 3, 4.3 ); > >> > > >> > > >> > Please, check the definition of column cost in > >> > your MySQL table using one of the following commands: > >> > > >> > SHOW CREATE TABLE shifts; > >> > DESCRIBE shifts; > >> > > >> > Best regards > >> > > >> > Xypron > >> > > >> > -------- Original-Nachricht -------- > >> >> Datum: Sat, 4 Sep 2010 15:27:18 -0300 > >> >> Betreff: [Help-glpk] Error: requires numeric data. > >> > > >> >> Hello, > >> >> > >> >> Looking in my bare bone model, see this error down, can you help me? > >> >> > >> >> $ glpsol -m nurse.mod > >> >> GLPSOL: GLPK LP/MIP Solver, v4.43 > >> >> Parameter(s) specified in the command line: > >> >> -m nurse.mod > >> >> Reading model section from nurse.mod... > >> >> Reading data section from nurse.mod... > >> >> 32 lines were read > >> >> Reading shifts_cost... > >> >> SELECT id,cost FROM shifts > >> >> nurse.mod:14: Shifts_cost requires numeric data > >> >> MathProg model processing error > >> >> > >> >> /* nurse.mod - Solve simple NSP - Nurse Scneduling Problem > >> >> /*** Variables ***/ > >> >> set SHIFTS; > >> >> > >> >> /*** Parameters ***/ > >> >> /* Custo por turno */ > >> >> param Shifts_cost{i in SHIFTS}; > >> >> table shifts_cost IN "MySQL" 'Database=nsp;UID=nsp;PWD=nurseproblem' > >> >> 'SELECT id,cost FROM shifts' : SHIFTS <- [id], Shifts_cost~cost; > >> >> > >> >> param Time_work >= 0; > >> >> > >> >> /*** solve section ***/ > >> >> solve; > >> >> for {i in SHIFTS} > >> >> { > >> >> printf "%d",Shifts_cost[i]; > >> >> printf "\n"; > >> >> } > >> >> > >> >> /*** data section ***/ > >> >> data; > >> >> > >> >> #param Shifts_cost := 1 1, 2 2, 3 4.3; > >> >> end; > >> >> > >> >> -- > >> >> Marcello Henrique > >> > > >> > -- > >> > GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 > >> Euro/mtl.!* > >> > http://portal.gmx.net/de/go/dsl > >> > > >> > >> > >> > >> -- > >> Marcello Henrique > >> Blog - http://faraohh.wordpress.com > >> Associação Software Livre de Goiás (www.aslgo.org.br) > >> Cercomp - UFG (www.cercomp.ufg.br) > >> > >> _______________________________________________ > >> Help-glpk mailing list > >> [email protected] > >> http://lists.gnu.org/mailman/listinfo/help-glpk > > > > -- > > GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 > Euro/mtl.!* > > http://portal.gmx.net/de/go/dsl > > > > > > -- > Marcello Henrique > Blog - http://faraohh.wordpress.com > Associação Software Livre de Goiás (www.aslgo.org.br) > Cercomp - UFG (www.cercomp.ufg.br) -- GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl _______________________________________________ Help-glpk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-glpk
