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


7.1 pic-guess

This program reduces the actor algorithm to a simple method of finding values for a set of boolean variables to maximize an objective function depending on those variables.

The program uncovers the bitmap of letter ‘A’, ‘B’, ‘C’, ‘D’, or ‘E’ by generating a trial bitmap and passing it to an opaque function returning a measure of similarity between the trial bitmap and the bitmaps of these letters hard-coded into the program. The opaque function also returns a flag indicating whether the trial bitmap is equal to one of the five letter bitmaps. If it is so, program execution finishes. All bitmaps have size 8x8.

The measure of similarity between a trial bitmap and the five letter bitmaps is equal to the maximum measure of similarity among the measures of similarity between the trial bitmap and each letter bitmap. The measure of similarity between a trial bitmap and a letter bitmap is the number of equal bits at the same positions in these two bitmaps divided by 64 and multiplied by a predefined weight for the letter bitmap. You pass those five predefined weights on the command line. The program should detect a bitmap with a maximum predefined weight by a minimum number of trials (steps).

Spur accumulated by the actor is equal to ln x, where x is the measure of similarity between last trial bitmap and the five letter bitmaps. The actor uses ey as the relative probability of an output signal, where y is a spur increment over a cycle type. The row and column of a bit in a trial bitmap specify an action choice state. Every action choice state has two output signals specifying possible values of a bit—the presence or absence of a dot at that position. Every trial (step) consists of generating bits for all positions in the trial bitmap, calculating the measure of similarity for the trial bitmap, and updating the spur according to that measure.

The command line has the format

./pic-guess weight_A weight_B weight_C weight_D weight_E seed

where weight_A, ..., weight_E are predefined weights for the bitmaps of letters ‘A’, ..., ‘E’, and seed is a random seed. If the random seed is non-negative, the actor operates adaptively, otherwise it operates randomly.

For example, when calling the program using the command line

./pic-guess 0.8 0.8 0.85 0.8 0.8 seed

where seed is in the range 1 to 20, the program correctly uncovers the letter ‘C’ in 18 of 20 runs.

For example, the call

./pic-guess 0.8 0.8 0.85 0.8 0.8 20

results in the output

   X  X  X  X  X  X

X  X  X  X  X  X  X  X

X  X

X  X

X  X

X  X

X  X  X  X  X  X  X  X

   X  X  X  X  X  X



Step: 746

Press [Q] to exit

where 746 is the number of trial bitmaps generated to detect the bitmap of letter ‘C’.

The file samples/pic_guess.c in the package distribution contains the source code of this example program. The command make builds the example program if the configure script has configured QSMM to use the ncurses library. See the file INSTALL in the root of the package distribution for information on the configure script.


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