How to use loop to run model several times when some random data is being imported from excel.

Problems with modeling
Post Reply
User avatar
Renger
Posts: 639
Joined: 4 years ago

Re: How to use loop to run model several times when some random data is being imported from excel.

Post by Renger » 2 years ago

Hi
If you want, for example, loop over 10 sets of random data, you could define your data indexed over your loop and read all of them before the loop.

Code: Select all

set 
	iteration /1*10/,
	sectors   /s1*s20/;

parameter randSectors(sectors, iteration) Random data for sectors;

** Pseudo code
* Read your data from Excel organized in a two-dimensional table (sectors * iteration)
**
loop(iteration,
      randData(sectors) = randSectors(sectors, iteration);
      solve mymodel
end;
      
Hope this helps!
Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist

Post Reply