[Top][All Lists]

[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

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;
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;
  system("glpsol -m " modfile " -d " datfile);

Run the script with

awk -f test.awk

Windows users can find a binary for awk at
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


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

reply via email to

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