DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦2ecc2f65d⟧ Ada Source

    Length: 10240 (0x2800)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Sfam, seg_032f77

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦this⟧ 

E3 Source Code



with Text_Io;
package body Sfam is
    type Pattern_Array is
        record
            Normal : Raw_Input_Pattern;
            Complement : Raw_Input_Pattern;
        end record;

    type Activation is delta Sfam_Units.Pattern'Delta range 0.0 .. 100.0;

    type Node;
    type Node_Ptr is access Node;
    type Node is
        record
            Cat : Category;
            Act : Activation;
            W : Pattern_Array;
        end record;

    type Link;
    type Link_Ptr is access Link;
    type Link is
        record
            Node : Node_Ptr;
            Next : Link_Ptr;
        end record;

    Output_Nodes : Link_Ptr := null;
    Sorted_Nodes : Link_Ptr := null;

    function Create_Pattern_Array
                (Normal : Raw_Input_Pattern) return Pattern_Array is
        P : Pattern_Array;
    begin
        P.Normal := Normal;
        for I in Normal'Range loop
            P.Complement (I) := Sfam_Units.Complement (P.Normal (I));
        end loop;
        return P;
    end Create_Pattern_Array;

    function And_Pattern_Array (P1, P2 : Pattern_Array) return Pattern_Array is
        R : Pattern_Array;

        function Min (P1, P2 : Sfam_Units.Pattern) return Sfam_Units.Pattern is
            use Sfam_Units;
        begin
            if P1 < P2 then
                return P1;
            else
                return P2;
            end if;
        end Min;

    begin
        for I in R.Normal'Range loop
            R.Normal (I) := Min (P1.Normal (I), P2.Normal (I));
        end loop;
        for I in R.Complement'Range loop
            R.Complement (I) := Min (P1.Complement (I), P2.Complement (I));
        end loop;  
        return R;
    end And_Pattern_Array;

    function Norm_Of_Pattern_Array (P : Pattern_Array) return Activation is
        Norm : Activation := 0.0;
    begin
        for I in P.Normal'Range loop
            Norm := Norm + Activation (P.Normal (I));
        end loop;
        for I in P.Complement'Range loop
            Norm := Norm + Activation (P.Complement (I));
        end loop;
        return Norm;
    end Norm_Of_Pattern_Array;

    function Create_Node (Its_Category : Category; Its_Pattern : Pattern_Array)
                         return Node_Ptr is
    begin
        return new Node'(Its_Category, 0.0, Its_Pattern);
    end Create_Node;

    procedure Display_Node (N : Node_Ptr) is
        package Fio is new Text_Io.Fixed_Io (Activation);
        package Pio is new Text_Io.Fixed_Io (Sfam_Units.Pattern);
    begin
        Text_Io.Put ("Node : ");
        Text_Io.Put (Image (N.Cat));
        Text_Io.Put (" T = ");
        Fio.Put (N.Act);
        for I in N.W.Normal'Range loop
            Text_Io.Put (" n ");
            Pio.Put (N.W.Normal (I));
        end loop;
        for I in N.W.Complement'Range loop
            Text_Io.Put (" c ");
            Pio.Put (N.W.Complement (I));
        end loop;
        Text_Io.Put_Line ("");
    end Display_Node;

    function Category_Is_Known (A_Category : Category) return Boolean is
        N : Link_Ptr := Output_Nodes;
    begin
        while N /= null loop
            if N.Node.Cat = A_Category then
                return True;
            end if;
            N := N.Next;
        end loop;
        return False;
    end Category_Is_Known;

    procedure Evaluate_Activation (N : Node_Ptr; I : Pattern_Array) is
        Alpha : constant Activation := 0.000_000_1;
    begin
        N.Act := Activation (Norm_Of_Pattern_Array
                                (And_Pattern_Array (I, N.W)) /
                             (Alpha + Norm_Of_Pattern_Array (N.W)));
    end Evaluate_Activation;

    procedure Sort_Nodes is
        Sorted : Link_Ptr := null;
        L : Link_Ptr;

        procedure Insert (N : Node_Ptr) is
            P, Q : Link_Ptr;
        begin  
            if Sorted = null then
                Sorted := new Link'(Node => N, Next => null);
            elsif N.Act > Sorted.Node.Act then
                Sorted := new Link'(Node => N, Next => Sorted);
            else
                Q := Sorted;
                P := Sorted.Next;
                while P /= null loop
                    if N.Act > P.Node.Act then
                        Q.Next := new Link'(Node => N, Next => P);
                        return;
                    end if;
                    Q := P;
                    P := P.Next;
                end loop;
                Q.Next := new Link'(Node => N, Next => null);
            end if;
        end Insert;
    begin
        L := Output_Nodes;
        while L /= null loop
            Insert (L.Node);
            L := L.Next;
        end loop;
        Sorted_Nodes := Sorted;
    end Sort_Nodes;

    procedure Treat_Labeled_Pattern (Its_Category : Category;
                                     Its_Pattern : Raw_Input_Pattern) is
        use Sfam_Units;
        N : Node_Ptr;
        L : Link_Ptr;
        Vigilance : Sfam_Units.Pattern;
        Match_Value : Sfam_Units.Pattern;
        Input : Pattern_Array;
        Mismatch : Boolean := False;
    begin
        Input := Create_Pattern_Array (Its_Pattern);
        if not Category_Is_Known (Its_Category) then
            N := Create_Node (Its_Category, Input);
            Output_Nodes := new Link'(Node => N, Next => Output_Nodes);
        else
            Vigilance := Base_Vigilance;
            L := Output_Nodes;
            while L /= null loop
                Evaluate_Activation (L.Node, Input);
                L := L.Next;
            end loop;
            Sort_Nodes;  
            L1:
                while Sorted_Nodes /= null loop
                    Match_Value := Pattern
                                      (Norm_Of_Pattern_Array
                                          (And_Pattern_Array
                                              (Input, Sorted_Nodes.Node.W)) /
                                       Its_Pattern'Length);
                    if Match_Value < Vigilance then
                        Sorted_Nodes.Node.Act := 0.0;
                        Mismatch := True;
                    else
                        if Sorted_Nodes.Node.Cat = Its_Category then
                            Sorted_Nodes.Node.W :=
                               And_Pattern_Array (Input, Sorted_Nodes.Node.W);
                            Mismatch := False;
                            exit L1;
                        else
                            Vigilance := Pattern (Match_Value + 0.000_000_1);
                            Sorted_Nodes.Node.Act := 0.0;
                            Mismatch := True;
                        end if;
                    end if;
                    Sorted_Nodes := Sorted_Nodes.Next;
                end loop L1;

            if Mismatch then
                N := Create_Node (Its_Category, Input);
                Output_Nodes := new Link'(Node => N, Next => Output_Nodes);
            end if;
        end if;
        Text_Io.Put_Line ("----------");
        L := Output_Nodes;
        while L /= null loop
            Display_Node (L.Node);
            L := L.Next;
        end loop;

    end Treat_Labeled_Pattern;

end Sfam;

E3 Meta Data

    nblk1=9
    nid=0
    hdr6=12
        [0x00] rec0=26 rec1=00 rec2=01 rec3=072
        [0x01] rec0=01 rec1=00 rec2=09 rec3=002
        [0x02] rec0=1f rec1=00 rec2=05 rec3=06a
        [0x03] rec0=1d rec1=00 rec2=02 rec3=010
        [0x04] rec0=1a rec1=00 rec2=04 rec3=014
        [0x05] rec0=1d rec1=00 rec2=03 rec3=03e
        [0x06] rec0=1b rec1=00 rec2=06 rec3=04e
        [0x07] rec0=13 rec1=00 rec2=08 rec3=020
        [0x08] rec0=13 rec1=00 rec2=07 rec3=000
    tail 0x2152bb05c84cc816d41e6 0x42a00088462060003