The Iterator Tool enables you to:
Usage:Normally the Iterator tool is used with the ITERATOR_GUI as a front-end to this tool. However, the following describes the usage of the Iterator tool by itself, without the GUI, with plain files.
Example 1:SWEEP: velocity 0.0 750.0 50.0 AGGREGATE: 2 Altitude PLOT: (1, 2, Red), Flight Profile, Velocity (kph), Altitude (km) Note-1: Your simulation model should be set-up to exit automatically at the end of each recursion. A simple way to do this based on a time, such as 500.0, is: DELAY( 500.0 ); exit(0); Note-2: You can embed comments within the Iterator script (file: iteration.control) using the squiggly brackets, ex. { comment }. Note-3: You should build your simulation for textual command-line mode operation. No one will be there to press the Run button. To avoid needing to supply the run and quit commands from a script, you can invoke the simulator with the -batch command-line option. This causes the textual simulator to start running immediatly and then exit when there are no further events. Note-4: During the recursions, there is normally much output to the screen. It may be difficult to glean the pertinent items. Fortunately Iterator produces a log file of the input parameter summary and the aggregated results. See iteration.log after running the Iterator to see a condensed summary of the conditions and results. It also shows how to view the graphical results. See iteration.log example for an example output. Note-5: A GUI interface to Iterator exists, called ITERATOR-GUI. It guides you through generating the iteration.control file by pushing buttons, enables invocation of the Iterator by button press, and allows viewing of results through menus and buttons. Start the Iterator-GUI by clicking Tools/Iterator or by typing igui. See ITERATOR-GUI.
Advanced Options:Automatic Design Optimization:You can have the Iterator attempt to optimize your design over a set of parameters subject to your own goal criteria and constraints.
The optimizer is a steepest descent optimizer. It will run your simulation many times to explore the solution space. The quicker your simulation runs, the faster will be the optimization. The optimizer contains several optimization algorithms; each best suited for different system characteristics. For example, some systems exhibit a smooth continuously differentiable performance surface and are completely deterministic. Others have noise and require many observations to observe a trend. Still others are non-differentiable and have disjoint performance functions. Remember that the optimizer knows nothing about your system, other than it's response to control input via your PFOM; I.E. your system is a black box to the optimizer. The optimizer will characterize your system and switch to the best suited algorithm. The number of variables will also affect the convergence rate. Designing a proper PFOM evaluation function is crucial. It should reflect your design goals, constraints, and relative trade-offs for your system. It may take some experimentation, based on feedback from results of the optimizer, to variations in your PFOM function. One hint is that if you have linear performance trade-off surfaces, it is usually useful to use sum of squares PFOM functions (I.E. Least-Squares optimization). This avoids infinite equivalent, and often trivial, solutions by minimizing the importance of a criterion as it gets close to satisfaction, and balances focus of attention on other criteria that may be further from their desired values. In Optimize mode, the Iterator also produces an optimization log file called, optimization.log. You can plot the data in it to see the history of the optimizer's convergence. The first column is the recursion-number. The second column is the PFOM value that resulted at that recursion. The remaining column(s) is (are) the value(s) of the control variable(s) at each recursion. For example, you can plot the PFOM versus recursion-number by: xgraph -pl optimization.log. If you run the optimizer in high verbosity mode (-v on the command-line), your will get much more detailed comments about the optimization, though extra text renders the the log file unplottable.
Reviewing Previously Captured Data:When the Iterator runs, it produces a results table called: results_table.dat You can re-direct the Iterator to re-aggregate or plot a previously captured results_table.dat file by including only PLOT and AGGREGATE commands in your iteration.control file.
Plotting Histograms:To plot histograms, use the HIST keyword in place of the PLOT keyword. A histogram is a frequency versus quantity graph.The relevant parameters are:
Example: HIST 2, 0.0, 250.0, 50, HistogramNote that you will get better averaging with fewer bins, because there will be higher counts within each bin. However, the histgram resolution will drop. Generally the number of histogram bins should be much less than the number of cases run, but it depends on the data and what you are looking to see.
Random Seed:By default, for repeatability of random parameter sequences, Iterator will generate the same sequence each time Iterator is invoked. In other words, it initializes it's random number seed to the same default value. However, you can alter the random seed to generate new sequences by setting a different seed value. Use the SEED keyword, as in:SEED: seed_valueThe seed_value must be an integer. (Relatively prime integers tend to generate better random sequences.)
Then in file testruns.params, have something like:
You can set as many parameters as you wish for each run. The iterator will perform the runs with your specified values.
Alternate Execution Commands:By default, the assumed execution command is:sim.exe << || \n run \n quit \n ||( The << || \n run \n quit \n || directs the the run and quit commands to start and exit the simulation, as input to the simulation prompt. The \n specify carriage returns.) However an alternate method is to invoke your simulation with the -batch option as mentions in Note-3 above. The execution command then becomes: sim.exe -batch
Also, you may add command-line options, or specify other commands, by the RUN: keyword. RUN: sim.exe app.dfg netinfo << || \n run \n quit \n ||If you want to have additional commands run prior and/or after simulation, a clever idea is to wrap the simulation invocation into a script file that also calls the other files. Then have Iterator call your script file via the RUN: keyword. This option actually makes the Iterator general purpose. You can use Iterator to control any program, tool, or utility; not just CSIM simulations! To use on non-CSIM programs, you should understand a little about the inner workings of Iterator. Iterator works by setting the parameter values in a file called top_tab.dat. Specifically, it looks for, and modifies lines of the following format: number <parameter_name> <value>Example: 1 <velocity> <150.0>(The first number is not important to Iterator, but can be used to uniquely enumerate or identify your variables.) If you structure your program to get it's variable values from this format, then you can use Iterator on any program.
Parallel Simulations:An advanced option of the Iterator is the ability to launch parallel simulations on multiple computers and to coordinate the collection of their results. For example, if you have five computers on a shared file system, and you need to run a simulation 100 times while sweeping or randomizing parameters, then Iterator can automatically launch parallel simulations on the five computers such that, each does a unique iteration, results are collected and sorted appropriately, and all computers stay busy until no more iterations are left to run. In this example, each computer would run approximately 20 simulations, and would complete in about 1/5th the time required to run all the iterations on a single computer.Parallel mode is activated by suppling the Hosts: option with a list of available computers to use. Iterator then launches simulations on the computers, as available by:
tar cf simpackage.tar sim.exe *.prog netinfo netinfo.rte This provides you an opportunity to include whatever local files your simulation needs, such as other data, scripts, program files, or subdirectories.
You can also supply a build command with the Build: option.
A typical build command is: csim -nongraphical mymodel.sim The Iterator will generate launch scripts of the form: mkdir /tmp/runzzzzxxxx... Where {path} is the absolute path on the shared file-system where the Iterator is being run from, and xxxx is the iteration number. The zzzz is a unique alpha-numeric string to further ensure unique temporary directory names. Iterator generates the {path}, zzzz, and xxxx strings automatically. Note that Iterator is smart about the SimPackage names, in that it knows to not prepend the pwd if an absolute path was given, and it knows to first gunzip in the case of .tgz or .tar.gz suffix. Note also that Iterator cleans up after itself, by removing the temporary files from the remote system after sending results. Note that "rsh" capability must be available on the host systems to enable remote job invocations. If not, see note below on using ssh. The launch scripts will be launched by: rsh {host} {path}launchxxx.com &. For many cases where parallel simulation is useful, the simulation build-time is much less than the individual run-times, so it is sometimes safer or simpler to copy and re-build the simulation on each machine. However, re-building, or even copying the model/data, are not necessary if appropriate options are used for the run commands. Specifically, the run command must reference the absolute path of the pre-compiled simulation, unless you are doing alternative commands, such as tar'ing a local executable or sourcing a local script. It is important that your run-command not end with an ampersand (&). Otherwise, the iteration coordination and clean-up would begin before the simulation finishes. You may want to direct std.out to /dev/null or a log file to avoid the mixture of confusing output that could come back to your launching window. Below is an example iteration.control file for parallel executions. Example: SWEEP: velocity 0.0 750.0 50.0 AGGREGATE: 2 Altitude PLOT: (1, 2, Red), Flight Profile, Velocity (kph), Altitude (km) SimPackage: simpackage.tar.gz HOSTS: pc1, pc2, pc3, pc4, pc5 RUN: sim.exe -batch > /dev/nullWhile the iterations proceed, the Iterator displays the overall progress. Note that optimization mode is not supported for parallel simulation, due to the inherently sequential evaluation/optimization process. Note that RSH has been depricated on many systems due to security issues and may be turned-off at your site. Instead, use SSH. Add USE_SSH to your iteration.control file. SSH also requires setting up authentication keys to avoid interactive prompting for passwords. Use the following process to generate and install the private and public parts of your authentication keys:
Command-Line Options:The following command-line options can be used with Iterator. From the ITERATOR_GUI, these can be set on the Run Controls menu before invoking the Iterator.
. .
|