help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Problems with Connecting GLPK to Excel


From: glpk xypron
Subject: Re: [Help-glpk] Problems with Connecting GLPK to Excel
Date: Mon, 26 Apr 2010 18:52:58 +0200

Hello Aly

> 1. Suppose I only need to read the values in Excel, while the rest are
> zeros, how can that be done?
See example below.

Please, consider of rows or columns have to be generated for the
characeristics combinations that do not exist in your Excel
sheet. E.g. if plant i cannot produce product j in period k
there is no need to define a column for the production quantity
of j in i,k.



> 
> 2. While connecting GLPK (MathProg) to Excel, I have a problem. To best
> understand this problem, please see the attached Excel file.
In the Excel sheet the first row must define the column names
all further rows must contain the field values.

Best regards

Xypron

production.mod
==============

# File name
param f, symbolic;
# Supplier
set S;
# Product
set P;
# Period
set T;
# Characteristics combinations from file
set C, dimen 3;
# Quantity from file
param r{S,P,T};
# Quantity for all characteristics combinations
param q{s in S, p in P, t in T} := 
  if (s,p,t) in C then r[s,p,t] else 0;

# Read quantity
table ti IN 'CSV' f :
  C <- [Supplier,Product,Period], r ~ Quantity;

# Output quantity
display q;

data;
param w := 8;
set S := 1 2 3;
set P := A B C;
set T := 1 2 3 4 5;
end; 


production.csv
==============

Supplier,Product,Period,Quantity
1,A,1,23
1,A,2,8
1,A,3,7
1,A,4,65
2,B,1,1
2,B,2,37
2,B,3,81
2,B,4,9
3,C,1,71
3,C,2,65
3,C,3,81
3,C,4,9

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01




reply via email to

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