RE: Output to GMPL data file
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 Envoyé : mardi 27 juillet 2021 20:32 À : help-glpk@gnu.org ; Philippe Jugla Objet : Re: Output to GMPL data file Am 27. Juli 2021 20:06:53 MESZ schrieb Philippe Jugla : >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 >
Re: Output to GMPL data file
Am 27. Juli 2021 20:06:53 MESZ schrieb Philippe Jugla : >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 >
Output to GMPL data file
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’ 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