Program for Bruce's equations

[From Bill Powers (960104.2100 MST)]

Bruce Abbott (960104) --

Here is a program that executes your control system. It iterates 6000 times
at 0.1 sec per iteration to run the simulation for 10 minutes, then prints
out the values of the variables. With the depletion rate set to zero, the
values of the variables are

Ratio F e R B
  1 10.00 0.0 0.0 0.0
  2 10.00 0.0 0.0 0.0
  5 10.00 0.0 0.0 0.0
10 10.00 0.0 0.0 0.0
20 10.00 0.0 0.0 0.0

This makes sense, because with no depletion, once F reaches the reference
level there is no error, no behavior, and no further food required.

With the depletion set to M = 0.01, the table is

Ratio F e R B
  1 9.98 0.02 0.22 0.22
  2 9.96 0.04 0.22 0.44
  5 9.89 0.11 0.22 1.11
10 9.78 0.22 0.22 2.22
20 9.56 0.44 0.22 4.44

Program appended.

···

----------------------------------------------------------------------
Best,

Bill P.

Program food1.pas

program food1;

uses dos,crt;
{
(1) R = B/n environment function (ratio schedule)
(2) F = F0 + (m*R - M)*t food amount at time t
(3) p = F perceptual signal
(4) e = Fr - F error signal
(5) B = g * e output function

g = 10 resp/gram
m = 0.045 gram
t = 600 seconds [ten minutes into session]
F0 = 0 gram [empty gut]
Fr = 10 gram
M = 0 grams/sec [depletion rate would be negligible compared to repletion]

}

var R,B,n,F,F0,Fr,g,mm,m,dt,t,p,e: real;
    ch: char;
     i,j: integer;
    ratio: array[1..5] of real;
begin

g := 10.0; mm := 0.045; F := 0.0; Fr := 10; M := 0.01;
F := 0.0; dt := 0.1;
ratio[1] := 1; ratio[2] := 2; ratio[3] := 5;
ratio[4] := 10; ratio[5] := 20;
writeln('Ratio F e R B');
for j := 1 to 5 do
begin
n := ratio[j];
F := 0.0;
for i := 0 to 6000 do
begin
  e := Fr - F;
  B := g*e;
  R := B/n;
  F := F + (mm*R - M)*dt
end;
writeln(Ratio[j]:5:0,' ',F:5:2,' ',e:5:2,' ',R:5:2,' ',B:5:2);
end;
ch := readkey;
end.