# INTRODUCTION TOPERCEPTUAL CONTROL THEORY

## Part 2: Modeling control behavior

### Introduction

The secret of constructing behavioral models is to think of everything as an amount rather than a thing. We deal with variables, not objects or acts. In this series we will model compensatory tracking, which as you know from Part 1 involves moving a handle that affects a cursor; the cursor is also subject to an independent random disturbance. The first step is to see the handle and cursor not as objects but as variables. All that matters about either one is represented by a number. A number represents handle position, a number represents cursor position. The physical environment (the computer) makes the cursor number depend on both the handle number and the disturbance number.

The links between handle and cursor or disturbance and cursor are established by properties of the environment, which we will show in boxes. We can give the boxes any properties we like. Of course we choose properties that will make the model cursor depend on handle position and disturbance as realistically as possible. The next step is concerned with setting up the environment model.

### Modeling the environment

In the following series we will build up the model of a control system step by step. The first step is to model the environment, which consists of the control handle, the cursor seen on the screen, and the disturbance (which acts invisibly inside the computer).

The handle position is represented by h, a variable number. The value of h is multiplied by a "feedback constant" Kf. The product h * Kf represents the contribution of handle position to the cursor position.

The magnitude of disturbance is represented by d, another variable number. The value of d is multiplied by a "disturbance constant" Kd. The product d * Kd represents the contribution of the disturbance to the cursor position.

Finally, cursor position c is found by summing the effects of the handle via Kf and the disturbance via Kd, so that c = h * Kf + d * Kd.

You can use the control handle to keep the cursor between two target marks, a standard compensatory tracking experiment. A "strip chart" graph shows handle and cursor recordings. You can alter Kf and Kd. Experiment until you see and feel just how the disturbance and handle effects add up to position the cursor. Generally, do the tracking for 15-20 seconds, then click the Pause button to freeze the action so you can look at the numbers. You can always alter the constants. Click and hold the constant with the mouse and change it by dragging the number left to decrease it, or right to increase it.

Kd, Environmental Disturbance Constant

The "disturbance constant" Kd determines how much effect a disturbance will have on the cursor. Step Kf down to 0 by dragging the number in the box to see the disturbance's effect by itself (the handle can move as usual but has no effect on the cursor). Change Kd to see how different values of Kd give the same disturbance different amounts of effect on the cursor.

Kf, Environmental Feedback Constant

The "feedback constant" Kf determines how much effect a given handle position will have on the cursor. Set the disturbance factor Kd to zero to see how changing Kf alters the handle's effect on the cursor. With a large value of Kf (3.00), a given change in cursor position can be produced with a small handle movement. Reducing Kf to a small number (like 0.5) means that a larger handle movement is needed to give the same effect.

### The perceptual or input function

As you watch the cursor, you get a continual sense of its position. This sense is modeled as a "perceptual signal", generated by a combination of a visual image and neural computations that create a signal representing the state of the variable. As the cursor moves up, the signal increases; as it moves down, the signal decreases. Here we allow the perceptual signal to go negative when the cursor is left of the target. In a real nervous system there would have to be a "left" signal and a "right" signal because the magnitude of neural signals (measured in impulses per second) can't ever be less than zero.

Modeling perception is easy because we don't know any of the details of how sensing position works. We simply draw a box called the "input function" and declare that its input is the actual state of the cursor, and its output is a signal ("p") whose magnitude is the input times some input constant, Ki.

We will now begin using more general labels: "qi" for "input quantity" instead of "cursor", and "qo" for "output quantity" instead of "handle". We will keep "d" for disturbance just to prove that one needn't be compulsive about these labels (we could say "qd" -- disturbing quantity). A dashed line now separates the behaving system from its environment. The magnitude of the perceptual signal is now p = qi * Ki.

Ki, Input Constant

The "input constant" Ki determines the scaling factor that relates physical units (cursor position) to nervous-system units or NSU, related to frequency of impulses. A factor of 1.00 means that one physical unit of input creates one NSU of perceptual signal. Try different values of Ki by dragging it left or right.

### The comparator and reference signal

Control behavior is based on the difference between the perceived state of the input quantity and a "reference" state -- the state intended. Just seeing if the cursor is left or right from the target is not enough. You have to know how much right or left you want it to be. Normal tracking implies that there should be no "rightness" or "leftness", but you can easily decide to keep the cursor any amount left or right of the target. In the model there is a "comparator" that receives the perceptual signal and a new signal, the "reference signal." The reference signal specifies the desired level of the perceptual signal. The comparator creates an error signal that tells how far the reference signal is to the right or to the left of the perceptual signal: the magnitude of the error signal is just the magnitude of the reference signal minus the magnitude of the perceptual signal.

Using the mouse, you can increase or decrease the reference signal in the range -200 to +200. Watch the effects on the error signal as you move the handle. You can also set Kf to zero, so the handle has no effect, and let the disturbance variations affect the model while you experiment.

Comparator: Reference & Error Signals

