testControllerTiger.cpp
Go to the documentation of this file.
00001 
00007 // Usage: "./testController --policy-file=out.policy
00008 // ../examples/POMDPX/Tiger.pomdpx"
00009 
00010 #include "Controller.h"
00011 #include "GlobalResource.h"
00012 #include "MOMDP.h"
00013 #include "ParserSelector.h"
00014 #include "AlphaVectorPolicy.h"
00015 #include <iostream>
00016 using namespace std;
00017 
00018 int main(int argc, char **argv)
00019 {
00020     SolverParams* p = &GlobalResource::getInstance()->solverParams;
00021     bool parseCorrect = SolverParams::parseCommandLineOption(argc, argv, *p);
00022 
00023     if (p->policyFile == "") {
00024         cout<<"Invalid params\n";
00025         return 0;
00026     }
00027 
00028     cout<<"\nLoading the model ...\n   ";
00029     SharedPointer<MOMDP> problem = ParserSelector::loadProblem(p->problemName, *p);
00030 
00031     SharedPointer<AlphaVectorPolicy> policy = new AlphaVectorPolicy(problem);
00032 
00033     cout<<"\nLoading the policy ... input file : "<<p->policyFile<<"\n";
00034     bool policyRead = policy->readFromFile(p->policyFile);
00035 
00036     if (p->useLookahead) {
00037         cout<<"   action selection : one-step look ahead\n";
00038     }
00039 
00040     Controller control(problem, policy, p, -1);
00041 
00042     cout<<"\nInitialized the controller\n";
00043 
00044     // In the Tiger problem, X = 0
00045     // dummy obs for first action
00046     int firstAction = control.nextAction(1, 0);
00047     cout<<"\nFirst action : "<<firstAction<<endl;
00048 
00049     // obs-left
00050     int action = control.nextAction(0, 0);
00051     cout<<"Obs-left => Action : "<<action<<endl;
00052     // obs-left => open right
00053     action = control.nextAction(0, 0);
00054     cout<<"Obs-left => Action : "<<action<<endl;
00055     // reset
00056     action = control.nextAction(1, 0);
00057     cout<<"\nReset ...\nFirst action : "<<action<<endl;
00058     // obs-right
00059     action = control.nextAction(1, 0);
00060     cout<<"Obs-right => Action : "<<action<<endl;
00061     // obs-right => open left
00062     action = control.nextAction(1, 0);
00063     cout<<"Obs-right => Action : "<<action<<endl;
00064 
00065     return 0;
00066 }


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