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


7.2 apsamp

This program uses a pair of actors that investigates a state model represented in Figure 7.1. The first actor of the pair guesses current state of the state model. The second actor of the pair emits signals to the state model on the basis of current states guessed by the first actor.

The state model contains 10 states, shown in the figure by circles with state indices inside them. The first actor of the pair works with two spur types, where spur type 0 corresponds to the automatic spur, and spur type 1 corresponds to user spur. The second actor of the pair works only with user spur. The goal of the operation of the pair of actors is to maximize the velocity of increment of user spur.

Arrows represent allowed state transitions. The thick arrow indicates a transition, during which the pair of actors receives user spur increment +1. A number before a slash shown near every arrow indicates a signal that can be emitted to the state model, and which makes the model perform the state transition. A number after a slash shown near every arrow indicates a signal the state model emits to the pair of actors when performing the state transition. If the state model receives from the pair of actors a signal, for which no state transition exists, then current state of the model will be left unchanged, and signal 0 will be emitted to the pair of actors.

As it could be seen from the figure, the optimal behavior of the pair of actors would be continuous emitting sequence of output signals <7, 4, 6, 7>, which gives user spur increment +1.

Sample state model investigated by the pair of actors

Figure 7.1: Sample state model investigated by the pair of actors

Unfortunately, the sample state model is too simple and permits guessing the optimal sequence of output signals to emit even without analyzing input signals received from the state model. However, you may experiment with other state models by modifying matrices trans_mat, emiss_mat, and spur_mat hard-coded in the program source text.

The macro NSTEP (that has value 40000) defines the number of steps of interaction of the pair of actors with the state model equal to the number of signals emitted to the state model and to the number of signals received from the state model. At the end of its run, the example program prints the amount of user spur accumulated by the pair of actors.

A random seed can be specified by a program argument. If the random seed is non-negative, then the pair of actors will operate normally. If the random seed is negative, then the pair of actors will generate output signals completely randomly. You could compare the accumulated values of user spur for these two modes of program execution.

The example program can be built for various schemes of using a pair of actors. To build the program for a selected scheme, delete executable and object files of the program if they exist, and run command

make name_of_executable_of_program_apsamp AP_MODE=name_of_scheme

in directory samples. The supported names of schemes are: ‘S1_S1’, ‘S1_S3’, ‘S1_L3’, ‘S3_S1’, ‘S3_S3’, ‘S3_L3’, ‘L3_L3’. For example, the command might look like this: make apsamp AP_MODE=L3_L3. If a scheme is not specified when building the program, then default scheme ‘S1_S1’ will be used.

The schemes are encoded in the following way. The first letter and digit denote parameters of the first actor of the pair. The second letter and digit denote parameters of the second actor of the pair. Letter ‘S’ denotes a small actor, and letter ‘L’ denotes a large actor. Digit 1 denotes the type of relative probability function similar to QSMM_RELPROB_BUILTIN1 used by an actor. Digit 3 denotes type of relative probability the function QSMM_RELPROB_BUILTIN3 used by an actor. The name of the scheme also defines other parameters of the actors.

Here is given the output of the example program built for scheme ‘S1_S1’.

$ ./apsamp -1
spur = 373
$ ./apsamp 1
spur = 2236

Results of invocation of the example program in the normal mode of operation using each of the supported schemes and random seeds in the range 1 to 20, and in the completely random mode of operation using seeds in the range -20 to -1 are represented in the table below. Negative seeds for the completely random mode of operation are negated values of the ‘SEED’ column. The ‘RAND’ column contains values of user spur accumulated in the completely random mode of operation.

  SEED RAND S1_S1 S1_S3 S1_L3 S3_S1 S3_S3 S3_L3 L3_L3
------ ---- ----- ----- ----- ----- ----- ----- -----
     1  373  2236  3854  4259  1022   824  1872  1735
     2  380   823   900  1867     6   385  3254     5   
     3  397  1120     3  2473    46  1120  5452  2289
     4  366  1071   638  3604  1130   713  3502  2266
     5  411  1787  1451  3569  2253  3074  5210  1444
     6  446  3493  3050  1758  5266  2224  5527  5487
     7  430  1295  1940  1780  1882  1656  5169   311 
     8  387  3236  4513  1704  2532  4299  2320     3   
     9  351     4     2  3214  1501  4085  2071  1141
    10  402  1262  3677     1  2181  3039     3   932  
    11  407  3547  1427  1264  1147  1665  2331  1742
    12  428  2925  2650  1173  4013  3777  6665  1608
    13  402  2710  2329  5059   304  3037  6356    15  
    14  384  3233  3575  3962  1010  1122  2309  1085
    15  407  1962  1616  5921  3049  4168  3919   953 
    16  388  1082  2502  2786  5591  1453   719   270 
    17  378  2153  1937  1739  2040  2355  3714  2587
    18  420  1294  1314   697  4813  5828  6463  1472
    19  416     1    39  1454     2  1819  3358   738 
    20  392  4681  1633  8205  1691  4489  2666  2216
------ ---- ----- ----- ----- ----- ----- ----- -----
   AVG  398  1996  1952  2824  2074  2557  3644  1415
STDDEV   23  1251  1321  1966  1707  1511  1919  1254
 % EFR  100   502   490   710   521   642   916   356

The ‘AVG’ and ‘STDDEV’ rows contain arithmetic means and standard deviation of column values located above. The ‘% EFR’ row contains values in the ‘AVG’ row multiplied by 100 and divided by the value of a cell at the intersection of the ‘AVG’ row and the ‘RAND’ column. As it can be seen from the table, the average amount of user spur accumulated by the pair of actors for 20 invocations of the example program in the normal mode of operation is about 4–9 times greater than in the completely random mode of operation.


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