Connection.h 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/**
 * DESCRIPTION OF THE FILE
 *
 * @author Michal Kravčenko
 * @date 13.6.18 -
 */

#ifndef INC_4NEURO_CONNECTION_H
#define INC_4NEURO_CONNECTION_H

#include "../Neuron/Neuron.h"
12 13
#include "ConnectionWeight.h"

14
class Neuron;
15
class ConnectionWeight;
16 17

/**
18
 * Class representing directed connection between two neurons
19 20 21
 */
class Connection {
private:
22

23
    /**
24
     * Pointer to an object evaluating the weight function
25
     */
26
    ConnectionWeight *con = nullptr;
27
    /**
28
     * Pointer to the Neuron on the receiving end of this connection
29
     */
30
    Neuron *neuron_in = nullptr;
31 32

    /**
33
     * Pointer to the Neuron on the signaling end of this connection
34
     */
35 36
    Neuron *neuron_out = nullptr;

37 38 39 40 41
    /**
     *
     */
    bool delete_connection = true;

42

43
    //TODO pridat gradient pro ucely backpropagation
44 45 46

public:

47 48 49 50 51 52 53 54
    /**
     * Returns a new object reprresenting an edge using the same weight function as this one
     * @param n_in
     * @param n_out
     * @return
     */
    virtual Connection* get_copy(Neuron *n_in, Neuron *n_out) final;

55
   /**
56 57 58 59 60
    *
    * @param n_in
    * @param n_out
    * @param con
    * @param delete_weight
61
    */
62
    Connection(Neuron *n_in, Neuron *n_out, ConnectionWeight* con, bool delete_weight = true);
63 64

    /**
65
     * Destructor, deletes the 'con' object
66
     */
67
    ~Connection();
68 69

    /**
70 71 72
     * Takes the array of double values and alters the corresponding weights associated
     * with the 'con' object
     * @param[in] values Values to be added to the associated weights
73
     */
74
    void adjust_weights(double *values);
75 76

    /**
77 78 79
     * Takes the array of double values and sets the corresponding weights associated
     * with the 'con' object
     * @param[in] values Values to be set to the associated weights
80
     */
81
    void set_weights(double *values);
82 83

    /**
84 85 86
     * Takes the output signal of Neuron 'neuron_out', multiplies it by the result of the
     * weight function associated with this connection and adds the result to the potential
     * of the Neuron 'neuron_in'
87 88 89 90 91
     */
    void pass_signal();


    /**
92
     * Returns the pointer to the Neuron on the receiving end of this connection
93 94 95 96 97
     * @return
     */
    Neuron* get_neuron_in();

    /**
98
     * Returns the pointer to the Neuron on the signaling end of this connection
99 100 101 102 103 104 105 106
     * @return
     */
    Neuron* get_neuron_out();

};


#endif //INC_4NEURO_CONNECTION_H