Page 1 of 1

Running incremental optimizations

Posted: Sat Oct 04, 2014 5:25 pm
by linear feedback
I want to run sequential optimizations while monitoring the progress. E.g. run the optimizer n times, evaluate the best solution and if not good enough let the optimizer run another n times. I have come up with this:

SIMULATE>RUNNAME|opt
do
MENU>RUN_OPTIMZE
Analyse the opt.out file: if ok -> exit else
SIMULATE>RESUME|1|0
SIMULATE>BASED|opt.out
loop

This loads the best found solution as a base line but unfortunately the same Random-numbers are used for the next RUN, e.g. the same results are generated again... Is there a way to continue the optimization with the next n random iterations?

Re: Running incremental optimizations

Posted: Mon Oct 06, 2014 8:19 am
by Administrator
This loads the best found solution as a base line but unfortunately the same Random-numbers are used for the next RUN, e.g. the same results are generated again... Is there a way to continue the optimization with the next n random iterations?
I cannot think of a way of doing it. The random number streams will be reinitialized, I cannot think of a way around that.

You could use the GET TIME VALUE function to get a system time and use that as the random number seed. But this would give you a different stream every time you run the simulation.
http://www.vensim.com/documentation/ind ... _value.htm

Re: Running incremental optimizations

Posted: Mon Oct 06, 2014 5:45 pm
by linear feedback
Thanks - will do. Alas, it would be nice if there were a condition which would make Vensim always use a different seed when beginning an optimization. So I have to edit the voc file. The underlying reason for this request is that I cannot provide Vensim with a time limit for the calibration so I want to initiate brief runs until either the solution converges or time runs out.

Re: Running incremental optimizations

Posted: Tue Oct 07, 2014 5:24 pm
by tomfid
it would be nice if there were a condition which would make Vensim always use a different seed when beginning an optimization
There is - set the :SEED to 0.

Re: Running incremental optimizations

Posted: Tue Oct 07, 2014 5:35 pm
by tomfid
I think you don't want RESUME; that resumes at a time. http://www.vensim.com/documentation/25345.htm

Instead you can either use BASED|previousrun.vdf or READCIN|previousrun.out (BASED expects a vdf and is probably simpler if there are other change inputs; otherwise you'd have to use READCIN/ADDCIN to replicate the whole cascade of changes each time).

This should work, but there is a penalty. The Powell algorithm starts by searching each parameter axis individually, but as it progresses, it replaces parameter vectors with improved directions from the initial passes. Each time you restart, you lose the direction set information. This may not be a big problem though.

Tom

Re: Running incremental optimizations

Posted: Wed Oct 08, 2014 7:35 pm
by linear feedback
Many thanks, Tom, this is very helpful.

The seed=0 might be made more explicit in the documentation - at least I never figured that one.

Re: Running incremental optimizations

Posted: Thu Oct 09, 2014 10:27 pm
by tomfid
SEED=0 is new, with the new random number generator in 6.3.
http://www.vensim.com/documentation/opt ... htsub=seed

Note that random number stream IDs and NOISE SEED within a model behave differently.
http://www.vensim.com/documentation/noi ... htsub=seed