RewardOnPath.cpp
Go to the documentation of this file.
00001 #include "RewardOnPath.h"
00002 #include "VariableValue.h"
00003 #include <set>
00004 
00005 using namespace std;
00006 
00007 
00008 RewardOnPath::RewardOnPath(SharedPointer<Variable> rewardVar, SharedPointer<Map2DPosVar> auvPos, SharedPointer<Map2DPath> path, SharedPointer<ProblemParams> params)
00009 {
00010         this->auvPos = auvPos;
00011         this->rewardVar = rewardVar;
00012         this->params = params;
00013         this->path = path;
00014 
00015         this->addSourceVar(auvPos);
00016         this->setDestVariable(rewardVar);
00017 }
00018 
00019 RewardOnPath::~RewardOnPath(void)
00020 {
00021 }
00022 
00023 vector<SharedPointer<RelEntry> > RewardOnPath::getProb(map<string, SharedPointer<IVariableValue> > sourceVals)
00024 {
00025         vector<SharedPointer<Map2DPosValue> > pathSteps = path->getPath();
00026         
00027         SharedPointer<IVariableValue> curPos = sourceVals[auvPos->getVariableName()];
00028 
00029         vector<SharedPointer<RelEntry> > result;
00030         //set<string> visitedPos;
00031 
00032     FOREACH_NOCONST(SharedPointer<Map2DPosValue>,  pCurStep , pathSteps)
00033     {
00034                 SharedPointer<Map2DPosValue> curStep = *pCurStep;
00035                 if(curStep->equals(curPos))
00036                 {
00037                         SharedPointer<RelEntry> newEntry ( new RelEntry());
00038                         //newEntry->sourceValues[curStep->getVariableName()] = curStep;
00039                         newEntry->prob = params->OnPathReward;
00040                         result.push_back(newEntry);
00041                 }
00042                 //visitedPos.insert(curStep->ToString());
00043         }
00044     //vector<SharedPointer<IVariableValue> > auvPosVals = auvPos->getValues();
00045 
00046         //FOREACH_NOCONST(SharedPointer<IVariableValue>,  pCurStep , auvPosVals)
00047         //{
00048         //      SharedPointer<Map2DPosValue> curStep = dynamic_pointer_cast<Map2DPosValue>(*pCurStep);
00049         //      if(visitedPos.find(curStep->ToString()) == visitedPos.end())
00050         //      {
00051         //              // not visited, therefore, is off path
00052         //              SharedPointer<RelEntry> newEntry ( new RelEntry());
00053         //              //newEntry->sourceValues[curStep->getVariableName()] = curStep;
00054         //              newEntry->prob = params->OffPathPenalty;
00055         //              result.push_back(newEntry);
00056         //              visitedPos.insert(curStep->ToString());
00057         //      }
00058         //}
00059     return result;
00060 }


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