RewardMovementCostRel.cpp
Go to the documentation of this file.
00001 #include "RewardMovementCostRel.h"
00002 #include "VariableValue.h"
00003 
00004 
00005 RewardMovementCostRel::RewardMovementCostRel(SharedPointer<Variable> rewardVar, SharedPointer<Variable> actionVar, SharedPointer<ProblemParams> params)
00006 {
00007         this->actionVar = actionVar;
00008         this->rewardVar = rewardVar;
00009         this->params = params;
00010         this->addSourceVar(actionVar);
00011         this->setDestVariable(rewardVar);
00012 }
00013 
00014 RewardMovementCostRel::~RewardMovementCostRel(void)
00015 {
00016 }
00017 
00018 vector<SharedPointer<RelEntry> > RewardMovementCostRel::getProb(map<string, SharedPointer<IVariableValue> > sourceVals)
00019 {
00020         vector<SharedPointer<RelEntry> > result;
00021     vector<string> actions;
00022         actions.push_back("up");
00023     actions.push_back("down");
00024     actions.push_back("left");
00025     actions.push_back("right");
00026         
00027 
00028     FOREACH_NOCONST(string, pactionStr , actions)
00029     {
00030                 if(sourceVals[actionVar->getVariableName()]->getValueName().compare(*pactionStr) == 0)
00031                 {
00032                         // if action variable takes a value in the list
00033                         SharedPointer<RelEntry> newEntry ( new RelEntry());
00034                         // Reward releations does not need to fill in destValues. They only need to fill in the correct reward (stored in prob)
00035                         //newEntry->sourceValues[actionVar->getVariableName()] = actionVar->getValueByName(*pactionStr);
00036                         //newEntry->destValues[rewardVar->getVariableName()] = actionVar->getValueByName(*pactionStr);
00037                         newEntry->prob = params->MovementCost;
00038                         result.push_back(newEntry);
00039                         break;
00040                         // then reward is movement cost
00041                 }
00042                 else
00043                 {
00044                         // if reward is zero, can omit the return value, RewardsByFunction should be able to handle the missing value
00045                 }
00046         }
00047         
00048     return result;
00049 }


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