help-glpk
[Top][All Lists]
Advanced

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

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


From: Heinrich Schuchardt
Subject: Re: [Help-glpk] Loading matrix param from Excel table in GLPK
Date: Fri, 10 Mar 2017 21:23:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

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:
>          AGU    CEN
> ITU      5    6
> PMO   7    8
> 
> 
> 
> 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} <traffic_st[i,j] ~ (j)>;
> 
> and I define C2 in .dat file like:
> 
> set C2:=AGU CEN;
> 
> 
> Thank you in advance for your help
> 
> 
> Best regards.
> Rodolfo




reply via email to

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