home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / DATAREP.ZIP / READNF.INC < prev    next >
Encoding:
Text File  |  1990-02-22  |  3.8 KB  |  106 lines

  1. {Reads neuron file in from disk.  These files are composed of         }
  2. {Pascal records of TYPE NEURON.    If the neurons are partially       }
  3. {connected, then some synapses need not be used.  TYPE NEURON         }
  4. {files store data as connection lists, so a partially connected       }
  5. {system will compute faster than one that is fully connected.         }
  6. {This is a useful technique on a VAX which does not vectorize.        }
  7. {If these programs are run on many supercomputer or a machine with    }
  8. {an array processor, more traditional matrix storage would be faster, }
  9. {in spite of a number of zero entries.                                }
  10. {Our experience has been that partial connectivity usually works      }
  11. {better than full connectivity.  In a fully connected system, every   }
  12. {element sees the same enviroment, which seems to problems            }
  13. {with metastable and symmetric computational states.                  }
  14.  
  15.  
  16. PROCEDURE Read_Neuron_File;
  17.         VAR I, 
  18.             Number_of_neurons: INTEGER;
  19.  
  20.     FUNCTION Found_Zero (N: Neuron): BOOLEAN;
  21.            VAR J: INTEGER;
  22.            Found: BOOLEAN;
  23.            BEGIN
  24.            Found:= FALSE;
  25.            FOR J:= 1 TO Dimensionality DO
  26.                IF N.Synapses [J].From = 0 THEN Found:= TRUE; 
  27.            Found_Zero:= Found;
  28.            END;
  29.  
  30.     FUNCTION Synapse_Number (N: Neuron): INTEGER;
  31.            VAR First_Zero: INTEGER;
  32.            BEGIN
  33.            First_Zero := 0;
  34.  
  35.            IF Found_Zero (N)
  36.               THEN REPEAT First_Zero:= First_Zero + 1 
  37.                    UNTIL (N.Synapses [First_Zero].From = 0)
  38.               ELSE First_Zero := Dimensionality + 1;
  39.  
  40.            Synapse_Number:= First_Zero - 1;           
  41.            END;
  42.     
  43.     PROCEDURE Read_Nfile;
  44.         VAR File_error: BOOLEAN;
  45.         BEGIN
  46.         OPEN (Nfile, 'Nfile', OLD, ERROR:= CONTINUE);
  47.  
  48.         IF STATUS (Nfile) = 0 
  49.            THEN File_error:= FALSE ELSE File_error:= TRUE;
  50.  
  51.         IF NOT File_error THEN 
  52.            BEGIN
  53.            Neuron_file_present:= TRUE;
  54.            RESET (Nfile);
  55.            I:= 0;
  56.            WHILE NOT EOF (Nfile) DO
  57.                 BEGIN
  58.                 I:= I+1;
  59.                 Neurons [I]:= Nfile^;
  60.                 GET (Nfile);
  61.                 END;
  62.            Number_of_Neurons:= I; 
  63.            WRITELN ('The neuron file contains ',
  64.                      Number_of_Neurons:4,' neurons.');
  65.            Erase_line;
  66.  
  67.            {Computes average number of synapses in neuron file.}
  68.  
  69.            FOR I:= 1 TO Dimensionality DO
  70.                Number_of_synapses[I]:= Synapse_number (Neurons [I]);
  71.            Avg_number_of_synapses:= 0;
  72.            FOR I:= 1 TO Dimensionality DO
  73.                Avg_number_of_synapses:= 
  74.                    Number_of_synapses[I] + Avg_number_of_synapses;
  75.            Avg_number_of_synapses:= 
  76.                Avg_number_of_synapses DIV Dimensionality;
  77.            WRITE   ('Average number of synapses in neuron file: '); 
  78.            WRITELN (Avg_number_of_synapses:6);
  79.            Erase_line;
  80.            CLOSE (Nfile);
  81.            END;
  82.  
  83.         {VMS Specific Error Handling.}
  84.  
  85.         IF File_error THEN BEGIN
  86.                            Neuron_file_present:= FALSE;
  87.                            WRITE ('Neuron file cannot be opened.');
  88.                            IF STATUS (Nfile) = 3 
  89.                               THEN WRITELN (' FILE NOT FOUND.')
  90.                               ELSE WRITELN;
  91.                            END;
  92.         END;
  93.  
  94.         BEGIN      {Read_Neuron_File.}
  95.         WRITELN;
  96.         Scroll_block;
  97.         Bottom_line;
  98.         WRITELN ('The program is reading the neuron file.');
  99.         Erase_line;
  100.         WRITELN ('This is a file of TYPE NEURON.');
  101.         Erase_line;
  102.         Read_nfile;
  103.         Restore_scrolling;
  104.         WRITELN;
  105.         END;       {Read_Neuron_File.}
  106.