nneco:
An Artificial Neural Network extension for NetLogo
I have developed some years ago an extension in Java for NetLogo that allows me to give an evolving mental model to each agent. Agents can form expectations on the potential consequences of their decisions and actions in their environment, given the state of this environment, and its evolution as a consequence of these actions. Using this extension, the modeler can give a very basic back-propagation-based ANN to each agent and this ANN can evolve by trying to correct its expectation errors, after having observed the reaction of the environment.
See this article, for example, for an application of this approach in R&D decisions, or this article, in consumption theory. You can read more, in French, on the conceptual reasoning behind this approach in the chapter I have dedicated to expectations in my book on economic complexity.
I will give a brief description of this extension here, to help other potential users.
See this article, for example, for an application of this approach in R&D decisions, or this article, in consumption theory. You can read more, in French, on the conceptual reasoning behind this approach in the chapter I have dedicated to expectations in my book on economic complexity.
I will give a brief description of this extension here, to help other potential users.
You can download the extension from the links below and you should place it in a
If you send your NL program on a cluster, you must send the extension too, besides other NL libraries that are necessary for remote execution of your model.
If you use this extension in a publication, please cite it as:
Yildizoglu Murat, 2021, "A NetLogo extension implementing feed-forward artificial neural networks for agents", https://yildizoglu.fr/software/nneco/, University of Bordeaux, France.
Bibtex reference
You can download the extension by right-click + Save as
NetLogo 6 version
NetLogo 5 version
nneco
folder either in your .nlogo file's folder or in the extensions folder of the NetLogo program. Otherwise, it cannot be found by NetLogo, and it will complain about this problem.If you send your NL program on a cluster, you must send the extension too, besides other NL libraries that are necessary for remote execution of your model.
If you use this extension in a publication, please cite it as:
Yildizoglu Murat, 2021, "A NetLogo extension implementing feed-forward artificial neural networks for agents", https://yildizoglu.fr/software/nneco/, University of Bordeaux, France.
Bibtex reference
You can download the extension by right-click + Save as
NetLogo 6 version
NetLogo 5 version
Description
A simple back propagation feed forward neural network adapted for being driven by another user class. It has only one hidden layer.
Adapted with corrections from the Neural class by Mark Watson, 1997, Intelligent Java Applications, Morgan Kaufmann, SF:CA.
My modifications are based on T. Masters, 1993, Practical Neural Recipes in C++, Academic Press, San Diego: CA. The later is a very nice reference on ANNs.
Copyright : Copyright (c) Murat Yildizoglu November 2009-Today
Adapted with corrections from the Neural class by Mark Watson, 1997, Intelligent Java Applications, Morgan Kaufmann, SF:CA.
My modifications are based on T. Masters, 1993, Practical Neural Recipes in C++, Academic Press, San Diego: CA. The later is a very nice reference on ANNs.
Copyright : Copyright (c) Murat Yildizoglu November 2009-Today
Usage
To use this extension, copy the nneco folder in the extensions folder of NetLogo.
The package contains
You can use this extension to attach a NN to a turtle or to the observer.
The methods that you can use:
The package contains
- an ExtensionManager: NNecoExtension.java
- a class file for the neural network (NN): NNeco.java
You can use this extension to attach a NN to a turtle or to the observer.
The methods that you can use:
make: creates the ANN for the agent
You call the command: Make (i,h,o, winsize, numEpoch) with parameters necessary to design the ANN:
• nnindex, an index that references the ANN that will be created for this turtle (for example, with the value who + 1)
• in, number of inputs
• hn, number of hidden nodes on the hidden layer
• on, number of outputs
• winSIze, the number of last periods to use to train
• numEpoch, number of runs to train in each period
• numPeriods, number of periods (the total length of the inputs and output tables
updateInputs: extends the input matrix using the provided last period's observations
Asks the NNeco to update its inputs matrix, with parameters
updateOutputs: extends the output matrix using the provided last period's performance
Asks the NNeco to update its outputs matrix
Train: Trains the NN using the inputs and outputs matrices
Asks the NNeco to train itself, given the available data
and the period of the simulation
predict: Returns the performance predicted by the NN, as a function of the provided input
Asks the NNeco to return its expectations as a function of the provided input
and its actual state
Returns expectations: a list containing the predicted performance given the provided inputs.
You call the command: Make (i,h,o, winsize, numEpoch) with parameters necessary to design the ANN:
• nnindex, an index that references the ANN that will be created for this turtle (for example, with the value who + 1)
• in, number of inputs
• hn, number of hidden nodes on the hidden layer
• on, number of outputs
• winSIze, the number of last periods to use to train
• numEpoch, number of runs to train in each period
• numPeriods, number of periods (the total length of the inputs and output tables
updateInputs: extends the input matrix using the provided last period's observations
Asks the NNeco to update its inputs matrix, with parameters
- nnindex, the reference to the ANN to update
- period : the actual number of observations = nb of periods
- inputs : the list containing the inputs values vector containing the same number of elements as i in make
updateOutputs: extends the output matrix using the provided last period's performance
Asks the NNeco to update its outputs matrix
- nnindex, the reference to the ANN to update
- period : the actual number of observations = nb of periods
- outputs : the list containing the outputs values vector containing the same number of elements as o in make
Train: Trains the NN using the inputs and outputs matrices
Asks the NNeco to train itself, given the available data
and the period of the simulation
- nnindex, the reference to the ANN to train
- period : the actual number of observations = nb of periods
predict: Returns the performance predicted by the NN, as a function of the provided input
Asks the NNeco to return its expectations as a function of the provided input
and its actual state
- nnindex, the reference to the ANN to use for prediction
- inputs : the list containing the input values vector containing the same number of elements as i in make
Returns expectations: a list containing the predicted performance given the provided inputs.
A minimalistic example for demonstrating its usage
This is a very simple example where each turtle tries to learn the values of a function and train its ANN using the observed errors.
Again, Right click + Save as… to download the models
Example for NetLogo 6
Example for NetLogo 5
Again, Right click + Save as… to download the models
Example for NetLogo 6
Example for NetLogo 5