Problem in unloading results over a loop into excel spreadsheet (GDXXRW)

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Problem in unloading results over a loop into excel spreadsheet (GDXXRW)

Post by Archiver »


I am currently running my model in GAMS to get the results. I have a simple problem that could not find any solution for that yet. I need to run my model 500 times over a loop and unload the outputs in an excel spreadsheet but in different rows. is there is any way to solve this issue?


For example:


Sets

Parameters

Travel_Time ‘Random time’

Equations

…


Model Test /all/


For (i= 1 to 500,

Travel_time (k) = Uniform(10,100)

Solve test using MIP Maximising TC

Execute_unload “ Result.gdx” X

execute ‘gdxxrw.exe Result.gdx var=X rng=”Sheet1!A2’

);


Is it possible to dynamically change the row number "A2" or the sheet number in the excel range in each run so that the I can have all the 500 different outputs in one spreadsheet?


Thank you very much for your time and help in advance.

--
To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.
Archiver
User
User
Posts: 7876
Joined: 7 years ago

Re: Problem in unloading results over a loop into excel spreadsheet (GDXXRW)

Post by Archiver »


Hi Sean,

The put_utlity allows to manipulate strings which are executed during a loop, see:
http://www.gams.com/help/topic/gams.doc ... 2_1_15_0_2

Find attached "trnsport_.gms", a modified version of the GAMS Model Library example transport. The example shows two ways to write to a Excel Spreadsheets and I hope this helps you to solve the issue. "Result.xlsx" is written during the loop execution and "Report.xlsx" is written after the loop has finished.

To open, write and close a Excel Spreadsheet 500 times will take some time. To save time, you could write the results into parameters and, then, after the loop has finnished, write the paramter into a Excel Spreadsheet. This allows you to structure, as well as, filter the data that is written to the Excel Spreadsheet. Note that, GDXXRW can not write to a Excel Workbook that is open, unless you share it. Writing to a shared Workbook is slow.

I hope this helps,
Toni

On Monday, February 1, 2016 at 8:17:58 AM UTC+1, Sean wrote:

I am currently running my model in GAMS to get the results. I have a simple problem that could not find any solution for that yet. I need to run my model 500 times over a loop and unload the outputs in an excel spreadsheet but in different rows. is there is any way to solve this issue?


For example:


Sets

Parameters

Travel_Time ‘Random time’

Equations

…


Model Test /all/


For (i= 1 to 500,

Travel_time (k) = Uniform(10,100)

Solve test using MIP Maximising TC

Execute_unload “ Result.gdx” X

execute ‘gdxxrw.exe Result.gdx var=X rng=”Sheet1!A2’

);


Is it possible to dynamically change the row number "A2" or the sheet number in the excel range in each run so that the I can have all the 500 different outputs in one spreadsheet?


Thank you very much for your time and help in advance.

--
Attachments
trnsport_.gms
(1.94 KiB) Downloaded 362 times
Post Reply