Next: , Previous: , Up: Example Programs   [Contents][Index]


7.5 fw-simple

This program demonstrates basic features of the QSMM framework. The program performs interaction of a trainer with a single-node model. The trainer is launched in a separate thread and communicates with the main thread using the Side API. Units of communication are signals.

The model is trained to emit output signal 2 after receiving input signal 0, to emit output signal 1 after receiving input signal 1, and to emit output signal 0 after receiving input signal 2. A training process performed by the trainer thread consists in sending random signal 0, 1, or 2 to the model, receiving a response signal from the model, and making spur increment 1 if the response signal is correct.

The program registers instruction classes ‘sr 0’, ‘sr 1’, and ‘sr 2’ (‘sr’ is an abbreviation for “send/receive”), using which the model emits output signal 0, 1, or 2 to the trainer thread and receives outcome 0, 1, or 2, which is an input signal from the trainer thread.

At the end of its run, the program prints the amount of spur accumulated by the model. The program creates in the current directory file prg with a disassembled program of the node, file mat_goto with a state transition matrix, and file mat_action with an action emission matrix.

If options for tracing model execution are specified in the command line, then the program will create trace log trace in the current directory. If options for tracing data packets exchange are specified in the command line, then the program will create trace log trace_side in the current directory. On first acquaintance with the package, those trace logs can be inspected to understand what kind of information goes there.

The program understands command-line options listed below. For definitions of referenced trace flags of model execution, see Tracing Model Execution. For definitions of referenced trace flags of data packets exchange, see Tracing Exchange of Data Packets.

--deterministic

Generate the most probable deterministic program when disassembling the node.

-i, --seed=INT

A seed to initialize the pseudorandom number generator. A non-negative seed specifies normal behavior of the model. A negative seed specifies random behavior of the model. Default value is 0.

-n, --nstep=INT

The number of modeling steps. At each step, an output signal is emitted, and an input signal is received by the model. Default value is 5000.

-s, --nstate=INT

The number of tracked trainer states. Default value is 6.

--trace-api

Add constant QSMM_TRACE_API to trace flags of model execution.

--trace-ctrl

Add constant QSMM_TRACE_CTRL to trace flags of model execution.

--trace-evt

Add constant QSMM_TRACE_EVT to trace flags of model execution.

--trace-side-api

Add constant QSMM_SIDE_TRACE_API to trace flags of data packets exchange.

--trace-side-msg

Add constant QSMM_SIDE_TRACE_MSG to trace flags of data packets exchange and also dump indices of modeling steps, values of spur at modeling steps, and spur increments in the trace log.

The command make builds the example program if the QSMM package is configured by the configure script to use the POSIX threads API. See the file INSTALL in the root of the package distribution for information on the configure script.

Below there are represented results of sample invocation of the program.

$ ./fw-simple -i1 --deterministic
spur = 2671

$ cat prg
        jmp     L2

        ; State 0 (activations = 933).

L1:     sr      1               ; calls = 933
        joe     0, L3           ; jumps = 91
        joe     2, L4           ; jumps = 81
        jmp     L1              ; jumps = 127

        ; State 2 (activations = 724).

L2:     sr      2               ; calls = 724
        joe     1, L1           ; jumps = 80
        joe     0, L3           ; jumps = 59
        jmp     L4              ; jumps = 121

        ; State 3 (activations = 957).

L3:     sr      2               ; calls = 957
        joe     0, L3           ; jumps = 112
        joe     1, L1           ; jumps = 97

        ; State 5 (activations = 981).

L4:     sr      0               ; calls = 981
        joe     1, L1           ; jumps = 167
        joe     0, L3           ; jumps = 156
        jmp     L4              ; jumps = 176

Next: , Previous: , Up: Example Programs   [Contents][Index]