pomdpCassandraWrapper.cpp
Go to the documentation of this file.
00001 /********** tell emacs we use -*- c++ -*- style comments *******************
00002  $Revision: 2.28 $  $Author: duyanzhu $  $Date: 2009/01/07 05:10:05 $
00003   
00004  @file    pomdpCassandraWrapper.cc
00005  @brief   A wrapper that provides access to the pomdp read in by
00006           Tony Cassandra's file reading code, without requiring you
00007           to (1) directly reference global variables or (2) include
00008           all of the headers like sparse-matrix.h.  Also uses notation
00009           I am more familiar with.
00010 
00011  Copyright (c) 2002-2005, Trey Smith. All rights reserved.
00012 
00013  Licensed under the Apache License, Version 2.0 (the "License"); you may
00014  not use this file except in compliance with the License.  You may
00015  obtain a copy of the License at
00016 
00017    http://www.apache.org/licenses/LICENSE-2.0
00018 
00019  Unless required by applicable law or agreed to in writing, software
00020  distributed under the License is distributed on an "AS IS" BASIS,
00021  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
00022  implied.  See the License for the specific language governing
00023  permissions and limitations under the License.
00024 
00025  ***************************************************************************/
00026 
00027 /***************************************************************************
00028  * INCLUDES
00029  ***************************************************************************/
00030 
00031 #include <assert.h>
00032 #include <stdlib.h>
00033 #ifdef _MSC_VER
00034 #else
00035 #include <unistd.h>
00036 #endif
00037 
00038 #include <stdio.h>
00039 
00040 #include <iostream>
00041 using namespace std;
00042 
00043 #include "pomdpCassandraWrapper.h"
00044 #include "mdpCassandra.h"
00045 
00046 PomdpCassandraWrapper::~PomdpCassandraWrapper(void)
00047 {
00048   deallocateMDP();
00049 }
00050 
00051 int PomdpCassandraWrapper::getNumStates(void) const {
00052   return gNumStates;
00053 }
00054 
00055 int PomdpCassandraWrapper::getNumActions(void) const {
00056   return gNumActions;
00057 }
00058 
00059 int PomdpCassandraWrapper::getNumObservations(void) const {
00060   return gNumObservations;
00061 }
00062 
00063 ValueType PomdpCassandraWrapper::getDiscount(void) const {
00064   return gDiscount;
00065 }
00066 
00067 ValueType PomdpCassandraWrapper::getInitialBelief(StateType s) const {
00068   return gInitialBelief[s];
00069 }
00070 
00071 CassandraMatrix PomdpCassandraWrapper::getRTranspose(void) const {
00072   return Q;
00073 }
00074 
00075 CassandraMatrix PomdpCassandraWrapper::getT(ActionType a) const {
00076   return P[a];
00077 }
00078 
00079 CassandraMatrix PomdpCassandraWrapper::getO(ActionType a) const {
00080   return ::R[a];
00081 }
00082 
00083 void PomdpCassandraWrapper::readFromFile(const string& fileName) {
00084   if (! readMDP(const_cast<char *>(fileName.c_str())) ) {
00085     //throw InputError();
00086     exit(EXIT_FAILURE);
00087   }
00088 }
00089 
00090 /***************************************************************************
00091  * REVISION HISTORY:
00092  * $Log: pomdpCassandraWrapper.cc,v $
00093  * Revision 2.28  2009/01/07 05:10:05  duyanzhu
00094  * added GES.h
00095  *
00096  * Revision 2.26  2009/01/07 05:06:00  duyanzhu
00097  * added evaluator_win
00098  *
00099  * Revision 2.24  2009/01/07 05:01:34  duyanzhu
00100  * add GES
00101  *
00102  * Revision 2.22  2009/01/07 04:59:01  duyanzhu
00103  * adding in UniqueBeliefHeap
00104  *
00105  * Revision 2.20  2009/01/07 04:33:55  duyanzhu
00106  * APPL 0.3, added Policy Evaluator, added Memory Limit option
00107  *
00108  * Revision 2.18  2008/09/17 14:08:37  duyanzhu
00109  * Fix: Prune now only starts 5 seconds after initialization
00110  *
00111  * Revision 2.16  2008/07/16 13:27:46  duyanzhu
00112  * Bring everything to version 2.16
00113  *
00114  * Revision 2.12  2008/07/16 08:38:16  duyanzhu
00115  * Add CPMemUtils class
00116  *
00117  * Revision 2.11  2008/07/16 08:34:49  duyanzhu
00118  * Added parser memory allocation check. Added release script
00119  *
00120  * Revision 2.10  2008/06/14 01:41:17  duyanzhu
00121  * 14 Jun 08 by Du Yanzhu. Added command line option percentageThreshold
00122  *
00123  * Revision 1.5  2007/08/17 01:44:36  duyanzhu
00124  * Change Alpha vector to DenseVector. Xan adds dump functions. Xan's bound propagation code is also included, but not added to Makefile
00125  *
00126  * Revision 1.4  2007/08/16 14:06:42  duyanzhu
00127  * Undo last commit
00128  *
00129  * Revision 1.1.1.1  2007/07/24 13:17:52  dyhsu
00130  * Approximate POMDP Planning Library (APPL)
00131  *
00132  * Revision 1.1  2007/03/25 18:02:41  elern
00133  * initial revision
00134  *
00135  * Revision 1.7  2006/05/27 19:05:27  trey
00136  * PomdpCassandraWrapper accessors now return sparse matrices instead of providing element-by-element access
00137  *
00138  * Revision 1.6  2006/05/26 00:59:30  trey
00139  * changed error behavior from throwing an exception to exiting
00140  *
00141  * Revision 1.5  2006/04/28 17:57:41  trey
00142  * changed to use apache license
00143  *
00144  * Revision 1.4  2005/10/28 03:54:39  trey
00145  * simplified license
00146  *
00147  * Revision 1.3  2005/10/28 03:05:27  trey
00148  * added copyright header
00149  *
00150  * Revision 1.2  2005/10/27 21:34:20  trey
00151  * continued renaming process
00152  *
00153  * Revision 1.1  2005/10/27 21:27:10  trey
00154  * renamed pomdp to pomdpCassandraWrapper
00155  *
00156  * Revision 1.1.1.1  2004/11/09 16:18:56  trey
00157  * imported hsvi into new repository
00158  *
00159  * Revision 1.3  2003/07/16 16:12:44  trey
00160  * added support for terminal states
00161  *
00162  * Revision 1.2  2003/04/02 17:13:56  trey
00163  * minor changes to enable compilation under gcc 3.0.1
00164  *
00165  * Revision 1.1.1.1  2003/01/07 19:19:41  trey
00166  * Imported sources
00167  *
00168  *
00169  ***************************************************************************/


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:29