The error signal (e) is affected equally by the reference signal (r) and by the perceptual signal (p). The error signal becomes zero only when reference and perceptual signals match. Zero error is defined by the reference signal. A POSITIVE error signal says the handle should move RIGHT. You can change the reference signal; watch the effect on the error signal.

### The Output Function

We have an error signal that shows, by its magnitude and sign, how much and in what direction the cursor needs to move to make the perceptual signal match the reference signal. Now we add the last function, an "output function" that converts the error signal into action.

Ko, Output Constant

This output function makes the handle move to a position that is some constant times the error signal. The constant is the "output constant" or Ko, which you can adjust as before. For reasons that will be explained later, the output function also contains a slowing factor, which you will see as a lag in the output when the factor Ko is large (10 or so).

In this step we will NOT close the loop. The output will just be shown as a number, which you can compare with the handle number (qo). After you have understood this final part of the control system, you can go to the next step to see what happens when the output actually substitutes for your own handle movements, making this into a working model.

The Output Function

The feedback factor is now set to zero so the handle has no effect. Only the disturbance affects the perceptual, error, and output signals. Watch the disturbance and change Ko until you think the output is changing the way it should to cancel the effects of the disturbance. You are not likely to guess right unless you know control theory! You can still change all the constants.

### Closing the Feedback Loop

The situation is now just what it was in the last step, except that the 'Close loop' button is enabled. Pressing 'Close loop' button makes the model's output quantity qo determine the handle position, so your handle movements now have no effect. (Pressing it again allows you to control the model's handle position again)

The model is now controlling the cursor. You may have set Ko, in the last step, so the model's output was equal and opposite to the disturbance (with the handle ineffective, Kf = 0). That would require Ko to be 1.00. Now you will find that this gives very poor control. Watch the error signal with Kd = 1.00, Ki = 1.00, and Kf = 1.00.

For the model to keep the error small, you will have to increase Ko to at least 10. It can be set as high as 50. The larger Ko is, the better the control. With Ko set between 5 and 20, the model will control about as well as you do. Now you can experiment with all the constants to see their effects on the way the model controls. Be sure to check the effects of varying the reference signal -- it determines where the cursor will be maintained.

Use the 'Close loop' button to open and close the loop. With the loop open, you control the handle and the model just produces an output number. With the loop closed, the handle position IS the system's output number, qo. To keep the error signal small, you have to make Ko much larger than 1: the open-loop output changes must be much larger than the handle movements.

### A higher-level control system

The control-system model, with the loop closed, keeps the perceptual signal nearly matching the reference signal. With the reference signal set to zero, this means it keeps the cursor in line with the target marks, which are set to the zero (screen-center) position. This system, however, is controlling the absolute cursor position on the screen, not its position relative to the target. It isn't perceiving the target position.

You, however, can see that relationship. You can decide, when you are controlling, to keep the cursor some distance above or below the target. To do this, you pick an intended position, and use your own lower-level control systems to bring the target to the intended position. You can make this model act like your own lower level control systems -- you can specify where you want it to hold the cursor. You do this by altering the reference signal for the model. You don't have to watch the reference signal--just the relationship between cursor and target. Now you are acting like a higher level control system, controlling a RELATIONSHIP by varying the reference signal for a lower-order system that controls only POSITION. Notice that the position control system automatically cancels most of the disturbance effect.

Try changing the reference signal. The control system model will keep the perceptual signal matching the reference signal. To change the perceptual signal, the system has to move the cursor. The result is that the cursor is kept in a position, called its reference level, determined by the setting of the reference signal. The control sysstem automatically resists the disturbance.

### The Equations of Control

In all traditional models of behavior, only a single equation is needed to capture the relationship proposed to exist between inputs and outputs: however written, it says that output is a function of input, or in our terms, qo = f(qi).

The control concept adds another statement: input is a function of both output and independent disturbances: qi = g(qo) + h(d). Now there are two equations. They must both hold true all of the time. The final relationship between input and output is not correctly described by either equation alone.

The traditional role of "stimulus" is played by the disturbance, not by the input quantity qi. The real input, qi, is jointly determined by the disturbance, d, and by the behavioral output, qo. The true independent variables are the reference signal, r, and the disturbance, d.

Only certain values of qi and qo will satisfy both equations at once. Both qo and qi are dependent variables: both the input and the output come to values determined by the whole feedback relationship.

From the block diagram built up during Part 2 we can read off four equations that are as important for the life sciences as Maxwell's equations of electromagnetism were for physics. In the next frame you will see how these equations interact to give a picture of the behavior of a control process.

From the diagram above we can write four equations:
 1. Environment: qi = Kf * qo + Kd * d 2. Perception: p = Ki * qi 3. Comparison: e = r - p 4. Action: qo = Ko * e

Now you can set the values of the two independent variables, r and d, and the values of the constants Kf, Kd, Ki, and Ko. Each of the equations remains true at all times, as you can verify by checking each equation manually. The values of qi and qo agree with the solutions of the four equations solved as a simultaneous system (solutions shown below). The dynamics are still hidden; they are explained in later frames.

