Go to the documentation of this file.00001 #include "Const.h"
00002 #include "AlphaPlanePoolSet.h"
00003 #include "tinyxml.h"
00004 #include <exception>
00005 #include <fstream>
00006 using namespace std;
00007
00008
00009 REAL_VALUE AlphaPlanePoolSet::getValue(SharedPointer<BeliefWithState>& bns)
00010 {
00011 state_val sval = bns->sval;
00012 double bestVal;
00013 bestVal = set[sval]->getValue( bns->bvec);
00014
00015 return bestVal;
00016 }
00017
00018
00019 SharedPointer<AlphaPlane> AlphaPlanePoolSet::getValueAlpha(SharedPointer<BeliefWithState>& bns)
00020 {
00021 state_val sval = bns->sval;
00022 return set[sval]->getValueAlpha( bns->bvec);
00023 }
00024
00025 SharedPointer<AlphaPlane> AlphaPlanePoolSet::backup(BeliefTreeNode * node)
00026 {
00027 SharedPointer<AlphaPlane> result = backupEngine->backup(node);
00028 for(int i = 0 ; i < onBackup.size(); i++)
00029 {
00030 (*onBackup[i])(solver, node, result);
00031 }
00032 return result;
00033 }
00034
00035
00036 SharedPointer<AlphaPlane> AlphaPlanePoolSet::getBestAlphaPlane(BeliefWithState& beliefandState)
00037 {
00038 state_val sval = beliefandState.sval;
00039 SharedPointer<AlphaPlane> bestAlp;
00040 bestAlp = set[sval]->getBestAlphaPlane(beliefandState.bvec);
00041 return bestAlp;
00042
00043 }
00044
00045
00046 SharedPointer<AlphaPlane> AlphaPlanePoolSet::getBestAlphaPlane(BeliefTreeNode& cn)
00047 {
00048 state_val sval = cn.s->sval;
00049 SharedPointer<AlphaPlane> bestAlp;
00050
00051 bestAlp = set[sval]->getBestAlphaPlane(cn);
00052 return bestAlp;
00053 }
00054
00055 SharedPointer<AlphaPlane> AlphaPlanePoolSet::getBestAlphaPlane1(BeliefWithState& beliefandState)
00056 {
00057 state_val sval = beliefandState.sval;
00058 SharedPointer<AlphaPlane>bestAlp;
00059 bestAlp = set[sval]->getBestAlphaPlane1(beliefandState.bvec);
00060 return bestAlp;
00061 }
00062
00063
00064 void AlphaPlanePoolSet::writeToFile(const std::string& outFileName, string problemName)
00065 {
00066 ofstream out(outFileName.c_str());
00067 if (!out)
00068 {
00069 cerr << "ERROR: Bounds::writeToFile: couldn't open " << outFileName << " for writing " << endl;
00070 exit(EXIT_FAILURE);
00071 }
00072
00073 string declaration =
00074 "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<Policy version=\"0.1\" type=\"value\" model=\""+ problemName +"\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"policyx.xsd\">";
00075 out << declaration << endl ;
00076 int totalnumPlanes = 0;
00077 FOR (sval, set.size())
00078 {
00079 totalnumPlanes += set[sval]->planes.size();
00080 }
00081 int vectorLength = problem->YStates->size();
00082 int numObsValue = set.size();
00083 out << "<AlphaVector vectorLength=\"" << vectorLength << "\" numObsValue=\"" << numObsValue << "\" numVectors=\"" << totalnumPlanes << "\">" << endl;
00084 FOR (sval, set.size())
00085 {
00086 list<SharedPointer<AlphaPlane> >::const_iterator pi = set[sval]->planes.begin();
00087 FOR (i, set[sval]->planes.size())
00088 {
00089 (*pi)->write(out);
00090 pi++;
00091
00092 }
00093 }
00094 out << "</AlphaVector> </Policy>" << endl;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172