

             CubiCalc (R) Version 2.0
              HyperLogic Corporation
                 Example Scenarios



This release of CubiCalc contains six predefined scenarios that require
only CubiCalc to run, plus two others illustrating DDE that require
ToolBook(R). The CubiCalc sample projects appear as CubiCalc project
files in the EXAMPLES subdirectory and are identified by the extension
".CBC".

A run-time version of ToolBook is provided so that you can run the
ToolBook-based examples.  To modify the ToolBook projects, you must
have a development version of ToolBook. You can, in any case, examine
the CubiCalc project DDETRK.CBC for an example of the use of DDE.
The ToolBook projects have an extension of ".TBK".

Finally, a very simple Excel worksheet that uses DDE and works with
the TRUCK.CBC project is included as TRUCK.XLS. You must have Excel
to use this worksheet.


Dog vs. Cat  (DOGCAT.CBC)

This scenario is discussed in detail in the manual.  The basic idea is
target tracking, and applies equally well to all sorts of constant-
speed tracking problems.  The display provides only the tracking field,
and "as is" will terminate when the cat reaches the right hand edge.
The file CATPOSN.100 provides a source of positional data for the cat
and can be used in lieu of the simulation instructions in the project
file.  To use it, do the following:

    Load the project file DOGCAT.CBC.

    Select the File/Input File menu command.
    Set the file name to "CATPOSN.100".
    Set the file type to "Text".
    Set the field count per record to "2".  (Don't enter the quote marks.)
    Set the lines per record count to "1".
    Click OK.

    Select the Definitions/Simulation menu command.
    Disable the instruction governing the cat's x-coordinate
        ("Cat_x = ...") by inserting the pound symbol (#) in
        the first column of that line (just like the line
        below it).

    Select Definitions/Preprocessing and type the following lines:

        Cat_x = field(1);
        Cat_y = field(2);

    Select Definitions/Postprocessing and type the following line:

        ResetFile = EndOfFile;

    Then execute the scenario.  The cat will follow a square path
    forever, and the dog will try to catch it.


DDECAT.CBC is another version of the DOGCAT project designed to be used
with the ToolBook program DDECAT.TBK. To use them, first start CubiCalc
and load the DDECAT.CBC project.  Start the scenario using the
Execute/Monitor menu command.

Then start the ToolBook example with the provided icon or by using the
following command line:

    C:\CBC\EXAMPLES\TBOOK C:\CBC\EXAMPLES\DDECAT.TBK

The ToolBook display contains buttons for controlling the cat's
direction and speed. The Run button will start the project running and
the Monitor button will return CubiCalc to Monitor mode. If you use the
Monitor button while CubiCalc is already in Monitor mode, you will get a
"Failed" error message box from the ToolBook program.



Fruit Identification (PICKER.CBC)

This project is discussed in detail in the online tutorial, reached
through the Help/Tutorial menu command.  It is a simple decision
problem that takes input from a disk file.  The problem is to
identify a fruit based on its measured characteristics.

The PICKER project looks for its input file FRUITDAT.TXT in the
directory C:\CBC\EXAMPLES.  If you installed CubiCalc in a different
directory or moved the examples, you will need to change the input
file location with the File/Input File... menu command.



Truck  (TRUCK.CBC)

The problem addressed by this scenario is that of backing a truck up to
a loading dock.  The truck yard is assumed to be a square area 100
linear units on a side, and the loading dock is located at the bottom
center of the scenario display (at coordinates (50, 0)). The display
offers a scatter plot representing the truck yard, and includes a User
Interaction Window so that you can alter the three variables controlling
the truck's position and orientation (X is the truck's "X" coordinate, Y
is its "Y" coordinate, and Phi is its azimuth).  When changing the truck
position, try to keep it away from the edges of the yard.

When the truck reaches the "dock" the scenario will automatically
restart from a new, random position.  To see how this is done, select
Options/Restart... and examine the settings.

Each rule has a weight variable assigned.  You may disable an individual
rule by setting the corresponding weight to 0.0.  An interesting
experiment is to disable one or more rules.  In a number of cases, the
system still performs quite well.

Each rule also has an activation variable assigned. Logging them will
let you see the degree to which each rule "fires."

An Excel worksheet, TRUCK.XLS, uses DDE to obtain the current
SteeringAngle and displays it as a chart.  Load the worksheet into
Excel.  As TRUCK.CBC runs, Excel will update its chart.

DDETRK.CBC is a version of the Truck scenario that uses Windows DDE to
drive an animated ToolBook display.  To use it, start the ToolBook
example with the provided icon or by using the following command line:

    C:\CBC\EXAMPLES\TBOOK C:\CBC\EXAMPLES\DDETRK.TBK

then use Execute/Run to start the CubiCalc scenario. (CubiCalc is the
client in this example, so don't use Monitor mode.)

The adjectives used in the truck scenario were taken directly from
the original paper on which it is based.  They are listed below.

  Adjectives for Phi (truck orientation with respect to horizontal):
    RB - Right Below
    RU - Right Upper
    RV - Right Vertical
    VE - Vertical
    LV - Left Vertical
    LU - Left Upper
    LB - Left Below

  Adjectives for X (horizontal position):
    LE - Left
    LC - Left Center
    CE - Center
    RC - Right Center
    RI - Right

  Adjectives for Theta (steering signal):
    NB - Negative Big
    NM - Negative Medium
    NS - Negative Small
    ZE - Zero
    PS - Positive Small
    PM - Positive Medium
    PB - Positive Big



TruckXY  (TRUCKXY.CBC)

This scenario expands the truck backer example to account for the
y-coordinate input.  The extra coordinate is described by two fuzzy set
adjectives (LARGE and SMALL).  If the y-coordinate is LARGE, the rules
from the original scenario apply.  If the y-coordinate is SMALL, the
truck tends to steer away from the bottom boundary while it moves toward
the center.  The two rulesets blend where LARGE and SMALL overlap.

The adjectives used in this scenario differ from those of TRUCK.CBC.
For PHI, there are essentially three sets:  one set for 90 degrees, one
for 180 degrees, and one for 0 degrees.  These are assigned to three
different variables, PHI, PHI45, and PHI135.  The last two are important
when the truck is near the bottom boundary.  The X adjectives include
some similar to those of TRUCK.CBC, but there are some others to give
finer control.

  Adjectives for Phi (truck orientation):
    VL0 - Very much left of zero degrees
     L0 - Left of zero degrees
     M0 - More or less at zero degrees
     R0 - Right of zero degrees
    VR0 - Very much right of zero degrees

    VL90 - Very much left of ninety degrees
     L90 - Left of ninety degrees
     M90 - More or less at ninety degrees
     R90 - Right of ninety degrees
    VR90 - Very much right of ninety degrees

    VL180 - Very much left of one hundred eighty degrees
     L180 - Left of one hundred eighty degrees
     M180 - More or less at one hundred eighty degrees
     R180 - Right of one hundred eighty degrees
    VR180 - Very much right of one hundred eighty degrees

  Adjectives for Phi45 (truck orientation with respect to 45 degrees):

    VL45 - Very much left of forty-five degrees
     L45 - Left of forty-five degrees
     M45 - More or less at forty-five degrees
     R45 - Right of forty-five degrees
    VR45 - Very much right of forty-five degrees

  Adjectives for Phi135 (truck orientation with respect to 135 degrees):

    VL135 - Very much left of one hundred thirty-five degrees
     L135 - Left of one hundred thirty-five degrees
     M135 - More or less at one hundred thirty-five degrees
     R135 - Right of one hundred thirty-five degrees
    VR135 - Very much right of one hundred thirty-five degrees

  Adjectives for X (horizontal position):

  LG_LEFT - Very much to left of center of the yard
     LEFT - Left of center of the yard
  LG_LCTR - Close to, but off to left of center
     LCTR - Very close to but left of center
   CENTER - More or less at center of yard
     RCTR - Very close to but right of center
  LG_RCTR - Close to, but off to right of center
    RIGHT - Right of center of the yard
 LG_RIGHT - Very much to right of center of the yard

  Adjectives for Theta (steering signal):
    NB - Negative Big
    NM - Negative Medium
    NS - Negative Small
    ZE - Zero
    PS - Positive Small
    PM - Positive Medium
    PB - Positive Big

Start the scenario and let it run for a time.  You should observe the
truck starting from a variety of situations but always ending up at the
dock.  While the scenario runs you can watch the activation and
resultant graphs to see the response of the fuzzy engine.



Circle  (CIRCLE.CBC)

This is the simplest scenario in the CubiCalc package.  The problem here
is to drive a car in a circle 20 linear units in radius.  It is a
variation on the "Dog vs. Cat" problem and is far more complicated in
its simulation than in its fuzzy rulebase.  The display includes a Log
Window and a plot of rule activations so that you can watch details of
the car's performance.

Try commenting out the center (zero-case) rule by inserting pound signs
(#) before both lines of the rule. This illustrates the value of
overlapping fuzzy adjectives.



Magnetic Levitation (MAGLEV.CBC)

This project shows how to control an electromagnet so as to suspend a
ball bearing in midair below the magnet face.  This sort of problem
arose in the construction of a transportation system in Germany that
uses magnetic suspension for the passenger vehicles.

As a control problem, some delicacy is required because the system is
very unstable.  A displacement from the equilibrium position in the
direction of the ground decreases the effectiveness of the magnet while
gravity simultaneously tends to increase the distance.  Conversely, a
displacement in the direction of the magnet pole increases the magnetic
force on the bearing, so that it tends to race faster toward the magnet.

The scenario uses both the current displacement from equilibrium as well
as the rate of change in that displacement to decide the correct action.
Note the very narrow adjectives that describe both inputs near the
equilibrium position.  (Nominally, the magnet is 10 units up, so the
bearing should reach suspension equilibrium at 5 units up.)

The fineness of control required implies many rules to handle situations
that differ little (except to the bearing).  Otherwise, the rulebase is
typical of tracking problems.

The scenario shows the bearing over time as it experiences impulse
displacements from equilibrium.  The system is "overdamped", meaning
that the bearing does not oscillate about equilibrium, but rather
approaches equilibrium steadily from one direction.

As the scenario runs, five displays are visible.  At upper left is the
current activation of the input pairs in each possible combination of
input fuzzy set adjectives.  The resultant output fuzzy set that is
defuzzified to control the magnet appears at upper right.  The
activation levels that led to this resultant are shown directly below
the result graph. The other two displays show the bearing position as a
function of time. One is a continuous record of events, while the other
resets each time a new impulse affects the bearing.



Inventory (INVENT.CBC)

This project makes decisions about the size of orders to make to keep
inventory at an appropriate level.  It takes into account the current
level of stock, the amount already on order (with lead time), and the
backlog of unshipped orders.  The plot displayed shows the current
levels of backlog, stock, sales, and orders as sales rise and fall.



CubiCalc is a registered trademark of HyperLogic Corporation.
ToolBook is a registered trademark of Asymetrix Corporation.
Excel and Windows are trademarks of Microsoft Corporation.

