00001 /* mdp.h 00002 00003 ***** 00004 Copyright 1994-1997, Brown University 00005 Copyright 1998, 1999, Anthony R. Cassandra 00006 00007 All Rights Reserved 00008 00009 Permission to use, copy, modify, and distribute this software and its 00010 documentation for any purpose other than its incorporation into a 00011 commercial product is hereby granted without fee, provided that the 00012 above copyright notice appear in all copies and that both that 00013 copyright notice and this permission notice appear in supporting 00014 documentation. 00015 00016 ANTHONY CASSANDRA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00017 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY 00018 PARTICULAR PURPOSE. IN NO EVENT SHALL ANTHONY CASSANDRA BE LIABLE FOR 00019 ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00020 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00021 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00022 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00023 ***** 00024 00025 header file for mdp.c 00026 */ 00027 #ifndef MDP_H 00028 #define MDP_H 00029 00030 #include <stdio.h> 00031 00032 #include "sparse-matrix.h" 00033 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 /* This parameter is declared in ZMDP src/common/zmdpConfig.h, but 00040 let's not include any ZMDP headers if we can help it. I've added 00041 some more verbose output if zmdpDebugLevelG > 0. -Trey */ 00042 extern int zmdpDebugLevelG; 00043 00044 /* Use this type for a variable that indicated whether we have a 00045 POMDP or an MDP. 00046 */ 00047 typedef enum { UNKNOWN_problem_type, 00048 MDP_problem_type, 00049 POMDP_problem_type 00050 } Problem_Type; 00051 00052 /* Use this to determine if the problems values are rewards or costs. 00053 */ 00054 #define NUM_VALUE_TYPES 2 00055 typedef enum {REWARD_value_type, COST_value_type } Value_Type; 00056 #define VALUE_TYPE_STRINGS { \ 00057 "cost", \ 00058 "reward" \ 00059 } 00060 00061 #define DEFAULT_DISCOUNT_FACTOR 1.0 00062 00063 #define DEFAULT_VALUE_TYPE REWARD_value_type 00064 00065 #define INVALID_STATE -1 00066 00067 /* Exported variables */ 00068 extern char *value_type_str[]; 00069 extern REAL_VALUE gDiscount; 00070 extern Problem_Type gProblemType; 00071 extern Value_Type gValueType; 00072 extern int gNumStates; 00073 extern int gNumActions; 00074 extern int gNumObservations; 00075 00076 /* Intermediate variables */ 00077 00078 extern I_Matrix *IP; /* Transition Probabilities */ 00079 extern I_Matrix *IR; /* Observation Probabilities */ 00080 extern I_Matrix IQ; /* Immediate values for MDP only */ 00081 00082 /* Sparse variables */ 00083 00084 extern Matrix *P; /* Transition Probabilities */ 00085 extern Matrix *R; /* Observation Probabilities */ 00086 extern Matrix *QI; /* The immediate values, for MDPs only */ 00087 extern Matrix Q; /* Immediate values for state action pairs. These 00088 are expectations computed from immediate values: 00089 either the QI for MDPs or the special 00090 representation for the POMDPs */ 00091 00092 extern REAL_VALUE *gInitialBelief; /* For POMDPs */ 00093 extern int gInitialState; /* For MDPs */ 00094 00095 00096 00097 /* Exported functions */ 00098 extern REAL_VALUE *newBeliefState(); 00099 extern int transformBeliefState( REAL_VALUE *pi, 00100 REAL_VALUE *pi_hat, 00101 int a, 00102 int obs ); 00103 extern void copyBeliefState( REAL_VALUE *copy, REAL_VALUE *pi ); 00104 extern void displayBeliefState( FILE *file, REAL_VALUE *pi ); 00105 extern int readMDP( char *filename ); 00106 extern void convertMatrices(); 00107 extern void deallocateMDP(); 00108 extern void convertMatrices(); 00109 extern int verifyIntermediateMDP(); 00110 extern void deallocateIntermediateMDP(); 00111 extern void allocateIntermediateMDP(); 00112 extern int writeMDP( char *filename ); 00113 extern void displayMDPSlice( int state ); 00114 00115 extern void memoryExhaustedErrorHandler(); 00116 extern void checkAllocatedPointer(void * ptr); 00117 00118 00119 /* from pomdp_spec.y */ 00120 extern int readMDPFile( FILE *file ); 00121 00122 extern unsigned long getPhysicalMemorySize(); 00123 extern unsigned long getCurrentProcessMemoryUsage(); 00124 extern unsigned long getPlatformMemoryLimit(); 00125 00126 #ifdef __cplusplus 00127 } /* extern "C" */ 00128 #endif 00129 00130 #endif /* MDP_H */