Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
tutorial:dinamica_ego_script_language_and_console_launcher [2013/07/30 02:06] juliana |
tutorial:dinamica_ego_script_language_and_console_launcher [2026/07/06 20:00] (current) hermann |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Dinamica EGO script language and console launcher ===== | + | ===== Dinamica EGO script language and command line tool ===== |
| ==== What will you learn? ==== | ==== What will you learn? ==== | ||
| - | * Naming variables with alias | + | * Naming functors with aliases |
| - | * Dinamica EGO programming language | + | * [[:EGO Script|Dinamica EGO programming language]] |
| - | * Dinamica EGO Console launcher | + | * Dinamica EGO Command Line Tool |
| - | As a model becomes more and more complex, you may find useful to save it in EGO format to keep developing the model using EGO programming language on a text editor, (e.g. NotePad++ or Contex)t. | + | As a model becomes more and more complex, you may find useful to save it in EGO format to keep developing the model using [[:EGO Script|EGO programming language]] on a text editor, (e.g. [[http://notepad-plus-plus.org/|NotePad++]] or [[http://www.contexteditor.org|Context]]). For example, the Amazon logging model [[http://dx.doi.org/10.1007/s00267-009-9337-1|(Merry et al, 2009)]] developed in Dinamica EGO involves more than one thousand script lines. Both script formats ([[:XML Script|EGOML/XML]], [[:EGO Script|EGO]]) are 100% compatible, so users can move a model freely between the graphical interface and a text editor. Note that reopening a saved script in the graphical interface and saving it again may reformat some inputs and outputs according to the current script generation options — the resulting model is semantically equivalent, but may not be byte-for-byte identical to the original. Advanced modelers will greatly benefit from this well structured and tractable programming language. |
| - | For example, the Amazon logging model (Merry et al., 2009) developed in Dinamica EGO involves more than one thousand script lines. Both script formats (XML, EGO) are 100% compatible, so users can take back and forth a model from the graphical interface to the text editor without losing any information. Advanced modelers will greatly benefit from this well structured and tractable programming language. | + | Open again the model "simulate_deforestation_from_1997_2000_30years_ahead.xml". To make the model more intelligible on the text editor, you first need to name some key functors with aliases and then add comments to parts of the model. Let's do this. Select the Edit Functor tool and click on the Categorical Map "23267_1997.ers". |
| - | <note tip>**TIP**: EGO format is also a good way to merge two models, since you can cut and paste parts of scripts.</note> | + | Write in the alias field "initial_landscape", click on //Calc Distance Map// and write the alias "distance_to_deforested". Now save the model in EGO format. |
| - | Open again the model “simulate_deforestation_from_1997_2000_30years_ahead.xml”. To make the model more intelligible on the text editor, you first need to name some key variables and then add comments to parts of the model. Let’s do this. Select the Edit Functor tool and click on the Categorical Map “23267_1997.ers”. | + | Open in a text editor, the model "simulate_deforestation_from_1997_2000_30years_ahead.ego". The EGO script is as follows: |
| - | + | ||
| - | Write in the alias field “initial_landscape”, click on //Calc Distance Map// and write the alias “distance_to_deforested”. Now save the model in EGO format. | + | |
| - | + | ||
| - | Open in a text editor (preferentially one that highlights the script in C++ format, e.g. Notepad++, available on http://notepad-plus.sourceforge.net) the model “simulate_deforestation_from_1997_2000_30years_ahead.ego”. The EGO script is as follows: | + | |
| {{ :tutorial:script_1.1.jpg |}} | {{ :tutorial:script_1.1.jpg |}} | ||
| Line 26: | Line 22: | ||
| {{ :tutorial:script_4.1.jpg |}} | {{ :tutorial:script_4.1.jpg |}} | ||
| - | Now that you have learned a bit about programming with EGO script language, another resource available in Dinamica EGO is the Console Launcher. Any model saved in Dinamica EGO, either XML or EGO, can be run from the command prompt. Running the model from the command prompt increases model performance, as the model becomes free of the burden of the graphical interface. In addition, from the command prompt, Dinamica EGO takes advantage of multiprocessor architecture, either splitting execution pipelines on different processors or running several functors’ internal algorithms using parallel processing. Therefore, execution becomes much faster. Depending on the amount of data loaded in the memory, it is also possible to disable disk swapping. | + | Now that you have learned a bit about programming with EGO script language, another resource available in Dinamica EGO is the Command Line Tool. Any model saved in Dinamica EGO, either EGOML/XML or EGO, can be run from the command prompt. Running the model from the command prompt might increase model performance, as the model becomes free of the burden of the graphical interface. |
| - | <note tip>**TIP**: Windows 32 bits only handles up to 3 gigabytes of memory for a single process.</note> | + | To run Dinamica EGO from the command line, run ''DinamicaConsole'' from a command prompt. The executable is located in the Dinamica EGO installation folder. On Windows, the executable name includes the major version number: ''DinamicaConsole7'', ''DinamicaConsole8'', etc. On Linux, the executable is simply ''DinamicaConsole''. For the full list of parameters accepted by the Command Line Tool, see [[:dinamica_console|Dinamica Console]]. |
| - | To facilitate running a model from the command prompt, we have developed a Console Launcher tool. Its use is strongly advised for complex models and others with large amount of data. Also, Console Launcher allows for queuing models and running them sequentially Call the Console Launcher from the tools subfolder in the Start/Programs/Dinamica EGO shortcut. It will open the following interface. | + | <note tip>**TIP**: another way to loosely couple other computer programs with Dinamica EGO is by means of functor [[:Run External Process]], available in the Control Tab. By using this functor, you will be able to make a call to an external program from within Dinamica, pass to this program intermediate results and feed its output back again into the Dinamica EGO model.</note> |
| - | {{ :tutorial:script_9.jpg |}} | + | [[tutorial:final_remarks| Next Session]] |
| - | <WRAP center round box 60%> | ||
| - | Some parameters of Console Launcher are: | ||
| - | |||
| - | -Model: name of the model | ||
| - | |||
| - | -Scheduler: how the model functors are going be sequenced | ||
| - | |||
| - | -Verifier: Type of script verification | ||
| - | |||
| - | -Log Level: Maximum level of log report | ||
| - | |||
| - | -Use Predefined seed: Check it to use a predefined seed to generate random numbers | ||
| - | |||
| - | -Processors: number of processors that model will use ( Use 0 to automatically detect the number available) | ||
| - | |||
| - | -Run Model: Check it to run model completely | ||
| - | </WRAP> | ||
| - | |||
| - | You can save the Console Launcher configuration into a batch file too. This is useful in case you want to couple Dinamica EGO with other software. | ||
| - | |||
| - | <note tip>**TIP**: another way to loosely couple other computer programs with Dinamica EGO is by means of functor Run External Process, available in the Control Tab. By using this functor, you will be able to make a call to an external program from within Dinamica, pass to this program intermediate results and feed its output back again into the Dinamica EGO model. </note> | ||
| - | |||
| - | [[tutorial:final_remarks| Next Session]] | ||