InvertMotorNStep Class Reference

class for robot controller that uses the georg's matrixlib for direct matrix inversion for n channels (simple one layer networks) More...

#include <invertmotornstep.h>

Inherits InvertMotorController, and Teachable.

Inheritance diagram for InvertMotorNStep:

Inheritance graph
[legend]
Collaboration diagram for InvertMotorNStep:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InvertMotorNStep (const InvertMotorNStepConf &conf=getDefaultConf())
virtual void init (int sensornumber, int motornumber, RandGen *randGen=0)
 initialisation of the controller with the given sensor/ motornumber Must be called before use.
virtual ~InvertMotorNStep ()
virtual int getSensorNumber () const
 returns the number of sensors the controller was initialised with or 0 if not initialised
virtual int getMotorNumber () const
 returns the mumber of motors the controller was initialised with or 0 if not initialised
virtual void step (const sensor *, int number_sensors, motor *, int number_motors)
 performs one step (includes learning).
virtual void stepNoLearning (const sensor *, int number_sensors, motor *, int number_motors)
 performs one step without learning. Calulates motor commands from sensor inputs.
virtual bool store (FILE *f) const
 stores the controller values to a given file.
virtual bool restore (FILE *f)
 loads the controller values from a given file.
virtual std::list< ILayergetStructuralLayers () const
 Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important.
virtual std::list< IConnectiongetStructuralConnections () const
 Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important.
virtual void setMotorTeachingSignal (const motor *teaching, int len)
 The given motor teaching signal is used for this timestep.
virtual void setSensorTeachingSignal (const sensor *teaching, int len)
 The given sensor teaching signal (distal learning) is used for this timestep.
void getLastMotors (motor *motors, int len)
void getLastSensors (sensor *sensors, int len)
virtual void setMotorTeaching (const matrix::Matrix &teaching)
 The given motor teaching signal is used for this timestep.
virtual void setSensorTeaching (const matrix::Matrix &teaching)
 The given sensor teaching signal (distal learning) is used for this timestep.
virtual matrix::Matrix getLastMotorValues ()
 returns the last motor values (useful for cross motor coupling)
virtual matrix::Matrix getLastSensorValues ()
 returns the last sensor values (useful for cross sensor coupling)
void calcCandHUpdatesTeaching (matrix::Matrix &C_update, matrix::Matrix &H_update, int y_delay)
 calculates the Update for C and H using the teaching signal
virtual void setReinforcement (double reinforcement)
 set the reinforcement signal for this timestep.
