Re: [Help-glpk] Loading matrix param from Excel table in GLPK

2017-03-10 Thread Heinrich Schuchardt
Hello Rodolfo,

I guess it would be a better idea to format the CSV such that C1 and C2
values go into columns:

ITU,AGU,5
ITU,CEN,6
PMO,AGU,7
PMO,CEN,8

Otherwise use:

set D, dimen 3;
set C2;
set C1 := setof{(i,j,k) in D} i;
param traffic_st{i in C1, j in C2} >=0 :=
  if j = "AGU" then sum{(i,k,l) in D} k else sum{(i,k,l) in D} l;
table t1 IN "CSV" "foo.csv" :
D <- [IDX, AGU, CEN];
display traffic_st;
data;
set C2:=AGU CEN;
end;

with foo.csv:

IDX,AGU,CEN
ITU,5,6
PMO,7,8

Please, be aware that GLPK for Windows 4.61 comes with examples for
using the GLPK library with Visual Basic for Applications (VBA).

Best regards

Heinrich
On 03/10/2017 09:00 PM, Rodolfo Grosso wrote:
> Hi,
> 
> I want to pass matrix values contained in excel file or csv to a
> matrix parameter, for example, Excel table:
>  AGUCEN
> ITU  56
> PMO   78
> 
> 
> 
> So that I can read  through the parameter traffic:
> 
> traffic[ITU,AGU]=5
> traffic[PMO,AGU]=7
> ...
> 
> In the real case there are many values.
> 
> For this, I made the following code, but it did not work:
> 
> set C1;
> set C2;
> param traffic_st{C1,C2} >=0;
> 
> table data IN "CSV" "traffic_st1.csv":
> [i ~ C1], {j in C2} ;
> 
> and I define C2 in .dat file like:
> 
> set C2:=AGU CEN;
> 
> 
> Thank you in advance for your help
> 
> 
> Best regards.
> Rodolfo


___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


Re: [Help-glpk] Loading matrix param from Excel table in GLPK

2017-03-10 Thread Andrew Mason
Rodolfo. SolverStudio (http://solverstudio.org) will do this for you 
automatically and also let's you edit GMPL files and run GLPK from within 
Excel. Might be useful. Andrew

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk


[Help-glpk] Loading matrix param from Excel table in GLPK

2017-03-10 Thread Rodolfo Grosso
Hi,

I want to pass matrix values contained in excel file or csv to a
matrix parameter, for example, Excel table:
 AGUCEN
ITU  56
PMO   78



So that I can read  through the parameter traffic:

traffic[ITU,AGU]=5
traffic[PMO,AGU]=7
...

In the real case there are many values.

For this, I made the following code, but it did not work:

set C1;
set C2;
param traffic_st{C1,C2} >=0;

table data IN "CSV" "traffic_st1.csv":
[i ~ C1], {j in C2} ;

and I define C2 in .dat file like:

set C2:=AGU CEN;


Thank you in advance for your help


Best regards.
Rodolfo

___
Help-glpk mailing list
Help-glpk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-glpk