help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] CSV FILES PROBLEM


From: espetegos
Subject: [Help-glpk] CSV FILES PROBLEM
Date: Fri, 17 Apr 2009 12:10:10 +0300

HI 

I got a sample code from the group and try with no succes. i declared the table 
in just after the sets and then i say to read the file but it shows a error

colon missing where expected 
context: set i;set j; set s dimen 2; table Ti

and this is my model
set I;
set J;
set s dimen 2;
table Ti;
param a{i in I};
param b{j in J};
param d{i in I, j in J};
param f;
param c{i in I, j in J} := f * d[i,j] / 1000;
var x{i in I, j in J} >= 0;
table read ti;
minimize cost: sum{i in I, j in J} c[i,j] * x[i,j];
s.t. supply{i in I}: sum{j in J} x[i,j] <= a[i];
s.t. demand{j in J}: sum{i in I} x[i,j] >= b[j];
---------------------------------------------------------------------
data;
:
:
table Ti IN 'csv' 'c:\pruebatab.csv':
s <- [FROM,TO] d~DISTANCE c~COST;
:
end;-- glpk xypron wrote : 
Hello Andrew,

thank You for formalizing the syntax.

In my original message I proposed to put into the model file table declarations 
and the table read and write statements and to put the table definitions into 
the data file. 

This will allow to use the same model with different data sets from separate 
data sources, e.g. first using the model with a small data set from a CSV file 
and then run in with data from an SQL data base by just changing the data file 
and leaving the model untouched.

Could You, please, extend the syntax description to point out, where to place 
the table declarations and definitions.

Best regards

Xypron


example:

File Model.mod
==============
set K dimen 2;
table T1;
table T2;
param p{K} >= 0;
param s;
var c{K} >=0;
table read T1;
maximize obj: sum((i, j) in K) p[i,j] * c[i,j];
s.t. c1: sum((i, j) in K) c[i,j] <= s;
solve;
table write T3;
end;

File Data1.dat
=============
data;
s := 10;
table T1 IN 'CSV' 'dist.csv' :
  K <- [i ~ from, j ~ to] p[i,j];
table T2 OUT 'CSV' 'result.csv' :
  {(i,j) in K} -> [i ~ from, j ~ to], p[i,j];
end;

File Data2.dat
=============
data;
s := 1000;
table T1 IN 
  'iODBC' 'DRIVER=MySQL;DSN=db;UID=glpkuser;PWD=pw' 'prices' :
  K <- [i ~ from, j ~ to] p[i,j];
table T2 OUT 
  'iODBC' 'DRIVER=MySQL;DSN=db;UID=glpkuser;PWD=pw' 'production' :
  {(i,j) in K} -> [i ~ from, j ~ to], p[i,j];
end;



> The syntax of the table statement in BNF is the following:
> 
> *  <table statement> ::= <input table statement>
> *  <table statement> ::= <output table statement>
> *
> *  <input table statement> ::=
> *        table <table name> <alias> IN <string list> :
> *        <input set> [ <column list> ] , <input list> ;
> *  <alias> ::= <empty>
> *  <alias> ::= <string literal>
> *  <string list> ::= <expression 5>
> *  <string list> ::= <string list> <expression 5>
> *  <string list> ::= <string list> , <expression 5>
> *  <input set> ::= <empty>
> *  <input set> ::= <set name> <-
> *  <column list> ::= <column name>
> *  <column list> ::= <column list> , <column name>
> *  <input list> ::= <input item>
> *  <input list> ::= <input list> , <input item>
> *  <input item> ::= <parameter name>
> *  <input item> ::= <parameter name> ~ <column name>
> *
> *  <output table statement> ::=
> *        table <table name> <alias> <domain> OUT <string list> :
> *        <output list> ;
> *  <domain> ::= <indexing expression>
> *  <output list> ::= <output item>
> *  <output list> ::= <output list> , <output item>
> *  <output item> ::= <expression 5>
> *  <output item> ::= <expression 5> ~ <column name>
> 
> Note: <expression 5> is an expression of level 5, which, while not
>       enclosed in parenthesis, syntactically is numeric or symbolic
>       expression.

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehort?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger


_______________________________________________
Help-glpk mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-glpk


--
This message was sent on behalf of address@hidden at openSubscriber.com
http://www.opensubscriber.com/message/address@hidden/8585465.html







reply via email to

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