00001 // Copyright (C) 200300002 // 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_toolbox00007 //00008 // All rights reserved.00009 //00010 // Redistribution and use in source and binary forms, with or without00011 // modification, are permitted provided that the following conditions00012 // are met:00013 // 1. Redistributions of source code must retain the above copyright00014 // notice, this list of conditions and the following disclaimer.00015 // 2. Redistributions in binary form must reproduce the above copyright00016 // notice, this list of conditions and the following disclaimer in the00017 // documentation and/or other materials provided with the distribution.00018 // 3. The name of the author may not be used to endorse or promote products00019 // derived from this software without specific prior written permission.00020 //00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES00023 // 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, BUT00026 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,00027 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY00028 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT00029 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF00030 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.00031
00032 #ifndef CMODELSTATE_H00033 #define CMODELSTATE_H00034
00035
00036 #include "cbaseobjects.h"00037
00038 #include <vector>00039 #include <stdio.h>00040 #include "newmat/newmat.h"00041
00042
00043 classCEnvironmentModel;
00044 classCState;
00045
00047
00057classCStateCollection00058 {
00059 protected:
00060boolb_resetState;
00061
00062 public:
00063CStateCollection() {b_resetState = false;};
00064virtual~CStateCollection() {};
00066 virtualCState *getState(CStateProperties *properties) = 0;
00068 virtualCState *getState() = 0;
00070 virtualboolisMember(CStateProperties *stateModifier) = 0;
00071
00072virtualboolisResetState() {returnb_resetState;};
00073virtualvoidsetResetState(bool reset) {b_resetState = reset;};
00074 };
00075
00076
00078
00091classCState : publicCStateObject,publicCStateCollection, public ColumnVector
00092 {
00093 protected:
00094
00096int *discreteState;
00097
00099unsignedintnumActiveContinuousStates;
00101unsignedintnumActiveDiscreteStates;
00102
00103 public:
00105 CState(CStateProperties *properties);
00107 CState(CEnvironmentModel *model);
00109 CState(CState *copy);
00111
00116 CState(CStateProperties *properties, FILE *stream, bool binary = true);
00118 voidsetState(CState *copy);
00120
00122 voidresetState();
00123
00124 virtual~CState();
00125
00127
00128 virtualCState *getState(CStateProperties *properties);
00130
00131 virtualCState *getState();
00132
00136 virtualboolisMember(CStateProperties *stateModifier);
00137
00139 unsignedintgetNumActiveDiscreteStates();
00141 unsignedintgetNumActiveContinuousStates();
00142
00144 voidsetNumActiveDiscreteStates(int numActiveStates);
00146 voidsetNumActiveContinuousStates(int numActiveStates);
00147
00149 voidsaveBinary(FILE *stream);
00151 voidloadBinary(FILE *stream);
00152
00154 voidsaveASCII(FILE *stream);
00156 voidloadASCII(FILE *stream);
00157
00159 virtualCState* clone();
00160
00162 virtualdoublegetContinuousState(unsignedint dim);
00164
00166 virtualdoublegetNormalizedContinuousState(unsignedint dim);
00168 virtualintgetDiscreteState(unsignedint dim);
00169 virtualintgetDiscreteStateNumber();
00170
00172 virtualvoidsetContinuousState(unsignedint dim, double val);
00174 virtualvoidsetDiscreteState(unsignedint dim, int val);
00175
00177 virtualboolequals(CState *state);
00178
00179 virtualdoublegetDistance(ColumnVector *vector);
00180
00181 doublegetSingleStateDifference(int dim, double value);
00182
00183 };
00184
00186
00196classCStateList : virtualpublicCStateObject00197 {
00198 protected:
00200 std::vector<std::vector<double> *> *continuousStates;
00202 std::vector<std::vector<int> *> *discreteStates;
00203
00204 std::vector<bool> *resetStates;
00205
00207intnumStates;
00208 public:
00210
00212 CStateList(CStateProperties *properties);
00213 virtual~CStateList();
00214
00216
00220 voidaddState(CState *state);
00222
00227 voidgetState(unsignedint num, CState *state);
00228
00229 voidremoveLastState();
00230 voidremoveFirstState();
00231
00233
00235 virtualvoidloadBIN(FILE *stream);
00237 virtualvoidsaveBIN(FILE *stream);
00238
00240
00242 virtualvoidloadASCII(FILE *stream);
00244 virtualvoidsaveASCII(FILE *stream);
00245
00247 unsignedintgetNumStates();
00248 voidclear();
00249 };
00250
00251
00252
00253 #endif00254
00255