00001 /********** tell emacs we use -*- c++ -*- style comments ******************* 00002 $Revision: 2.28 $ $Author: duyanzhu $ $Date: 2009/01/07 05:10:04 $ 00003 00004 @file decision-tree.h 00005 @brief Efficient decision tree data structure for MDP/POMDP immediate 00006 rewards. 00007 00008 Copyright (c) 2006, Trey Smith. All rights reserved. 00009 00010 Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 not use this file except in compliance with the License. You may 00012 obtain a copy of the License at 00013 00014 http://www.apache.org/licenses/LICENSE-2.0 00015 00016 Unless required by applicable law or agreed to in writing, software 00017 distributed under the License is distributed on an "AS IS" BASIS, 00018 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 00019 implied. See the License for the specific language governing 00020 permissions and limitations under the License. 00021 00022 ***************************************************************************/ 00023 00024 #ifndef INCdecision_tree_h 00025 #define INCdecision_tree_h 00026 00027 #include "Const.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 00034 /********************************************************************** 00035 See an example of how to use this library in testDecisionTree.c. 00036 00037 The decision-tree library efficiently stores a mapping [a,s,s',o] -> 00038 val, where a is an action, s and s' are states, o is an observation 00039 (all integers), and val is an immediate reward value (real). 00040 00041 * Construct the immediate reward mapping by calling dtInit() and 00042 repeatedly calling dtAdd(), one time for each "entry" in the mapping. 00043 00044 * Query immediate rewards by calling dtGet(). 00045 00046 * When finished, call dtDeallocate(). 00047 00048 The decision-tree library is intended to be used only by the 00049 imm-reward library. (The dtGet() function hides behind the 00050 getImmediateReward() function in imm-reward.c). 00051 **********************************************************************/ 00052 00053 /* Initialize the decision-tree library--dimensionality of the model 00054 must be specified so that tables in the decision tree can be 00055 allocated appropriately later. */ 00056 extern void dtInit(int numActions, int numStates, int numObservations); 00057 00058 /* Adds an entry to the decision tree. Any of the first four arguments 00059 can be given the value -1 (== WILDCARD_SPEC), indicating a wildcard. 00060 Later calls to dtAdd() overwrite earlier calls. */ 00061 extern void dtAdd(int action, int cur_state, int next_state, int obs, REAL_VALUE val); 00062 00063 /* Returns the immediate reward for a particular [a,s,s',o] tuple. */ 00064 extern REAL_VALUE dtGet(int action, int cur_state, int next_state, int obs); 00065 00066 /* Cleans up all decision tree data structures on the heap. */ 00067 extern void dtDeallocate(void); 00068 00069 /* Print a textual representation of the decision tree data structure to 00070 stdout. Intended for debugging. */ 00071 extern void dtDebugPrint(const char* header); 00072 00073 #ifdef __cplusplus 00074 } 00075 #endif 00076 00077 00078 00079 #endif // INCdecision_tree_h 00080 00081 /*************************************************************************** 00082 * REVISION HISTORY: 00083 * $Log: decision-tree.h,v $ 00084 * Revision 2.28 2009/01/07 05:10:04 duyanzhu 00085 * added GES.h 00086 * 00087 * Revision 2.26 2009/01/07 05:05:59 duyanzhu 00088 * added evaluator_win 00089 * 00090 * Revision 2.24 2009/01/07 05:01:32 duyanzhu 00091 * add GES 00092 * 00093 * Revision 2.22 2009/01/07 04:59:00 duyanzhu 00094 * adding in UniqueBeliefHeap 00095 * 00096 * Revision 2.20 2009/01/07 04:33:55 duyanzhu 00097 * APPL 0.3, added Policy Evaluator, added Memory Limit option 00098 * 00099 * Revision 2.18 2008/09/17 14:08:36 duyanzhu 00100 * Fix: Prune now only starts 5 seconds after initialization 00101 * 00102 * Revision 2.16 2008/07/16 13:27:45 duyanzhu 00103 * Bring everything to version 2.16 00104 * 00105 * Revision 2.12 2008/07/16 08:38:15 duyanzhu 00106 * Add CPMemUtils class 00107 * 00108 * Revision 2.11 2008/07/16 08:34:49 duyanzhu 00109 * Added parser memory allocation check. Added release script 00110 * 00111 * Revision 2.10 2008/06/14 01:41:17 duyanzhu 00112 * 14 Jun 08 by Du Yanzhu. Added command line option percentageThreshold 00113 * 00114 * Revision 1.5 2007/08/17 01:44:35 duyanzhu 00115 * Change Alpha vector to DenseVector. Xan adds dump functions. Xan's bound propagation code is also included, but not added to Makefile 00116 * 00117 * Revision 1.4 2007/08/16 14:06:41 duyanzhu 00118 * Undo last commit 00119 * 00120 * Revision 1.1.1.1 2007/07/24 13:17:46 dyhsu 00121 * Approximate POMDP Planning Library (APPL) 00122 * 00123 * Revision 1.2 2007/06/04 10:13:37 elern 00124 * adapted a newer version of parser 00125 * 00126 * Revision 1.3 2006/06/01 16:48:36 trey 00127 * cleaned up comments 00128 * 00129 * Revision 1.2 2006/06/01 15:59:55 trey 00130 * no longer publish unnecessary typedefs in header 00131 * 00132 * Revision 1.1 2006/05/29 04:06:02 trey 00133 * initial check-in 00134 * 00135 * 00136 ***************************************************************************/