Section: User Commands (1)
Updated: 10 Sep 2001
xfsim - build simulations for xfl-based fuzzy systems
takes a description of a closed-loop system containing one (or more) xfl-based elements and produces a main C source file and a makefile ready to build, run and analyze a simulation of the behavior of this system.
The description of the system allows the definition of:
The variables describing the state of the system and their units and valid ranges.
The behavior of the system, expressed in terms of:
* Fuzzy inference engines derived from xfl.
* C functions.
* Data stored in files.
The output produced when running the simulation.
A set of options which control the building and execution of the simulation.
The result of running
is (by default) a pair of files: A
which (when executed throuhg "make -f") will produce the executable code for the closed-loop simulation, and a
written in C, containing the main function for the simulation code. The simulation is built using
and the C compiler defined by the environment variable FSCCOMPILER (defaults to "cc" if this variable is not set)
Once built, the simulation code accepts the following arguments:
run in debug mode. The program will sequentially print on stdout the message "^Iteration N", where N is the current iteration of the system loop. When the simulation is complete, it will print the message "^Finished at iteration N".
initial values for the system variables. These values can be assigned by calling the simulation executable with as many numerical arguments as variables have been defined. Assignment of values to variables is positional: the first argument is assigned to the first defined variable and so on. To skip the assignment to an specific variable, the numerical value must be substituted by a '-' character. Variables with no specific initial value take the default (the mean of the range assigned in the definition).
In case of any error, the simulation will end (with an exit code of -1) and print on stderr the appropriate message.
- -O opsfile
Defines the operations file to be used when translating the xfl-based inference engines (see
for more details).
Only produce the simulation makefile.
Only produce the simulation main module.
THE DEFINITION FILE
The file containing the simulation definition consists in four separate sections. The beginning of each section is marked with an specific keyword and the end with "%%". The format of each of these sections is as follows:
The variables section
This section is introduced by the keyword "%variables". Each line in this section defines a variable of the closed-loop system and its format is:
Apart from these variables,
defines two variables:
which holds the iteration index in the simulation, and
which holds the simulation time.
The behavior section
This section is introduced by the keyword "%behaviour". Each line in this section defines a call to a procedure defining the behavior of the system. Procedures are called inside the system loop in the same order they are defined. The format of the procedure lines is:
defines the type of procedure. Supported classes are:
An xfl-based fuzzy inference engine, derived from
A direct call to a C function.
Values are directly read from a file. The file is assumed to contain lines with data values separated by blanks or tabs. Each time a
"procedure" is called, a line of values is read and assigned (in positional order) to the variables included as parameters to the call. Lines starting with '#' are ignored.
defines the source file pathname for the procedure. This parameter is optional for classes
class it is mandatory (since it holds the data file pathname).
defines the name to be used when calling the procedure inside the main simulation code. It is mandatory for classes
and is not used for
are the actual parameters passed to the procedure. Only variable names defined in the previous section can be used. Parameters are passed by reference (type (FUZZY *), see below), so any value can be changed inside a procedure.
The output section
This section is introduced by the keyword "%output". Each line in this section defines the format of an output file for the system simulation. Currently,
supports two classes of output modes: a raw output (compatible with the raw "procedure" described for the section above) and a
compatible format. An output specification has the form:
(for the raw output format),
(for using a raw format through standard output) or
(for the gnuplot-compatible format).
are the variables used for output. Only defined variable identifiers can be used.
The options section
This section is introduced by the keyword "%options". Each line in this section contains a keyword identifying an option for the building and execution of the simulation. The rest of the line defines the value of the corresponding option. The settings defined in a line override any other settings for the same option in previous lines. Available options keywords are:
Defines the type for the variables describing the system. Any valid C type identifier can be used as value, since the value of this option is used in a "typedef FUZZY fuzzytype-value" construct. The default value is "double".
Defines the name for the simulation executable (and the main module, which has the same name with a ".c" suffix). Any valid file name can be used as value. The default is
Defines the name for the simulation makefile. Any valid file name can be used as value. The default is
Defines the list of directories used when searching for libraries in the linking stage of the makefile (the -L option of the C compiler). The separator for the different elements in the list is the character ':'. By default, it takes the value of the environment variable FSLIBPATH (empty if not set).
Defines the list of directories used when searching for include files in the compilations made by the makefile (the -I option of the C compiler). The separator for the different elements in the list is the character ':'. By default, it takes the value of the environment variable FSINCPATH (empty if not set).
Defines the libraries to be linked with the simulation executable. The value for this option is of the form: -llib1 -llib2... (as used by the linking command in the makefile). By default, it takes the value of the environment variable FSLIBS (empty if not set).
Defines the options to be passed to the C compiler in all the stages of the simulation building process. Any valid combinations of options accepted by the C compiler can be used. By default, it takes the value of the environment variable FSCCOPS (empty if not set).
Defines a prefix for the output files. This prefix is combined with the variable identifiers, the ouput class identifier and the simulation PID to produce the actual pathname for the output files in each execution. Any valid path component can be used. The default value is
Selects whether, upon the end of the simulation loop, the viewers defined for each output class must be started on each output file. Can take the values 'y' (the default) or 'n'.
The viewers (as defined in the distribution) are:
for raw files, and, for gnuplot, an instance of this program controlled by a specific xterm.
Selects whether output files are to be kept or are written to a system scratch area (defined by the environment variable FSTMPDIR or "/tmp" if not set). Can take the values 'y' (the default) or 'n'.
Defines the simulation tic, i.e., the amount of simulated time corresponding to each iteration of the main loop. Any valid positive real value can be used. The default value is 1.
Defines the unit for the simulation time. Since it is only used for informational purposes in the output files, any string can be used. The default value is "s".
Defines the end condition for the simulation. Any valid C expression returning an integer value and using simulation variables can be used. This expression is used as the controlling condition for a "while" loop in the main module. The default value is "_n < 100".
The section for other source files
While the other sections in the definition file are mandatory (even when they are empty), this section is optional and lists any other source files needed to build the simulation executable. The section starts with the keyword "%othersrc" and each line must contain a valid pathname between double quotes. The usual C compiler conventions are used: source files with the ".c" suffix are compiled and the object produced is linked, while files without the suffix are directly passed to the linker.
Defines the C compiler to be used for building the simulation executable. Defaults to "cc" if not set.
Defines the directory to be used for temporary viewer files, if the
option is not used inside the simulation file. Defaults to "/tmp" if not set.
A colon separated list of directories defining additional places where look for libraries when building the simulation executable.
A colon separated list of directories defining additional places where
look for include files when building the simulation executable.
A list of libraries to be used for building the simulation executable. Libraries must be defined using the C compiler conventions. This is, to use the library
the string "-lX" must be employed.
A list of additional options to be pased to the C compiler when building the simulation executable.
Runtime library used by the simulation code.
A guide to xfl,
Xfuzzy user guide
- THE DEFINITION FILE
- The variables section
- The behavior section
- The output section
- The options section
- The section for other source files
- SEE ALSO