mdp.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 __MDP_H_
00030 #define __MDP_H_
00031 
00032 #include <cstdlib>
00033 #include <cstdio>
00034 
00035 #define EPS_ERROR 0.000001
00036 
00037 //the maximum size of the heap
00038 #define MAXSTATESPACESIZE 20000000
00039 
00040 class CMDPSTATE;
00041 class CMDPACTION
00042 {
00043 
00044 //data
00045 public:
00046         int ActionID;
00047         int SourceStateID;
00048         vector<int> SuccsID;
00049         vector<int> Costs;
00050         vector<float> SuccsProb;
00051         void* PlannerSpecificData;
00052 
00053 //constructors
00054 public:
00055         CMDPACTION(int ID, int sourcestateid) 
00056           {
00057                 ActionID = ID;
00058                 SourceStateID = sourcestateid;
00059                 PlannerSpecificData = NULL;
00060           };
00061         ~CMDPACTION()
00062         {
00063                 if(PlannerSpecificData != NULL)
00064                 {
00065                         SBPL_FPRINTF(stderr, "ERROR: state deletion: planner specific data is not deleted\n");
00066                         throw new SBPL_Exception();
00067                 }
00068         };
00069 
00070 //functions
00071 public:
00072         bool Delete();
00073         bool IsValid();
00074         void AddOutcome(int OutcomeStateID, int OutcomeCost, float OutcomeProb);
00075         int GetIndofMostLikelyOutcome();
00076         int GetIndofOutcome(int OutcomeID);
00077         bool DeleteAllOutcomes();
00078 
00079 private:
00080 
00081 //operators
00082 public:
00083   void operator = (const CMDPACTION& rhsaction);
00084 
00085 
00086 };
00087 
00088 
00089 class CMDPSTATE
00090 {
00091 //data
00092 public:
00093         int StateID;
00094         vector<CMDPACTION*> Actions;
00095         vector<int> PredsID;
00096         void* PlannerSpecificData;
00097 
00098 //constructors
00099 public:
00100         CMDPSTATE(int ID) 
00101           {
00102                 StateID = ID;
00103                 PlannerSpecificData = NULL;
00104           };
00105         ~CMDPSTATE()
00106         {
00107                 if(PlannerSpecificData != NULL)
00108                 {
00109                         SBPL_FPRINTF(stderr, "ERROR: state deletion: planner specific data is not deleted\n");
00110                         throw new SBPL_Exception();
00111                 }
00112         };
00113 
00114 //functions
00115 public:
00116         bool Delete();
00117         CMDPACTION* AddAction(int ID);
00118         bool ContainsPred(int stateID);
00119         bool AddPred(int stateID);
00120         bool RemovePred(int stateID);
00121         bool RemoveAllActions();
00122         CMDPACTION* GetAction(int actionID);
00123 
00124 private:
00125 
00126 //operators
00127 public:
00128 
00129   void operator = (const CMDPSTATE& rhsstate);
00130 
00131 };
00132 
00133 class CMDP
00134 {
00135 
00136 //data
00137 public:
00138         vector<CMDPSTATE*> StateArray;
00139 
00140 //constructors
00141 public:
00142         CMDP()
00143           {
00144           };
00145         ~CMDP()
00146         {
00147         };
00148 
00149 //functions
00150 public:
00151   bool empty();
00152   bool full();
00153   //creates numofstates states. Their ids are their orderings for Original, Thresholded & Search MDPs
00154   bool Create(int numofstates);
00155   bool Delete();
00156   void Print(FILE* fOut);
00157   CMDPSTATE* AddState(int StateID);
00158 
00159 private:
00160 
00161 
00162 
00163 
00164 
00165 //operators
00166 public:
00167 
00168 
00169 };
00170 
00171 
00172 
00173 
00174 #endif
 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