The Generate C++ option on the toolbar starts the process of generating all files needed to run a simulation independent of the MLDesigner GUI. The simulation will, however, not run externally unless MLDesigner is installed on the machine where you execute the system; a result of the dynamic linking mechanism.
All files are written to "TargetDirectory"/"LibraryName"/"SystemName", where "TargetDirectory" means the content of the equally named property of the Simulation Properties, which is set to $MLD_USER/SYSTEMS per default. Here is a list of the files which are generated from MLD.
Note that "SystemName" stands for the according system name, for example, "butterfly".
File |
Role |
---|---|
SystemName-build |
Script for compiling with a lockfile mechanism, to avoid parallel compilation of the same architecture. |
SystemName-mldstart |
Script used my MLDesigner to start distributed external simulations, do not use it. |
SystemName.params |
parameter file |
SystemName.cpp |
Source code to construct and execute the system. |
ExternAppInit.cpp |
Initialization functions for external tools (e.g., PTcl/PTk, Tcl/Tk) |
makefile |
makefile |
obj/*.$MLDARCH.o |
Object files of the user primitives. |
Before the system can be executed, it must be compiled. In the directory where the files are stored type make, or better, start the script ending with "-build". If compilation is successful, the directory contains serveral more files listed below.
Note that $MLDARCH means the output of "mldarch" on your site.
File |
Role |
---|---|
SystemName |
Script for starting the simulation. |
SystemName.$MLDARCH |
Simulation binary file. |
SystemName.$MLDARCH.o |
Object file generated from SystemName.cpp |
ExternAppInit.$MLDARCH.o |
Object file generated from ExternAppInit.cpp |
As you can see, now there is a file called "SystemName". To give the simulation a try, you can start it by typing "./SystemName". If your system uses X, Tk, Qt or similar primitives, you have to start the simulation with "./SystemName -x", which is the common case. If you are unsure about this, use -x in every case. The file with the extension .param is parsed when the simulation is executed. This file can be edited manually and the simulation can be rerun independent of the MLDesigner GUI. The simulation parameters for each simulation run are stored in a file with the extension .param.* where * indicates a unique simulation number.
The Generate PTcl option on the toolbar opens a dialog where you can create a location to save the .ptcl file in. It is possible to create a new directory and/or change the default name of the ptcl file.
The two files *.params and *.ptcl are generated in the specified location. The *.params file contains the default settings for all visible parameters (parameters that are visible in the Simulation Properties window). After every simulation a *.params.* file is created containing the settings for the simulation. The filename is extended by a unique number indicating the simulation number. This feature means it is possible to execute a number of simulations with different settings while keeping a record of the parameter settings for each simulation. It makes sense to save the results of each simulation with the name extended by the simulation number.
In the MLDesigner Console View activate the Simulation plane or open a new PTcl Shell, there you change to the directory where the files are stored and type:
An MLDesigner PTcl shell makes it possible to execute PTcl simulations independent of the MLDesigner GUI. To execute the simulation type:
$MLD/ptclsh -x Systemname.ptcl
It is also possible to run PTcl simulations in batch mode using the at command followed by the above line.
The .params file can contain a list of numbers separated by semicolons or can be a list of numbers defined using the following syntax:
for -1.0 to 1.0 step 0.1
which would be equivalent to a list of numbers separated by semicolons such as
-1.0; -0.90; -0.80; ....to 1.0.
These values represent the initial particle value per iteration of the relevant Parameter Set. A typical file of a simulation with three parameter sets looks like this:
PARAMETER_SET { GlobalSeed : 1234567890 Parameter1 : for -.10 to 1.0 step 0.1 RunLength : 1000 } PARAMETER_SET { GlobalSeed : 1234567890 Parameter1 : for 2 to 10 step 2 RunLength : 1000 } PARAMETER_SET { GlobalSeed : 1234567890 Parameter1 : 3; 30; 300 RunLength : 1000 }
It is not possible to create new parameters by editing the file: it is only possible to edit the values of parameters in the .params file.
It is possible to execute systems designed under one operating system such as Linux on another operating system such as Windows®, but only if the system DOES NOT contain user-defined primitives.
User-defined primitives that are compiled for external simulation on one system will not be compatible with another operating system. If the system contains user defined primitives they are exported to the $MLD/SYSTEMS directory as object files (.o). The primitive itself is not exported. The simulation can only run if the user-defined primitive has been compiled on the machine where you want to execute the system.
To do this, export the system using the Export Library feature available via the context menu in the Tree View window. For more information on exporting libraries see Export Libraries.
External files are sensitive to MLDesigner environmental variable settings. Changes to the default settings, if made incorrectly, could lead to unsuccessful compilation of external systems.
The environment variables SIM_SYSTEM and SIM_EXTERN are set to the URL of the simulated system and the directory where the code of the external simulation is generated (specified by the Target Parameter property in the Simulation Properties window).