execute_load all parameters with wildcard or similar

Problems with syntax of GAMS
Post Reply
pecenak21
User
User
Posts: 24
Joined: 5 years ago

execute_load all parameters with wildcard or similar

Post by pecenak21 »

Hello,

I have a code which runs a nested loop. The inner loop keeps updating and recording data, while the outer loop needs to reset *all* values each time before starting the inner loop. I was planning to use execute_unload and execute_load for this, but am having trouble getting it to work. Some pseudocode to explain what I am trying.

Code: Select all

*set up all default data
parameter x /0/; 
execute_unload 'defaultData.gdx'
loop(i,
	execute_load 'defaultData.gdx' *;
    loop(j,
         *manipulate parameters
              x=x+j
              Objective=E=f(i,j)
              solve model min Objective
         )
)
The key is that the execute_load needs to overwrite *all* values (parameters included) to their default, at each instance of the outer loop. However, the execute_load statements seems to need to point to specific names, and can't just load all values. I have over 900 parameters alone in my model, and can't possibly type them all in. Also, as the model grows, it could become tedious to continue to update the pointing.

Is there anyway to accomplish this? To reset all values (parameters, variables, equations) back to their default values, without needing to explicitly point to them? For example, is there a wildcard option (*) like shown in the example? Any help is appreciatted.
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: execute_load all parameters with wildcard or similar

Post by Renger »

Hi
THe only thing I can think of is starting the outer loop before the assignments of the default values. In your simple example:

Code: Select all

*set up all default data
parameter x;
loop(i,  
    x = 0;
    loop(j,
         *manipulate parameters
              x=x+j
              Objective=E=f(i,j)
              solve model min Objective
         )
)
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Post Reply