environment_XXX.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Maxim Likhachev
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  * 
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the University of Pennsylvania nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  * 
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 #ifndef __ENVIRONMENT_XXX_H_
00030 #define __ENVIRONMENT_XXX_H_
00031 
00032 
00033 #define XXX_MAXACTIONSWIDTH 9           
00034 
00035 typedef struct ENV_XXX_CONFIG
00036 {
00037         //parameters that are read from the configuration file
00038         unsigned int StartX1;
00039         unsigned int StartX2;
00040         unsigned int StartX3;
00041         unsigned int StartX4;
00042         unsigned int GoalX1;
00043         unsigned int GoalX2;
00044         unsigned int GoalX3;
00045         unsigned int GoalX4;
00046 
00047 
00048         //derived and initialized elsewhere parameters
00049 
00050 } EnvXXXConfig_t;
00051 
00052 typedef struct ENVXXXHASHENTRY
00053 {
00054         int stateID;
00055         unsigned int X1;
00056         unsigned int X2;
00057         unsigned int X3;
00058         unsigned int X4;
00059 
00060 } EnvXXXHashEntry_t;
00061 
00062 typedef struct
00063 {
00064 
00065         int startstateid;
00066         int goalstateid;
00067 
00068         //hash table of size x_size*y_size. Maps from coords to stateId 
00069         int HashTableSize;
00070         vector<EnvXXXHashEntry_t*>* Coord2StateIDHashTable;
00071 
00072         //vector that maps from stateID to coords       
00073         vector<EnvXXXHashEntry_t*> StateID2CoordTable;
00074 
00075         //any additional variables
00076 
00077 }EnvironmentXXX_t;
00078 
00079 
00082 class EnvironmentXXX : public DiscreteSpaceInformation
00083 {
00084 
00085 public:
00088         bool InitializeEnv(const char* sEnvFile);
00089 
00090 
00093         bool InitializeMDPCfg(MDPConfig *MDPCfg);
00096         int  GetFromToHeuristic(int FromStateID, int ToStateID);
00099         int  GetGoalHeuristic(int stateID);
00102         int  GetStartHeuristic(int stateID);
00105         void SetAllActionsandAllOutcomes(CMDPSTATE* state);
00108         void SetAllPreds(CMDPSTATE* state);
00111         void GetSuccs(int SourceStateID, vector<int>* SuccIDV, vector<int>* CostV);
00114         void GetPreds(int TargetStateID, vector<int>* PredIDV, vector<int>* CostV);
00115 
00118         int      SizeofCreatedEnv();
00121         void PrintState(int stateID, bool bVerbose, FILE* fOut=NULL);
00124         void PrintEnv_Config(FILE* fOut);
00125 
00126 
00127     ~EnvironmentXXX(){};
00128 
00129 private:
00130 
00131         //member variables
00132         EnvXXXConfig_t EnvXXXCfg;
00133         EnvironmentXXX_t EnvXXX;
00134 
00135 
00136         
00137         void ReadConfiguration(FILE* fCfg);
00138 
00139         void InitializeEnvConfig();
00140 
00141         unsigned int GETHASHBIN(unsigned int X1, unsigned int X2, 
00142                                                 unsigned int X3, unsigned int X4);
00143 
00144         void PrintHashTableHist();
00145 
00146 
00147         EnvXXXHashEntry_t* GetHashEntry(unsigned int X1, unsigned int X2, 
00148                                                                                 unsigned int X3, unsigned int X4);
00149 
00150 
00151         EnvXXXHashEntry_t* CreateNewHashEntry(unsigned int X1, unsigned int X2, 
00152                                                                                                         unsigned int X3, unsigned int X4);
00153 
00154 
00155         void CreateStartandGoalStates();
00156 
00157         void InitializeEnvironment();
00158 
00159 
00160         void AddAllOutcomes(unsigned int SourceX1, unsigned int SourceX2, unsigned int SourceX3,
00161                                                 unsigned int SourceX4, CMDPACTION* action, int cost);
00162 
00163         void ComputeHeuristicValues();
00164 
00165 
00166 };
00167 
00168 
00169 #endif
00170 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


sbpl
Author(s): Maxim Likhachev/maximl@seas.upenn.edu
autogenerated on Fri Jan 18 2013 13:41:53