Solutions:
qi = [(KfKo)r + (Kd)d]/[1 + KiKoKf]
qo = [(Ko)r - (KoKiKd)d]/[1 + KiKoKf]

### Dynamics: The Slowing Factor

Real systems can't change their output actions instantly from one value to another. To this point, that fact about physical variables and physical time has been handled in the background. Whenever a jump in the output quantity was computed, the actual change was allowed to go only a fraction of the way toward the new value on any one computing cycle (once around the four equations). This fraction is 1/S, where S is called the "slowing factor." If the present value of output is 10 and the computation makes the next value 30, the computed jump is 20 units of output. With a slowing factor of 10, we would multiply the jump by 1/10, and so alter the output only 2 units instead of 20. You will see how this works in the next frame.

The nature of digital computations puts a lower limit on the number S. This limit is related to the "loop gain", the product Ki * Ko * Kf. If S is set to 1 + Ki * Ko * Kf, the digital computation reaches the correct final value in one jump. We have been using that optimum slowing factor. If S is 1/2 that amount or less, the computations will start oscillating and the results will no longer mean anything (you might even have to start the program over!). In simulations of real systems, the best slowing factor is considerably larger than this computer-imposed limit, so the problem doesn't arise. In the next frame, however, you can set the slowing factor to any value greater than 0.001, and see what happens. There's no closed loop to cause a problem.

In this example, all factors are adjustable. Change the value of the output constant Ko, the error signal e, or the slowing factor S. Press "Step" to compute the value of the expression below over and over. Eventually you will find that the output quantity qo comes exactly to the value Ko * e. How fast it does this depends on the slowing factor S (always positive). When S = 1 there is no slowing. qo is limited to +/- 10,000.

We are computing this expression (qo starts at zero):

When the slowing factor is used in simulations of a control system, there is a lower limit on the value of S. If S is less than this limit, the digital nature of the computations will cause a spurious runaway condition that would not appear in an analogue computation or in a normal control system. In the next frame, S is NOT forced to stay above this minimum value -- that's up to you. It is, however, made to stay larger than 0.001, to prevent dividing by 0. If the program runs away, press the 'Reset' button.

### The Equations of Control

This demonstration works as before. Also, you can now change the slowing factor rather than having it computed automatically. The loop gain and the optimum slowing factor are shown below. The fourth equation now shows how the slowing factor is applied to calculate a new output quantity. S = 1 means no slowing.

Loop Gain = ...
Optimum Slowing Factor = ...

### Matching the Model to Real Behavior

We will now set up a standard compensatory tracking experiment. You will go through a one-minute run while 3600 data points are taken (60 to 70 seconds). Then the same model we have been using will be run with the same disturbance. To "run" the model means feeding it values of the same disturbance, one after the other, and doing one cycle of the computations each time, saving the results. The model's behavior and the real behavior are then plotted.

You can adjust the reference signal r, the output constant Ko, and the slowing factor S for the model. The difference between model and real handle positions is plotted in the middle, with the root-mean-square (RMS) of the difference.

Also shown is the ratio Ko/S, which is the "integration factor" valid for large values of S. When S is a large number, the output function acts almost like a pure time integrator, summing the values of error signal. You will find that the best fit of model to real behavior occurs when Ko is greater than 100, and S is about 5 to 7 times as large as Ko. The most important number is Ko/S.

The numbers you end up with are inferences about the properties of the real person, under the assumption that the person is organized as the model is organized. You can judge for yourself whether this model is adequate.

Select the type of variable you want to control: Cursor Sound Number
Select the degree of difficulty: 1 2 3 4

This is a compensatory tracking experiment. Hold the cursor between the two target bars. The run lasts about one minute.

Adjust the parameters of the model to get a better fit.

Integration factor, Ko/S:
RMS difference:
Handle vs model-handle correlation:

### Matching the Model to Real Behavior, Revised Model

This time, after the experimental tracking run (from the previous step), the model will include a sensory lag adjustment, as well as the adjustments you've already seen. This is accomplished by using a slowing factor just as in the output function. You will find that with the right amount of sensory slowing factor (ss), somewhere around 4 to 6, you can get the model to fit the data even better than before -- more of the rapid changes are imitated (although still not all of them).

When you set the sensory slowing factor to 1.0 (as low as it will go), there is no sensory slowing. So you can compare the best parameter adjustments with and without sensory slowing.

A sensory slowing factor of 5 means that after a sudden change in cursor position, the perception of cursor position changes by 20 per cent in each 1/30 second interval -- 20 per cent of the remaining distance to the final value. This corresponds to a sensory time constant of about 0.15 seconds, a reasonable value for visual perception.

Below are show calculation of the correlation between the model's and the person's handle position, and you can see how well this model matches behavior.

Integration factor, Ko/S:
RMS difference:
Handle vs model-handle correlation:

Text and concept by W.T. Powers, circa 1989
Original programs for DOS: Demo2