X-Mailer: ELM [version 2.2 PL9]
Newsgroups: bit.listserv.csg-l
Date:         Wed, 4 Nov 1992 18:44:19 EDT
From:         jeff@DRETOR.DCIEM.DND.CA
Subject:      Re: Squirrels, airconditioners
              at Oct 28, 92 9:49 am

[From Jeff Hunter (921104)]
> Re Bill Powers (921028.0630)

        Thanks for your comments on my squirrel posting. I think I'll
try my point again with exposition first, and examples to follow.

        Your contention is that "proper" control systems have loop
gains of at least -5 (preferably -10 to -100). I believe that this
rule-of-thumb of yours may be a result of the specs of the systems
you designed. I also believe that this is too constrained a definition
to describe the majority of control systems in living organisms.

        A "good" control system keeps its error within a specified
distance of zero for a specified percentage of the time for a
given class of disturbances.

        The control systems you describe generally have a small
tolerence for error, quick response time, and make few assumptions
about the pattern of disturbances (although they implicitly assume
an upper limiton their magnitude).
        For example the machine you described to etch diffraction
gratings (am I remebering this correctly?) must be accurate to
within .1 microns, must react in fractions of a second, and
probably assumed that earthquakes were rare.
	Thus:
> >>A control system that can cancel only 10 percent of a disturbance
> >>isn't much of a control system.

        Now consider the squirrel trying to maintain a CEV
"I am well fed". This is set by the squirrel's metabolism and diet.
On a summer day the squirrel does not need to burn any calories
to stay warm (low metabolic load), plus it can find a lot of food
easily (good diet). However on a winter day the squirrel must burn
a lot of calories to stay warm, and cannot find much food. This
is the maximum disturbance case.
        If the squirrel cannot make assumptions about the pattern
of summer and winter days then it must be able to survive
indefinitely in winter. I'm not sure what such a squirrel would
look like, but it would be big to keep surface heat losses down.
(Maybe a mammoth?)
	In reality species (through evolution) have a long history
of the climate. Squirrels "know" that they can expect the winter
to end (and have a fair estimate of how long winters are). Their
bodies and lifestyles are tailored to have enough fat reserves at
fall to survive a bad winter, and not much more. If a squirrel
stores as much fat as possible (rather than as much as it will
likely need) then it won't get around to such cruicial things as
finding mates to make baby squirrels with.
	Many control systems in living organisms make similar
assumptions about the pattern of disturbances they will encounter.


	I've made a program to illustrate an extremely abstract version
of a "loose" control system.
	The environment is one dimensional (represented by a number).
Time is quantised in ticks. There is a "disturbance" size (default 4),
and each tick the environment is changed by this size. (A random
number gives a 50% chance of increment, and 50% chance of decrement.)
	Three copies of this environment are kept. In one there is no
attempt to control it. In the second the number is moved two units
towards zero each tick. In the third the environment is incremented
by one unit (to introduce a "bias") before being moved toards zero
as in the second.

	In case that was unclear here is some pseudo code:

	for (each tick)

		if /* 50% chance of being true */
			change =  4
		else
			change = -4

		free_new = free_old + change
		cont_new = cont_old + change
		bias_new = bias_old + change + 1

		if (cont_new > 0)  cont_new = cont_new - 2
		if (cont_new < 0)  cont_new = cont_new + 2

		if (bias_new > 0)  bias_new = bias_new - 2
		if (bias_new < 0)  bias_new = bias_new + 2


	The tick-by-tick disturbance has a magnitude of 4, however the
long term average disturbance is 0 (or +1 in the biased case).
	The "gain" of the controlled system is (at most) -0.5, and
indeed the error is often non-zero. However it keeps the environment
within 8 units of zero 93% of the time.
	The biased system has better effective gain if the error is
negative, and worse gain is the error is positive. Nonetheless
it too keeps the error bounded at small values.

	The results of one run (of 10000 ticks) are displayed below.
Min and max are the highest and lowest values of the number.
Sum is the average of the absolute value of the error, while
"err" is the average of the square of the error.

 %wavers: loops=1 bias=0, incr=4

 %wavers: free max=  404 min= -124 sum=  208.36 err=51220.66
 %wavers: cont max=   28 min=  -30 sum=    3.20 err=   23.29
 %wavers: bias max=   61 min=  -13 sum=    6.67 err=  104.30


	The code of the program follows at the end of the post. It
generates a graph of the environment in PostScript, as well as
the summaries above.


	Now for a few comments:
> The importance of the result in the eyes of a biologist doesn't mean
> that there's a control system for the variable. In lower animals, many
> reference levels are inherited and are not adjustable.

	I think this point is irrelevant. Your reference level for blood
CO2 level is inherited and not adjustable in the same fashion, yet
you have a control system for it.


> You'd better draw me a diagram of [the squirrel's] control system.

	The concert hall cooler is easier to diagram, and makes the same
