help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Parametric studies in GMPL?


From: glpk xypron
Subject: Re: [Help-glpk] Parametric studies in GMPL?
Date: Fri, 09 Jul 2010 21:36:35 +0200

Hello Jeffy,

you can use a shell script.

Here is a minimalistic example. Save the following as file test.awk

BEGIN {
modfile = "test.mod";
datfile = "test.dat";
system("rm " modfile);
printf ("Writing model file\n");
printf ("#model file\n") > modfile;
printf ("param iter;\n") > modfile;
printf ("solve;\n") > modfile;
printf ("display iter;\n") > modfile;
printf ("end;\n") > modfile;
close(modfile);
for (i = 1; i <= 10; i++) {
  system("rm " datfile);
  printf("\n\nIteration %i\n",i);
  printf ("Writing data file\n");
  printf("#data file %i\n", i) > datfile;
  printf("data;\n") > datfile;
  printf("param iter := %i;\n", i) > datfile;
  printf("end;\n") > datfile;
  close(datfile);
  system("glpsol -m " modfile " -d " datfile);
  }
exit;
}


Run the script with

awk -f test.awk

Windows users can find a binary for awk at 
http://gnuwin32.sourceforge.net/packages/gawk.htm
For Windows replace "rm " by "del ".

Please, observe that glpsol allows multiple data files,
so you could have one with the changing parameter and another
with the rest of your model data.

Best regards

Xypron

-------- Original-Nachricht --------
> Datum: Fri, 9 Jul 2010 09:15:19 -0400
> Betreff: [Help-glpk] Parametric studies in GMPL?

> Hi --
> 
> I'd like to be able to parametric studies in GMPL.  In other words, do a
> simple loop over a range of parameter values with the solve statement
> inside
> the loop.  To the best of my knowledge this is not currently possible, or
> is
> it?  If not, could this be a feature that could be incorporated into GMPL
> at
> some point?
> 
> Jeff

-- 
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]