Go to the documentation of this file.00001 #include "TerminationVarPaddedRel.h"
00002
00003
00004 TerminationVarPaddedRel::TerminationVarPaddedRel(SharedPointer<VariableRelation> origRel, SharedPointer<BooleanVariable> termVar)
00005 {
00006 this->origRel = origRel;
00007 this->termVar = termVar;
00008 this->addSourceVar(termVar);
00009 vector<SharedPointer<IVariable> > srcVars = origRel->getSourceVars();
00010 for(int i = 0 ; i < srcVars.size(); i++)
00011 {
00012 SharedPointer<IVariable> srcVar = srcVars[i];
00013 this->addSourceVar(srcVar);
00014 }
00015 this->setDestVariable(origRel->getDestVariable());
00016 }
00017
00018 TerminationVarPaddedRel::~TerminationVarPaddedRel(void)
00019 {
00020 }
00021
00022 vector<SharedPointer<RelEntry> > TerminationVarPaddedRel::getProb(map<string, SharedPointer<IVariableValue> > sourceVals)
00023 {
00024 vector<SharedPointer<RelEntry> > result;
00025 vector<SharedPointer<RelEntry> > srcEntries = origRel->getProb(sourceVals);
00026
00027 for(int j = 0 ; j < srcEntries.size() ; j ++)
00028 {
00029
00030 if(sourceVals[termVar->getVariableName()]->getIndex() == BooleanVariable::FalseValueIndex)
00031 {
00032
00033 SharedPointer<RelEntry> newEntry (new RelEntry());
00034
00035 newEntry->destValues[this->getDestVariable()->getVariableName()] = srcEntries[j]->destValues[this->getDestVariable()->getVariableName()];
00036 newEntry->prob = srcEntries[j]->prob;
00037 result.push_back(newEntry);
00038 }
00039 else
00040 {
00041
00042 SharedPointer<RelEntry> newEntry (new RelEntry());
00043
00044
00045
00046
00047
00048
00049
00050 newEntry->destValues[this->getDestVariable()->getVariableName()] = this->getDestVariable()->getValues()[0];
00051 newEntry->prob = srcEntries[j]->prob;
00052 result.push_back(newEntry);
00053
00054 }
00055 }
00056
00057 return result;
00058 }