Saving simulation results

You may wish to write the simulation results to a file where you can analyze the data later or use the data as input for other software tools. There are a number of ways to do this.

To demonstrate the various possibilities to save simulation results the statistics demo is a good example. It is located at MLD Libraries→DE→Demo. The MLD_Libraries directory is, however, write protected so you must first copy the system to your own library folder. There you will be able to edit certain parameters. Right-click on the item in the Tree View and select Save As to create a copy of statistics in your library. Open the copy and proceed as follows:

  1. Click on the Printer#1 primitive in the Model Editor window. The Property Editor will display the Instance Properties for the primitive.
  2. Click in the Parameter field fileName and click the folder icon to open the directory explorer.
  3. Select a directory to which you have write permissions and type a name for the file. The file will be created automatically if it does not exist.
  4. Run the system to write the results to the file.

Similarily you can save the results of an XGraph to a file. In this case two files are saved. One contains a list of coordinates the other the options needed to invoke the pxgraph with. Proceed as follows:

  1. Click on the Xgraph#1 primitive in the Model Editor window. The Property Editor will display the Instance Properties for the primitive.
  2. Click in the Parameter field saveFile and click the folder icon to open the directory explorer.
  3. Select a directory to which you have write permissions and type a name for the file. For example $MLD_USER/statistics.
  4. $MLD_USER/statistics and $MLD_USER/statistics.pxgo will be created.
  5. Run the system to write the results to the file.

To open the simulation results dumped to a file, select the instance that produced the output file, then right-click on its parameter of type filename in the Property Editor window and choose Open.

It is possible to use the simulation and iteration number in the expression that defines the filename to generate distinct files for different simulations/iterations. If the filename is given by a parameter, you can specify an expression that combines the simulation and iteration number, e.g.:

$MLD_USER/results.$absSimul.$absIter.txt
$MLD_USER/results_${SIMNO}_${SIMIT}.txt

If the filename is generated in the primitive’s code, during initialization or when the wrapup method is called, you can use the environment variables in conjunction with expandPathName function:

char* tFileName = expandPathName("results.$SIMNO.$SIMIT");
// open and write to file
delete [] tFileName;


Also you can use in your code the static methods of the SimControl class:

SimControl::getCurParamSet()
SimControl::getAbsSimul()
SimControl::getAbsIter()
SimControl::getCurIter()