void setSensorWeights (const matrix::Matrix &weights)
 sets the sensor channel weights (matrix should be (getSensorNumber() x 1)
matrix::Matrix getSensorWeights () const
matrix::MatrixgetC ()
 reference to C-matrix
double getE () const
void kwtaInhibition (matrix::Matrix &weightmatrix, unsigned int k, double damping)
 k-winner take all inhibition for synapses.
void limitC (matrix::Matrix &weightmatrix, unsigned int rfSize)
 sets all connections to zero which are further away then rfSize from the diagonal.

Static Public Member Functions

static InvertMotorNStepConf getDefaultConf ()
static double clip095 (double x)
static double regularizedInverse (double v)

Public Attributes

matrix::Matrix A
 Model Matrix (motors to sensors).
matrix::Matrix S
 additional Model Matrix (sensors to sensors)
matrix::Matrix SD
 additional Model Matrix (sensors derivatives to sensors)
matrix::Matrix C
 Controller Matrix.
matrix::Matrix H
 Controller Bias.
matrix::Matrix B
 Model Bias.

Protected Member Functions

virtual void fillBuffersAndControl (const sensor *x_, int number_sensors, motor *y_, int number_motors)
 puts the sensors in the ringbuffer, generate controller values and put them in the
virtual void calcEtaAndBufferIt (int delay)
 calculates the first shift into the motor space useing delayed motor values.
virtual void calcXsi (int delay)
 calculates xsi for the current time step using the delayed y values
virtual void learnController (int delay)
 learn H,C with motors y and corresponding sensors x
virtual void calcCandHUpdates (matrix::Matrix &C_update, matrix::Matrix &H_update, int delay)
 calculates the Update for C and H
virtual void updateCandH (const matrix::Matrix &C_update, const matrix::Matrix &H_update, double squashSize)
 updates the matrix C and H
virtual void learnModel (int delay)
 learn A, (and S) using motors y and corresponding sensors x
virtual matrix::Matrix model (const matrix::Matrix *x_buffer, int delay, const matrix::Matrix &y)
 calculates the predicted sensor values
virtual void management ()
 handles inhibition damping etc.
virtual matrix::Matrix calculateControllerValues (const matrix::Matrix &x_smooth)
 returns controller output for given sensor values
matrix::Matrix calcDerivatives (const matrix::Matrix *buffer, int delay)
 Calculates first and second derivative and returns both in on matrix (above).

Protected Attributes

unsigned short number_sensors
unsigned short number_motors
NoiseGeneratorBNoiseGen
 Noisegenerator for noisy bias.
NoiseGeneratorYNoiseGen
 Noisegenerator for noisy motor output.
matrix::Matrix R
 C*A.
matrix::Matrix SmallID
 small identity matrix in the dimension of R
matrix::Matrix xsi
 current output error
matrix::Matrix v
 current reconstructed error
double E_val
 value of Error function
double xsi_norm
 norm of matrix
double xsi_norm_avg
 average norm of xsi (used to define whether Modell learns)
double pain
 if the modelling error (xsi) is too high we have a pain signal
matrix::Matrixx_buffer
matrix::Matrixy_buffer
matrix::Matrixeta_buffer
matrix::Matrix zero_eta
matrix::Matrix x_smooth
matrix::Matrix y_teaching
 teaching motor signal
bool useTeaching
 flag whether there is an actual teachning signal or not
double reinforcement
 reinforcement value (set via setReinforcement())
double reinforcefactor
 reinforcement factor (set to 1 every step after learning)
int t_rand
 initial random time to avoid syncronous management of all controllers
matrix::Matrix sensorweights
 sensor channel weight (each channel gets a certain importance)
double continuity
 factor to teach for continuity: subsequent motor commands should not differ too much
double modelCompliant
 learning factor for model (or sensor) compliant learning
int managementInterval
 interval between subsequent management function calls
paramval inhibition
 inhibition strength for sparce kwta strategy (is scaled with epsC)
paramval kwta
 (int) number of synapses that get strengthend
paramval limitRF
 (int) receptive field of motor neurons (number of offcenter sensors) if null then no limitation. Mutual exclusive with inhibition
paramval dampS
 damping of S matrix
paramval dampC
 damping of C matrix
paramval activeExplore
 decides whether and how strong the backpropagated error is used as a control signal
paramval cfactor
paramval cnondiagabs
paramval cdiagabs
paramval noiseY
 noise strength for y
InvertMotorNStepConf conf

Detailed Description

class for robot controller that uses the georg's matrixlib for direct matrix inversion for n channels (simple one layer networks)

Implements standart parameters: eps, rho, mu, stepnumber4avg, stepnumber4delay


Constructor & Destructor Documentation

InvertMotorNStep ( const InvertMotorNStepConf conf = getDefaultConf()  ) 

~InvertMotorNStep (  )  [virtual]


Member Function Documentation

void calcCandHUpdates ( matrix::Matrix C_update,
matrix::Matrix H_update,
int  delay 
) [protected, virtual]

calculates the Update for C and H

void calcCandHUpdatesTeaching ( matrix::Matrix C_update,
matrix::Matrix H_update,
int  y_delay 
)

calculates the Update for C and H using the teaching signal

Matrix calcDerivatives ( const matrix::Matrix buffer,
int  delay 
) [protected]

Calculates first and second derivative and returns both in on matrix (above).

We use simple discrete approximations:

\[ f'(x) = (f(x) - f(x-1)) / 2 \]

\[ f''(x) = f(x) - 2f(x-1) + f(x-2) \]

where we have to go into the past because we do not have f(x+1). The scaling can be neglegted.

void calcEtaAndBufferIt ( int  delay  )  [protected, virtual]

calculates the first shift into the motor space useing delayed motor values.

Matrix calculateControllerValues ( const matrix::Matrix x_smooth  )  [protected, virtual]

returns controller output for given sensor values

Parameters:
x_smooth smoothed sensors Matrix(number_channels,1)

void calcXsi ( int  delay  )  [protected, virtual]

calculates xsi for the current time step using the delayed y values

double clip095 ( double  x  )  [static]

void fillBuffersAndControl ( const sensor x_,
int  number_sensors,
motor y_,
int  number_motors 
) [protected, virtual]

puts the sensors in the ringbuffer, generate controller values and put them in the

matrix::Matrix& getC (  )  [inline]

reference to C-matrix

static InvertMotorNStepConf getDefaultConf (  )  [inline, static]

double getE (  )  const [inline]

void getLastMotors ( motor motors,
int  len 
)

matrix::Matrix getLastMotorValues (  )  [virtual]

returns the last motor values (useful for cross motor coupling)

Implements Teachable.

void getLastSensors ( sensor sensors,
int  len 
)

matrix::Matrix getLastSensorValues (  )  [virtual]

returns the last sensor values (useful for cross sensor coupling)

Implements Teachable.

virtual int getMotorNumber (  )  const [inline, virtual]

returns the mumber of motors the controller was initialised with or 0 if not initialised

Implements AbstractController.

virtual int getSensorNumber (  )  const [inline, virtual]

returns the number of sensors the controller was initialised with or 0 if not initialised

Implements AbstractController.

matrix::Matrix getSensorWeights (  )  const [inline]

list< Inspectable::IConnection > getStructuralConnections (  )  const [virtual]

Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important.

Returns:
: list of layer names with dimension

Reimplemented from Inspectable.

list< Inspectable::ILayer > getStructuralLayers (  )  const [virtual]

Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important.

The first entry is the input layer and so on.

Returns:
: list of layer names with dimension

Reimplemented from Inspectable.

void init ( int  sensornumber,
int  motornumber,
RandGen randGen = 0 
) [virtual]

initialisation of the controller with the given sensor/ motornumber Must be called before use.

The random generator is optional.

Implements AbstractController.

void kwtaInhibition ( matrix::Matrix weightmatrix,
unsigned int  k,
double  damping 
)

k-winner take all inhibition for synapses.

k largest synapses are strengthed and the rest are inhibited. strong synapes are scaled by 1+(damping/k) and weak synapses are scaled by 1-(damping/(n-k)) where n is the number of synapes

Parameters:
weightmatrix reference to weight matrix. Synapses for a neuron are in one row. The inhibition is done for all rows independently
k number of synapes to strengthen
damping strength of supression and exitation (typically 0.001)

void learnController ( int  delay  )  [protected, virtual]

learn H,C with motors y and corresponding sensors x

void learnModel ( int  delay  )  [protected, virtual]

learn A, (and S) using motors y and corresponding sensors x

void limitC ( matrix::Matrix weightmatrix,
unsigned int  rfSize 
)

sets all connections to zero which are further away then rfSize from the diagonal.

If rfSize == 1 then only main diagonal is left. If rfSize = 2: main diagonal and upper and lower side diagonal are kept and so on and so forth.

void management (  )  [protected, virtual]

handles inhibition damping etc.

Matrix model ( const matrix::Matrix x_buffer,
int  delay,
const matrix::Matrix y 
) [protected, virtual]

calculates the predicted sensor values

double regularizedInverse ( double  v  )  [static]

bool restore ( FILE *  f  )  [virtual]

loads the controller values from a given file.

Implements Storeable.

void setMotorTeaching ( const matrix::Matrix teaching  )  [virtual]

The given motor teaching signal is used for this timestep.

It is used as a feed forward teaching signal for the controller. Please note, that the teaching signal has to be given each timestep for a continuous teaching process.

Parameters:
teaching,: matrix with dimensions (motornumber,1)

Implements Teachable.

void setMotorTeachingSignal ( const motor teaching,
int  len 
) [virtual]

The given motor teaching signal is used for this timestep.

It is used as a feed forward teaching signal for the controller. Please note, that the teaching signal has to be given each timestep for a continuous teaching process.

void setReinforcement ( double  reinforcement  )  [virtual]

set the reinforcement signal for this timestep.

It is used to calculate a factor for the update. Factor = 1-0.95*reinforcement.

Parameters:
reinforcement value between -1 and 1 (-1 bad, 0 neutral, 1 good)

void setSensorTeaching ( const matrix::Matrix teaching  )  [virtual]

The given sensor teaching signal (distal learning) is used for this timestep.

The belonging motor teachung signal is calculated by the inverse model. See setMotorTeaching

Parameters:
teaching,: matrix with dimensions (motorsensors,1)

Implements Teachable.

void setSensorTeachingSignal ( const sensor teaching,
int  len 
) [virtual]

The given sensor teaching signal (distal learning) is used for this timestep.

First the belonging motor teachung signal is calculated by the inverse model. See setMotorTeachingSignal

void setSensorWeights ( const matrix::Matrix weights  ) 

sets the sensor channel weights (matrix should be (getSensorNumber() x 1)

void step ( const sensor ,
int  number_sensors,
motor ,
int  number_motors 
) [virtual]

performs one step (includes learning).

Calulates motor commands from sensor inputs.

Implements AbstractController.

void stepNoLearning ( const sensor ,
int  number_sensors,
motor ,
int  number_motors 
) [virtual]

performs one step without learning. Calulates motor commands from sensor inputs.

Implements AbstractController.

bool store ( FILE *  f  )  const [virtual]

stores the controller values to a given file.

Implements Storeable.

void updateCandH ( const matrix::Matrix C_update,
const matrix::Matrix H_update,
double  squashSize 
) [protected, virtual]

updates the matrix C and H


Member Data Documentation

matrix::Matrix A

Model Matrix (motors to sensors).

paramval activeExplore [protected]

decides whether and how strong the backpropagated error is used as a control signal

matrix::Matrix B

Model Bias.

NoiseGenerator* BNoiseGen [protected]

Noisegenerator for noisy bias.

matrix::Matrix C

Controller Matrix.

paramval cdiagabs [protected]

paramval cfactor [protected]

paramval cnondiagabs [protected]

InvertMotorNStepConf conf [protected]

double continuity [protected]

factor to teach for continuity: subsequent motor commands should not differ too much

paramval dampC [protected]

damping of C matrix

paramval dampS [protected]

damping of S matrix

double E_val [protected]

value of Error function

matrix::Matrix* eta_buffer [protected]

matrix::Matrix H

Controller Bias.

paramval inhibition [protected]

inhibition strength for sparce kwta strategy (is scaled with epsC)

paramval kwta [protected]

(int) number of synapses that get strengthend

paramval limitRF [protected]

(int) receptive field of motor neurons (number of offcenter sensors) if null then no limitation. Mutual exclusive with inhibition

int managementInterval [protected]

interval between subsequent management function calls

double modelCompliant [protected]

learning factor for model (or sensor) compliant learning

paramval noiseY [protected]

noise strength for y

Reimplemented from InvertMotorController.

unsigned short number_motors [protected]

unsigned short number_sensors [protected]

double pain [protected]

if the modelling error (xsi) is too high we have a pain signal

matrix::Matrix R [protected]

C*A.

double reinforcefactor [protected]

reinforcement factor (set to 1 every step after learning)

double reinforcement [protected]

reinforcement value (set via setReinforcement())

matrix::Matrix S

additional Model Matrix (sensors to sensors)

matrix::Matrix SD

additional Model Matrix (sensors derivatives to sensors)

matrix::Matrix sensorweights [protected]

sensor channel weight (each channel gets a certain importance)

matrix::Matrix SmallID [protected]

small identity matrix in the dimension of R

int t_rand [protected]

initial random time to avoid syncronous management of all controllers

bool useTeaching [protected]

flag whether there is an actual teachning signal or not

matrix::Matrix v [protected]

current reconstructed error

matrix::Matrix* x_buffer [protected]

matrix::Matrix x_smooth [protected]

matrix::Matrix xsi [protected]

current output error

double xsi_norm [protected]

norm of matrix

double xsi_norm_avg [protected]

average norm of xsi (used to define whether Modell learns)

matrix::Matrix* y_buffer [protected]

matrix::Matrix y_teaching [protected]

teaching motor signal

NoiseGenerator* YNoiseGen [protected]

Noisegenerator for noisy motor output.

matrix::Matrix zero_eta [protected]


The documentation for this class was generated from the following files:
Generated on Fri Oct 30 16:29:02 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7