RE: Output to GMPL data file

Philippe Jugla <[email protected]> Tue, 27 Jul 2021 21:33:58 +0000
Newsgroups gmane.comp.gnu.glpk
Message-ID <PA4PR09MB4781734A515CF844911146DDF0E99@PA4PR09MB4781.eurprd09.prod.outlook.com>
Hi Heinrich,

Thanks for your help, it works just fine.
Just had a look at the language reference too for the printf statement.

Best regards

Philippe

________________________________
De : Heinrich Schuchardt <[email protected]>
Envoyé : mardi 27 juillet 2021 20:32
À : [email protected] <[email protected]>; Philippe Jugla <[email protected]>
Objet : Re: Output to GMPL data file

Am 27. Juli 2021 20:06:53 MESZ schrieb Philippe Jugla <[email protected]>:
>Hello everyone,
>
>I am looping with a .bat file to run N simulations with glpsol.
>At the end of each simulation, I would like to use the value of a variable which is calculated, as an input for the next simulation.
>What I have written in my .mod file doesn't work because it does not overwrite my storage.dat file after each simulation...
>
>in the .mod file :
>TIME = 0..T-1;
>param initial_storage;
>var storage {t in TIME};
>/* I want to output the final storage value as initial storage for next simulation*/
>printf ‘data; param initial_storage := ‘ & storage[T-1].val & ‘ ;’ >> ‘storage.dat’

Use a single > here.

>> is used to append.

Have a look at print format strings too.

Best regards

Heinrich

>printf ‘end ;’ >> ‘storage.dat’
>
>the .bat file :
>for /l %%k in (1,N,1) do (
>echo solving DAY %%k...
>"%GUSEKPATH%\glpsol.exe" --cuts -m "model.mod" -d "storage.dat" -d "data_%%k.dat"
>)
>
>Is there a way of achieving this ?
>Thank you very much,
>
>Best regards,
>
>Philippe
>