Difference between revisions of "Adding an example"

From SUMOwiki
Line 1: Line 1:
  +
This page explains how to add your own data/simulation code/... to the toolbox to model it.
  +
  +
== Project directories ==
  +
  +
Since version 6.0 every example (and all related files) is self contained in a project directory. See <code>examples/</code> for a list of examples and associated project directories. You can use one of them as an example for how to add your own.
  +
 
== Simulator file ==
 
== Simulator file ==
   
If you want to create a surrogate model (metamodel) for your own problem you will first have to write a [[simulator]] xml file.To do this simply open one of the existing simulator xml files (in the <code>examples/</code> subdirectory) and create a copy of it in the same directory but under a new name.
+
If you want to create a surrogate model (metamodel) for your own problem you will first have to write a [[simulator]] xml file. Again, use one of the exsiting simulator xml files (from on of the examples) as a guide. The simulator xml file should have the same name and capitalization as the project directory (except for the .xml extension). (also see the [[Simulator configuration]] page.
Note, since version 6.0 each simulator resides in its own project directory in <code>examples/</code>. To create a new simulator you can copy one of the existing project directories (e.g. Academic2D) in the same directory but under a new name. Make sure the simulator configuration inside the project directory has the same name as the project directory itself (except for the .xml extension).
 
   
 
You can then edit this file to suit your particular problem. This file should be pretty straightforward to write.
 
You can then edit this file to suit your particular problem. This file should be pretty straightforward to write.
Your simulator XML file may specify different implementations:
 
* an executable or script (<Executable> tag)
 
* a Java class (<Executable> tag, platform = java)
 
* a Matlab script (<Executable> tag, platform = matlab)
 
* a dataset
 
** scattered data (<ScatteredDataFile> tag)
 
** gridded data, data lies on a regular grid (<GriddedDataFile>)
 
   
 
'''For versions < 6.0:'''
 
'''For versions < 6.0:'''
 
Datasets should be placed in <code>examples/data/txt</code>.
 
Datasets should be placed in <code>examples/data/txt</code>.
 
In case of doubt about which dataset to use, use 'ScatteredDataFile'.
 
In case of doubt about which dataset to use, use 'ScatteredDataFile'.
 
 
Matlab scripts should be placed in <code>src/matlab/examples</code>.
 
Matlab scripts should be placed in <code>src/matlab/examples</code>.
   
Line 24: Line 21:
 
For an explanation of the data format and how the toolbox interfaces with the [[simulator]], see the [[Interfacing with the toolbox]] page.
 
For an explanation of the data format and how the toolbox interfaces with the [[simulator]], see the [[Interfacing with the toolbox]] page.
   
Having written your simulator XML file and provided the datasets/executables you now just need to change <code>default.xml</code> so it uses your file (<Simulator> tag). Finally you just run '<code>go</code>'.
+
Having written your simulator XML file and provided the datasets/executables you now just need to change <code>default.xml</code> so it uses your problem (<Simulator> tag). Finally you just run '<code>go</code>'. In version 5.0 of the toolbox you would just use the name of the simulator configuration file, for version 6.0 you must specify the project directory name (can be an absolute path or a directory name inside the toolbox path).
In version 5.0 of the toolbox you would just use the name of the simulator configuration file, for version 6.0 you must specify the project directory.
 
   
 
Note that, depending on whether your simulator is a script, native executable, dataset or Matlab script you will need to set different [[Config:SampleEvaluator| sample evaluator]] configuration options. For example, if your data comes from a dataset you will have to set the sample evaluator to [[Config:SampleEvaluator#scattered| scattered]] or [[Config:SampleEvaluator#gridded| gridded]], depending if you data points are scattered or on a regular grid.
 
Note that, depending on whether your simulator is a script, native executable, dataset or Matlab script you will need to set different [[Config:SampleEvaluator| sample evaluator]] configuration options. For example, if your data comes from a dataset you will have to set the sample evaluator to [[Config:SampleEvaluator#scattered| scattered]] or [[Config:SampleEvaluator#gridded| gridded]], depending if you data points are scattered or on a regular grid.

Revision as of 14:54, 25 July 2008

This page explains how to add your own data/simulation code/... to the toolbox to model it.

Project directories

Since version 6.0 every example (and all related files) is self contained in a project directory. See examples/ for a list of examples and associated project directories. You can use one of them as an example for how to add your own.

Simulator file

If you want to create a surrogate model (metamodel) for your own problem you will first have to write a simulator xml file. Again, use one of the exsiting simulator xml files (from on of the examples) as a guide. The simulator xml file should have the same name and capitalization as the project directory (except for the .xml extension). (also see the Simulator configuration page.

You can then edit this file to suit your particular problem. This file should be pretty straightforward to write.

For versions < 6.0: Datasets should be placed in examples/data/txt. In case of doubt about which dataset to use, use 'ScatteredDataFile'. Matlab scripts should be placed in src/matlab/examples.

For version 6.0: You can just copy the Datasets, matlab scripts, extra files in the project directory you created in the steps above.

For an explanation of the data format and how the toolbox interfaces with the simulator, see the Interfacing with the toolbox page.

Having written your simulator XML file and provided the datasets/executables you now just need to change default.xml so it uses your problem (<Simulator> tag). Finally you just run 'go'. In version 5.0 of the toolbox you would just use the name of the simulator configuration file, for version 6.0 you must specify the project directory name (can be an absolute path or a directory name inside the toolbox path).

Note that, depending on whether your simulator is a script, native executable, dataset or Matlab script you will need to set different sample evaluator configuration options. For example, if your data comes from a dataset you will have to set the sample evaluator to scattered or gridded, depending if you data points are scattered or on a regular grid. If on the other hand your data comes from a native executable you would want to use the local sample evaluator with the simulatorType set to "external" (you can also set the type to "java" if your executable is a java class). For Matlab scripts the sample evaluator to use is matlab.