// CSC 143 Computer Programming II Spring 1999 Instructor: Keith Hughes
// Homework 3
// File : \\Venus\katy\CIS143\Homework3\AdalineNetwork\NeuralNet.h
// Purpose : Declaration for NeuralNet and AdalineNet classes.
// Author : Hsin-yi F. Berg
// Date : 5/9/1999 Sun.
// Last Update: 5/28/1999 Fri.
// Update Note: NeuralNet is moved in this header file from layer.h
//                 AdalineNet is added in this header file.


#include "layer.h"
#include <iostream.h>
#include <fstream.h>

typedef int ID;

class Neuronlayer;
class LinkLayer;

class NeuralNet

        Default constructor for an NeuralNet. NeuralNet is created empty.
        NeuralNet::NeuralNet(const NeuralNet &otherNeuralNet)

        Copy constructor for an NeuralNet.
    NeuralNet(const NeuralNet &otherNeuralNet);


        Destructor for an NeuralNet.

        NeuralNet &NeuralNet::operator=(const NeuralNet &otherNeuralNet)

        Assignment operator for this NeuralNet
    NeuralNet &operator=(const NeuralNet &otherNeuralNet);

        void NeuralNet::SetHowManyNeuronLayers(int size)

        Set how many neuron layers in the NeuralNet.
        Cannot set the number of Neuron Layers to 0.
    void SetHowManyNeuronLayers(int size);

        void NeuralNet::SetSizeOfNeuronLayer(int whichLayer, int size)

        Set how many neurons a paticular NeuronLayer contains.
        Cannot set the number of Neurons to 0.
    void SetSizeOfNeuronLayer(int whichLayer, int size);

        void NeuralNet::SetInputValue(int whichNeuron, double Value)

        Set the value of a specific Neuron in input NeuronLayer
    void SetInputValue(int whichNeuron, double Value);

        double NeuralNet::GetOutputValue(int whichNeuron)

        Get the value of a specific Neuron in output NeuronLayer
    double GetOutputValue(int whichNeuron) const;

        void NeuralNet::Print(ostream &out) const

        Print out the internal state of the NeuralNet
        to client supplied ostream
    void Print(ostream &out) const;

        void NeuralNet::Fire(void)

        Fire the whole NeuralNet layer by layer
    void Fire(void);

        void NeuralNet::InterConnect(void)

        Create a fully connected Network - 
        Eevery neuron in one NeuronLayer is connected to every neuron in
        adjecent NeuronLayer.

    void InterConnect(void);

        void NeuralNet::ReadFromFile(istream &in)

        Read data into this NeuralNet instance from file specified by "in"
    void NeuralNet::ReadFromFile(istream &in);
        void NeuralNet::WriteToFile(ostream &out)

        Write data of this NeuralNet instance to file specified by "out"
    void NeuralNet::WriteToFile(ostream &out);

    // id_count keeps track of how many NeuralNet that have been created
    static int id_count;        
    // each NeuralNet automatically gets an unique id when it's created
    ID id;
    // number of Neurons in this NeuronLayer
    int numNeuronLayer;
    // neuronLayers points to a collection of NeuronLayers
    NeuronLayer *neuronLayers;
    // linkLayers points to a collection of LinkLayers
    LinkLayer *linkLayers;

        void NeuralNet::clone(const NeuralNet &otherNeuralNet)

        Deep copy of otherNeuralNet.
        This NeuralNet must be cleaned up before calling clone.
    void clone(const NeuralNet &otherNeuralNet);

        void NeuralNet::destroy(void)

        Clean up this NeuralNet.
        Deallocate all dynamic memory, reinitialize it's members.
    void destroy(void);

        void NeuralNet::Connect(Neuron &input_Neuron, Neuron &output_Neuron, Link &link, double weight)

        Private Utility:
        Connecting a link to its input and output neurons with a specific weight.
    void Connect(Neuron &input_Neuron, Neuron &output_Neuron, Link &link, double weight);



Back    Top