Reinforcement Learning Toolbox 2.0
last updated:
General
Documentation
Manual
Tutorial
Class Reference
Master Thesis
Examples
Related Papers
Downloads
Links
News
mailto:webmaster
Main Page     Class Hierarchy   Compound List   File List   Compound Members   File Members

cstatemodifier.h

Go to the documentation of this file.
00001 // Copyright (C) 2003
00002 // Gerhard Neumann (gneumann@gmx.net)
00003 // Stephan Neumann (sneumann@gmx.net) 
00004 //                
00005 // This file is part of RL Toolbox.
00006 // http://www.igi.tugraz.at/ril_toolbox
00007 //
00008 // All rights reserved.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions
00012 // are met:
00013 // 1. Redistributions of source code must retain the above copyright
00014 //    notice, this list of conditions and the following disclaimer.
00015 // 2. Redistributions in binary form must reproduce the above copyright
00016 //    notice, this list of conditions and the following disclaimer in the
00017 //    documentation and/or other materials provided with the distribution.
00018 // 3. The name of the author may not be used to endorse or promote products
00019 //    derived from this software without specific prior written permission.
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00024 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00026 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00027 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00028 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00030 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 
00032 #ifndef C_STATEMODIFIER_H
00033 #define C_STATEMODIFIER_H
00034 
00035 #ifndef M_PI
00036 #define M_PI 3.14159265358979323846
00037 #endif
00038 
00039 #include <list>
00040 #include "cstateproperties.h"
00041 #include <newmat/newmat.h>
00042 
00043 class CStateCollection;
00044 class CStateCollectionImpl;
00045 class CState;
00046 
00047 class CDataSet;
00048 class CDataSet1D;
00049 class CFeatureVFunction;
00051 
00062 class CStateModifier : public CStateProperties
00063 {
00064 protected:
00065         bool changeState;
00066 
00067         CStateModifier();
00068 
00069         std::list<CStateCollectionImpl *> *stateCollections;
00070 
00071         virtual void registerStateCollection(CStateCollectionImpl *stateCollection);
00072         virtual void removeStateCollection(CStateCollectionImpl *stateCollection);
00073 
00074         virtual void stateChanged();
00075 
00076 
00077         friend class CStateCollectionImpl;
00078 public:
00080         CStateModifier(unsigned int numContinuousStates, unsigned int numDiscreteStates);
00081         virtual ~CStateModifier();
00082 
00084         virtual void getModifiedState(CStateCollection *originalState, CState *modifiedState) = 0;
00085 
00086         
00087 };
00088 
00090 
00093 class CNeuralNetworkStateModifier : public CStateModifier
00094 {
00095 protected:
00096         CStateProperties *originalState;
00097         unsigned int *dimensions;
00098         unsigned int numDim;
00099 
00100         ColumnVector *input_mean;
00101         ColumnVector *input_std;
00102 
00103         ColumnVector *buffVector;
00104 
00105         virtual void preprocessInput(ColumnVector *input, ColumnVector *norm_input);
00106         
00108         static int getNumInitContinuousStates(CStateProperties *properties, unsigned int *dimensions,unsigned int numDim);
00109 public:
00110         bool normValues;
00111 
00112         CNeuralNetworkStateModifier(CStateProperties *originalState);
00113         CNeuralNetworkStateModifier(CStateProperties *originalState, unsigned int *dimensions, unsigned int numDim);
00114         ~CNeuralNetworkStateModifier();
00115 
00117 
00120         virtual void getModifiedState(CStateCollection *originalState, CState *modifiedState);
00121 
00122         void setPreprocessing(ColumnVector *input_mean, ColumnVector *input_std);
00123 };
00124 
00126 
00135 class CFeatureCalculator : public CStateModifier
00136 {
00137 protected:
00139 
00142         void normalizeFeatures(CState *featState);
00143 
00144         unsigned int numFeatures;
00145         unsigned int numActiveFeatures;
00146 
00147         CFeatureCalculator();
00148 
00150         void initFeatureCalculator(unsigned int numFeatures, unsigned int numActiveFeatures);
00151 
00152         CStateProperties *originalState;
00153 public:
00154         CFeatureCalculator(unsigned int numFeatures, unsigned int numActiveFeatures);
00155         virtual ~CFeatureCalculator() {};
00156 
00157         virtual unsigned int getNumFeatures();
00158         virtual unsigned int getNumActiveFeatures();
00159 
00160         virtual unsigned int getDiscreteStateSize(unsigned int i);
00161         virtual unsigned int getDiscreteStateSize();
00162 
00163         virtual double getMin(unsigned int i);
00164         virtual double getMax(unsigned int i);
00165 
00167 
00170         CStateProperties *getOriginalState() {return originalState;};
00171         void setOriginalState(CStateProperties *originalState) {this->originalState = originalState;};
00172 };
00173 
00174 class CNewFeatureCalculator
00175 {
00176 public:
00177         virtual ~CNewFeatureCalculator() {};
00178 
00179         virtual CFeatureCalculator * getFeatureCalculator(CFeatureVFunction *vFunction, CDataSet *inputData, CDataSet1D *outputData) = 0;
00180 };
00181 
00183 
00186 class CStateMultiModifier
00187 {
00188 protected:
00189         std::list<CState *> *states;
00190         std::list<CStateModifier *> *modifiers;
00191 public:
00192         CStateMultiModifier();
00193         virtual ~CStateMultiModifier();
00194 
00195         virtual void addStateModifier(CStateModifier *featCalc);
00196 
00197         std::list<CStateModifier *> *getStateModifiers();
00198 };
00199 
00200 class CStateVariablesChooser : public CStateModifier
00201 {
00202 protected:
00203         unsigned int *contStatesInd;
00204         unsigned int *discStatesInd;
00205 
00206         CStateProperties *originalState;
00207 public:
00208         CStateVariablesChooser(unsigned int numContStates, unsigned int *contStatesInd, unsigned int numDiscStates, unsigned int *discStatesInd, CStateProperties *originalState = NULL);
00209 
00210         ~CStateVariablesChooser();
00211 
00212 
00213         virtual void getModifiedState(CStateCollection *originalState, CState *modifiedState);
00214 };
00215 
00216 #endif
00217