Skip to content

This repository contains files related to RnD Project (Autumn 2023).

Notifications You must be signed in to change notification settings

Whitelisted2/RnD-Nerve-Net-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RnD-Nerve-Net-Simulator

This repository contains files related to RnD Project (Autumn 2023).

Definition and Requisite Theory

The definition and functioning of nerve nets, as implemented in this repository, is aligned with that of the book 'Counter-Free Automata' by McNaughton and Papert, which is accessible via the Internet Archive at this link. Note that the definition(s) from other sources could differ (e.g. an inclusion of implicit neuron delay) but such nerve nets can also be simulated here with suitable modifications in the inputs. (We have picked the more malleable definition.)

Instructions

  • You can edit input file path in the file config.json, and also enter the input string there. (An example is explained below.) The verbose_roundwise option allows you to view the internal junction/neuron values at each timeslot.
  • Run python3 src/simulator.py to simulate the nerve net and print output at the time of the last input character(s) being sent into the system.
  • sandbox/ contains code that consists of snippets dealing with graphical approach, dictionary separation, etc.

Input Format

Input files must be of the following format:

  • Line 1: Number of input lines (I1, I2, ...)
  • Line 2: Number of output lines (O1, O2, ...)
  • Line 3: Number of neurons (1, 2, ...)
  • Line 4: Threshold values for neurons ordered by neuron ID
  • Line 5 onwards: Axon specifications, in the format: <start-point> <end-point> <delay> <nature> where:
    • <start-point> can be a neuron or an input line.
    • <end-point> can be a neuron or an output line.
    • <delay> is a non-negative integer.
    • <nature> is either 0 (inhibitory) or 1 (excitory).

Ensure that the nerve net is well-formed (i.e., it has no zero-delay loops), or the program may enter an infinite loop (as it should, in that case).


Example 1: buzzer.in

A buzzer net is represented by the following figure (Assume that the input line is I1, and that output O1 is the value on the feedback axon just before the delay element):

image

For this example, config.json is specified as:

image

Here, the attribute I1 denotes the input stream incident to input line I1. Also, the contents of inputs/buzzer.in specify the buzzer net as follows:

image

With "verbose_roundwise": true, and "I1": "11111", on running python3 src/simulator.py the following output is observed, depicting the values of the neurons, axons, and I/O lines:

image

Note that the event at O1 is denoted by $(\Sigma^{*}0~~ \cup ~~\lambda)(11)*1$, where Σ = {0, 1}. Hence, a string with an odd number of ones, or a string with an odd number of ones after the last occurring zero character, would be accepted. Thus, the above case has {"O1": 1} as the final output, signifying acceptance/occurrence of the desired event.

If the same were to be run with the string 1111 as input on I1, then the same output trace would be generated EXCEPT the last timeslot. Hence, {"O1": 0} would signify the string not being accepted.


Example 2: input2.in

The file inputs/input2.in encodes the following nerve net (Assume that B is I1, and C is I2, while D is O1):

image

For this example, config.json is specified as:

image

The encoding is as follows:

image

For the inputs specified in the above two images, running python3 src/simulator.py results in the following output:

image

Clearly, the input strings, and any equal-length prefixes of the inputs are not accepted as high-signal events at O1. To describe the event at O1, we assume the following alphabet-encoding: 0 : (C : 0, B : 0); 1 : (C : 0, B : 1); 2 : (C : 1, B : 0); 3 : (C : 1, B : 1), and Σ = {0, 1, 2, 3}. Here, the event at O1 is given by $\Sigma^{ *}(1 \cup 3)\Sigma^{ *}2$. Thus, the following configuration should result in an accepting scenario for the same nerve net:

image

Let us check the output stream to verify this!

image

Thus any scenario where the final input is 2 with a 1 or 3 at some point in the prior past is accepted, with {"O1": 1} at the final timeslot.


Other Info

  • If your nerve net has some amount of 'delay' with respect to its output, the input string must also have extra characters to compensate, since the event described could be something along the lines of $(0101)^{ *}\Sigma\Sigma$ if the nerve net accepts $(0101)^{ *}$ with a delay of two time slots after the end of the last 'processed' character. Hence, be diligent when entering an input string.
  • If verbose_roundwise is set to false, then the output will just be the value of O1 at the final timeslot.

"Let your rapidity be that of the wind, your compactness that of the forest." — Sun Tzu, The Art of War

About

This repository contains files related to RnD Project (Autumn 2023).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages