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 __VIPLANNER_H_ 00030 #define __VIPLANNER_H_ 00031 00032 #define MDP_ERRDELTA 0.01 00033 00034 struct VIPLANNER_T 00035 { 00036 CMDP MDP; 00037 CMDPSTATE* StartState; 00038 CMDPSTATE* GoalState; 00039 int iteration; 00040 }; 00041 00044 typedef class VIPLANNERSTATEDATA : public AbstractSearchState 00045 { 00046 public: 00049 CMDPSTATE* MDPstate; 00052 float v; 00053 float Pc; 00054 unsigned int iteration; 00055 00058 CMDPACTION *bestnextaction; 00059 00060 00061 public: 00062 VIPLANNERSTATEDATA() {}; 00063 ~VIPLANNERSTATEDATA() {}; 00064 } VIState; 00065 00066 00069 class VIPlanner : public SBPLPlanner 00070 { 00071 00072 public: 00075 int replan(double allocated_time_secs, vector<int>* solution_stateIDs_V); 00076 00079 VIPlanner(DiscreteSpaceInformation* environment, MDPConfig* MDP_cfg) 00080 { 00081 environment_ = environment; 00082 MDPCfg_ = MDP_cfg; 00083 }; 00084 00087 ~VIPlanner(); 00088 00089 private: 00090 00091 //member variables 00092 MDPConfig* MDPCfg_; 00093 VIPLANNER_T viPlanner; 00094 00095 00096 void Initialize_vidata(CMDPSTATE* state); 00097 00098 CMDPSTATE* CreateState(int stateID); 00099 00100 CMDPSTATE* GetState(int stateID); 00101 00102 00103 void PrintVIData(); 00104 00105 void PrintStatHeader(FILE* fOut); 00106 00107 void PrintStat(FILE* fOut, clock_t starttime); 00108 00109 00110 void PrintPolicy(FILE* fPolicy); 00111 00112 00113 void backup(CMDPSTATE* state); 00114 00115 void perform_iteration_backward(); 00116 00117 void perform_iteration_forward(); 00118 00119 void InitializePlanner(); 00120 00121 00122 00123 00124 }; 00125 00126 00127 00128 00129 #endif