help-glpk
[Top][All Lists]
Advanced

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

[Help-glpk] GLPK/L


From: Braulio Lara
Subject: [Help-glpk] GLPK/L
Date: Fri, 13 Dec 2002 15:32:39 -0200

Hi,
 
I´m Braulio Lara. I´m a brazilian Computer Cientist student and I´m working in a Scientific Initiation Research to study possibilities to integrate models, solvers and database in a Model Managment System or in portuguese - SGM (Sistema Gerenciador de Modelos).
 
This system can manipulate data and models whithout interdependence whith the parts. So I´m trying to develop this using the GLPK/L as the modeling language and the glpsol as the solver in background. The main objective is to extract information of the combination of data, models and solvers in an easy way. It´s a good tool to Decision Suport Systems.
 
The problem is that I have to populate the data by an Oracle database, fill the model structure and solve it in glpsol. But the GLPK/L do not allow to write a model whithout especifying the data to instance it. And it´s necessary to get model and data independent.
 
That´s why I´m writing to you. I´m thinking about a way to solve this problem: we can indicate the sets and parameters in a tag and then in another file we can have all data about the model.
 
Note that if we do like this, we are able to have a lot of instances of the same model with different sorts of data. And the model doesn´t care about witch amount o data is going to be used to solve the problem.
 
I can implement this in a higher level and then a parser can converts the input in glpk/l script. But if I do this I will have another script to describe a Model whitout data that isn´t glpk/l. And it´s not interesting to me to develop another modeling language like GLPK/LX (GLPK Language Extension).
 
What do you think about this? Do you think it´s viable to develop another version of GLPK/L that implements the data separated of the model?
 
See the example below:
 

/* ----------------- The new GLPK/L Script ------------------------*/
 
model transp;
 
sets  I = (<<fabricas>>),
 J = (<<distribuidores>>),
 K = (<<portos>>);
 
parameters a[I], b[K], c[I,J], d[J,K];
 
variables x[I,J], y[J,K];
 
constraints supply[I], dem[K], trans[J], z;
 
a[i] := data (i in I:);
 
b[k] := data (k in K:);
 
c[i,j] := table (i in I, j in J:);
 
d[j,k] := table (j in J, k in K:);
 
supply[i] := sum (j, x[i,j]) <= a[i];
 
dem[k] := sum (j, y[j,k]) >= b[k];
 
trans[j] := sum (i, x[i,j]) = sum (k, y[j,k]);
 
z := sum ((i,j), c[i,j] * x[i,j]) + sum ((j,k), d[j,k] * y[j,k]);
 
minimize z;
 
end;
 

/* ----------------- The data file that populate the parameters ----------*/
 
fabricas = (op, ip, ac, cf);
distribuidores = (co, be, bh);
portos = (tu, sa, ga, rj, fl);
 

a[fabricas] := data:
  op 250
  ip 350
  ac 100
  cf 50);
 
b[portos] := data:
  tu 150
  sa 150
  ga 100
  rj 200
  fl 100);
 
c[fabricas,distribuidores] := table:
   co be bh:
  op 3 2 3
  ip 4 5 6
  ac 7 6 8
  cf 4 1 2);
 
d[distribuidores,portos] := table:
   tu sa ga rj fl:
  co 10 12 11 12 10
  be 11 10 09 08 12
  bh 13 10 11 09 13);
 
/* ---------------------- end of data file -------------------------------- */
 

Then after parsing the input, whe can generate the GLPK/L script:
 
 
 
/* ---------- Original model script --------------------------------------- */
 
model transp;
 
sets  I = (op, ip, ac, cf),
 J = (co, be, bh),
 K = (tu, sa, ga, rj, fl);
 
parameters a[I], b[K], c[I,J], d[J,K];
 
variables x[I,J], y[J,K];
 
constraints supply[I], dem[K], trans[J], z;
 
a[i] := data (i in I:
  op 250
  ip 350
  ac 100
  cf 50);
 
b[k] := data (k in K:
  tu 150
  sa 150
  ga 100
  rj 200
  fl 100);
 
c[i,j] := table (i in I, j in J:
   co be bh:
  op 3 2 3
  ip 4 5 6
  ac 7 6 8
  cf 4 1 2);
 
d[j,k] := table (j in J, k in K:
   tu sa ga rj fl:
  co 10 12 11 12 10
  be 11 10 09 08 12
  bh 13 10 11 09 13);
 
supply[i] := sum (j, x[i,j]) <= a[i];
 
dem[k] := sum (j, y[j,k]) >= b[k];
 
trans[j] := sum (i, x[i,j]) = sum (k, y[j,k]);
 
z := sum ((i,j), c[i,j] * x[i,j]) + sum ((j,k), d[j,k] * y[j,k]);
 
minimize z;
 
end;
 

/* --------------------------------------------------------------------------------- */
 

The AMPL language implements things like this but I prefer to work whith free-software.
 
Please write me back an sugestion, what do you think about this and what can we do to sofisticate the GLPK/L.
 
Thank´s for reading my e-mail and I´m waiting for your reply.
 
Good Bye,
 
Braulio Alves Silva Lara
 
Centro Universitário Uni-BH
Curso de Ciência da Computação
Programa de Iniciação Científica - GPTEX
Belo Horizonte - Minas Gerais - Brazil
 
 
 
 

reply via email to

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