point. It shows a system that can maintain a CEV (temperature is less
than a given value) even though it's instantaneous gain (cooling power)
is overwhelmed by the heating power of the audience.

> >We get the same sort of thing in concert halls. The air
> >conditioning cannot handle the heat output of 40,000 sweaty rock
> >fans. [But it] can keep the temperature acceptable even
> >though it can only compensate for a fraction of the momentary
> >disturbance.

                  Max Safe Temp
                       v
    Heat        +-----------------+
    Schedule--> | Climate Control |
    & Time      +-----------------+
                 ^          |
                 |          v
                Temp       Air
                        Conditioner

	Here's a diagram of the system. The top level reference is
35 degrees Celsius (95 F). If the temperature gets higher than
that then people start collapsing of heat-stroke, and the hall
gets hit with lawsuits.

	The climate control ECS uses the input function:

	delta heat = expected heat from concert * fudge factor -
                  cooling capacity of air conditioners
	delta temp = delta heat * thermal mass of the concert hall
	predicted temp = delta temp + current temp

	The comparator of the ECS is:

		if (predicted temp >= max safe temp)
			error =  predicted temp - max safe temp
		else
			error = 0

	And the output function is:

		if (error not zero)
			turn on air conditioners

	(Note: this portrays only the cooling side of the climate control
system.)

> The only control that exists is over a 24-hour period. The average
> temperature is kept within plus or minus x degrees of a reference
> level. That's not very good control.

	The actual CEV is "temperature is not high enough to be a health
hazard", and this is controlled quite well unless the drummer
spontaneously combusts.

> The only reason this works is that the fans are willing to accept a
> wide range of temperature error, beginning at "too cold" and ending up
> at "too hot".

	Exactly. Not all control systems are built to microscopic
tolerances.



> RE: Greg helping Evan to solve a problem, at Evan's request:
>
> >> See how easy it is when nobody is trying to figure out how to
> >>control someone else?
>
> >See why it seems that your definition of control is not:
> >     - getting someone else to do what you want
> >but
> >     - getting someone to do what they don't want to
>
> It isn't so much getting someone to do what they don't want to as
> getting someone to do what you want, without considering what they
> want. You're controlling in either case, of course.

	Ack! If you limit "control" in social situations to mean
almost instantaneous 100% compliance regardless of the wishes of
the controlee then a science of social interactions does not
have to consider control any more than it considers unicorns.
	If you threaten people with "walk through that door or I'll shoot"
you assume that they do not wish to be shot. If you want control
regardless you'll have to pick themm up and toss them through
the door. This passes way outside the realm of psychology, and
into the realm of physics.


----------8<------cut here-------->8-----------------

/* a quick-and-dirty program to test a loose control system
 *
 *	This tests three systems that all have the same disturbance.
 *	They are:
 *		free - no control
 *		cont - some control
 *		bias - bias in the disturbance
 */

#include	<stdio.h>


#define	ABS(x)	(x)>0 ? x : -(x)

#define	BINS	512
#define	BIN2	(BINS/2)

long	free_bin [BINS];
long	cont_bin [BINS];
long	bias_bin [BINS];




main (argc, argv)

int	argc;
char*	argv[];

