inspectable.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: inspectable.h,v $ 00023 * Revision 1.9 2006/12/21 11:44:17 martius 00024 * commenting style for doxygen //< -> ///< 00025 * FOREACH and FOREACHC are macros for collection iteration 00026 * 00027 * Revision 1.8 2006/07/20 17:14:34 martius 00028 * removed std namespace from matrix.h 00029 * storable interface 00030 * abstract model and invertablemodel as superclasses for networks 00031 * 00032 * Revision 1.7 2006/07/14 12:23:58 martius 00033 * selforg becomes HEAD 00034 * 00035 * Revision 1.5.6.1 2006/06/25 16:51:35 martius 00036 * configureable has name and revision 00037 * a robot is configureable by default 00038 * 00039 * Revision 1.5 2005/10/27 15:46:38 martius 00040 * inspectable interface is expanded to structural information for network visualiser 00041 * 00042 * Revision 1.4 2005/10/06 17:06:57 martius 00043 * switched to stl lists 00044 * 00045 * Revision 1.3 2005/09/11 11:20:01 martius 00046 * virtual destructor 00047 * 00048 * Revision 1.2 2005/08/06 20:47:54 martius 00049 * Commented 00050 * 00051 * Revision 1.1 2005/08/03 20:28:57 martius 00052 * inspectable interface 00053 * 00054 * * 00055 ***************************************************************************/ 00056 #ifndef __INSPECTABLE_H 00057 #define __INSPECTABLE_H 00058 00059 #include <list> 00060 #include <utility> 00061 #include <string> 00062 #include "stl_adds.h" 00063 00064 /** 00065 * Interface for inspectable objects. 00066 * That means that one can read out some internal parameters indentified by string keys 00067 */ 00068 class Inspectable { 00069 public: 00070 00071 typedef std::string iparamkey; 00072 typedef double iparamval; 00073 00074 typedef std::list<iparamkey> iparamkeylist; 00075 typedef std::list<iparamval> iparamvallist; 00076 00077 typedef struct ILayer{ 00078 ILayer(const std::string& vectorname, const std::string& biasname, 00079 int dimension, int rank, const std::string& layername) 00080 : vectorname(vectorname), biasname(biasname), 00081 dimension(dimension), rank(rank), layername(layername) {} 00082 std::string vectorname; //< prefix of the internal parameter vector e.g. "v" 00083 std::string biasname; ///< prefix of the internal parameter vector used as bias for the neurons e.g. "h" 00084 int dimension; ///< length of the vector (number of units) 00085 int rank; ///< rank of the layer (0 are input layers) 00086 std::string layername; ///< name of the layer as displayed by the visualiser 00087 }ILayer; 00088 00089 typedef struct IConnection{ 00090 IConnection(const std::string& matrixname, const std::string& vector1, const std::string& vector2) 00091 : matrixname(matrixname), vector1(vector1), vector2(vector2) {} 00092 std::string matrixname; ///< matrix name is the prefix of the internal parameter matrix e.g. "A" 00093 std::string vector1; ///< vectorname of input layer 00094 std::string vector2; ///< vectorname of output layer 00095 }IConnection; 00096 00097 typedef std::list<ILayer> ilayerlist; 00098 typedef std::list<IConnection> iconnectionlist; 00099 00100 /// nice predicate function for finding a Layer with its vectorname 00101 struct matchName : public std::unary_function<ILayer, bool> { 00102 matchName(std::string name) : name(name) {} 00103 std::string name; 00104 bool operator()(ILayer l) { return l.vectorname == name; } 00105 }; 00106 00107 virtual ~Inspectable(){} 00108 /** The list of the names of all internal parameters given by getInternalParams(). 00109 The naming convention is "v[i]" for vectors 00110 and "A[i][j]" for matrices, where i, j start at 0. 00111 @return: list of keys 00112 */ 00113 virtual iparamkeylist getInternalParamNames() const = 0; 00114 /** @return: list of values 00115 */ 00116 virtual iparamvallist getInternalParams() const = 0; 00117 00118 /** Specifies which parameter vector forms a structural layer (in terms of a neural network) 00119 The ordering is important. The first entry is the input layer and so on. 00120 @return: list of layer names with dimension 00121 00122 */ 00123 virtual ilayerlist getStructuralLayers() const { return std::list<ILayer>();} 00124 /** Specifies which parameter matrix forms a connection between layers (in terms of a neural network) 00125 The orderning is not important. 00126 @return: list of layer names with dimension 00127 */ 00128 virtual iconnectionlist getStructuralConnections() const { return std::list<IConnection>();} 00129 00130 }; 00131 00132 #endif

Generated on Tue Jan 16 02:14:35 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8