{

int	max_loop;			/* time to run			*/
int	init_bias;			/* initial value of counters	*/
int	increment;			/* size of counter increment	*/
int	d, i, j, k;
int	blip,	last;			/* random booleans		*/
int	pos,	neg;
int	up,	down,	high,	low;	/* bins to test random numbers	*/

long	b, max_bin, first_bin;

long	seed;

long	free_tot, free_max, free_min;
long	cont_tot, cont_max, cont_min;
long	bias_tot, bias_max, bias_min;

float	free_err, free_sum;
float	cont_err, cont_sum;
float	bias_err, bias_sum;

	printf ("%%!PS\n");

	if (argc > 1)
		max_loop = atoi (argv [1]);

	if (max_loop < 1)
		max_loop = 1;

	increment = 4;
	if (argc > 2)
		increment = atoi (argv [2]);

	init_bias = 0;
	if (argc > 3)
		init_bias = atoi (argv [3]);

	printf ("%%%s: loops=%d bias=%d, incr=%d\n",
		argv [0], max_loop, init_bias, increment);


	seed = time (0);
	srandom (seed);

	printf ("%%%s: seed=%ld\n", argv [0], seed);


		/* initialize counters and variables */

	free_tot = free_max = free_min = init_bias;
	free_sum = free_err = 0;
	cont_tot = cont_max = cont_min = init_bias;
	cont_sum = cont_err = 0;
	bias_tot = bias_max = bias_min = init_bias;
	bias_sum = bias_err = 0;

	pos = neg = up = down = high = low = 0;
	last = 0;

	for (b=0; b<BINS; b++)
		free_bin [b] = cont_bin [b] = bias_bin [b] = 0;

	k = 0;

		/* simulation loop */

    for (j=0; j<max_loop; j++) {

	for (i=0; i<10000; i++) {

		blip = random() & 0x100;

		if (blip) {
			d =  increment;
			pos++;
			if (last) high++; else up++;
		} else {
			d = -increment;
			neg++;
			if (last) down++; else low++;
		}
		last = blip;

		free_tot += d;
		cont_tot += d;
		bias_tot += d;

		if (cont_tot > 0) cont_tot -= 2;
		if (cont_tot < 0) cont_tot += 2;

		bias_tot++;
		if (bias_tot > 0) bias_tot -= 2;
		if (bias_tot < 0) bias_tot += 2;

		b = free_tot + BIN2; if (b >= 0 && b < BINS) free_bin [b]++;
		b = cont_tot + BIN2; if (b >= 0 && b < BINS) cont_bin [b]++;
		b = bias_tot + BIN2; if (b >= 0 && b < BINS) bias_bin [b]++;

		free_sum += ABS (free_tot);
		cont_sum += ABS (cont_tot);
		bias_sum += ABS (bias_tot);

		free_err += (free_tot * free_tot);
		cont_err += (cont_tot * cont_tot);
		bias_err += (bias_tot * bias_tot);

		if (free_tot > free_max) free_max = free_tot;
		if (free_tot < free_min) free_min = free_tot;
		if (cont_tot > cont_max) cont_max = cont_tot;
		if (cont_tot < cont_min) cont_min = cont_tot;
		if (bias_tot > bias_max) bias_max = bias_tot;
		if (bias_tot < bias_min) bias_min = bias_tot;
/*
		printf ("%%%s: free max=%5ld min=%5ld sum=%f err=%f \n",
			argv [0], free_max, free_min, free_sum, free_err);
		printf ("%%%s: cont max=%5ld min=%5ld sum=%f err=%f \n",
			argv [0], cont_max, cont_min, cont_sum, cont_err);
		printf ("%%%s: bias max=%5ld min=%5ld sum=%f err=%f \n",
			argv [0], bias_max, bias_min, bias_sum, bias_err);
		printf ("%%\n");
 */
	}
	k += i;

	printf ("%%%s: pos=%ld, neg=%ld, 00=%5d, 01=%5d, 10=%5d, 11=%5d\n",
		argv [0], pos, neg, low, up, down, high);
	printf ("%%%s: free max=%5ld min=%5ld sum=%8.2f err=%8.2f \n",
		argv [0], free_max, free_min, free_sum/k, free_err/k);
	printf ("%%%s: cont max=%5ld min=%5ld sum=%8.2f err=%8.2f \n",
		argv [0], cont_max, cont_min, cont_sum/k, cont_err/k);
	printf ("%%%s: bias max=%5ld min=%5ld sum=%8.2f err=%8.2f \n",
		argv [0], bias_max, bias_min, bias_sum/k, bias_err/k);
	printf ("%%\n");
    }

	max_bin = 1;
	first_bin = 0;
	for (b=0; b<BINS; b++) {
		if (free_bin [b] && (!first_bin)) first_bin = b;
		if (free_bin [b] > max_bin) max_bin = free_bin [b];
	}

	printf ("\n %% free variables, scale=%ld\n", max_bin);
	printf ("[1 1] 0 setdash\n %ld	50 moveto\n", first_bin+50);

	for (b=0; b<BINS; b++)
	    if (free_bin[b])
		printf ("%ld	%ld	lineto\n",
			b+50, (long) (600.0 * free_bin [b] / max_bin) + 50);
	printf ("stroke\n");


	max_bin = 1;
	first_bin = 0;
	for (b=0; b<BINS; b++) {
		if (cont_bin [b] && (!first_bin)) first_bin = b;
		if (cont_bin [b] > max_bin) max_bin = cont_bin [b];
	}

	printf ("\n %% cont variables, scale=%ld\n", max_bin);
	printf ("[2 1] 0 setdash\n %ld	50 moveto\n", first_bin+50);

	for (b=0; b<BINS; b++)
	    if (cont_bin[b])
		printf ("%ld	%ld	lineto\n",
			b+50, (long) (600.0 * cont_bin [b] / max_bin)+50);
	printf ("stroke\n");


	max_bin = 1;
	first_bin = 0;
	for (b=0; b<BINS; b++) {
		if (bias_bin [b] && (!first_bin)) first_bin = b;
		if (bias_bin [b] > max_bin) max_bin = bias_bin [b];
	}

	printf ("\n %% bias variables, scale=%ld\n", max_bin);
	printf ("[2 2] 0 setdash\n %ld	50 moveto\n", first_bin+50);

	for (b=0; b<BINS; b++)
	    if (bias_bin[b])
		printf ("%ld	%ld	lineto\n",
			b+50, (long) (600.0 * bias_bin [b] / max_bin)+50);
	printf ("stroke\n");

	printf ("showpage\n");
}
--
De apibus semper dubitandum est - Winni Ille Pu
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU