-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestSingleRoverEigen.cpp
61 lines (49 loc) · 1.68 KB
/
testSingleRoverEigen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include "Domains/SingleRover.h"
int main(){
std::cout << "Testing SingleRover class in SingleRover.h\n" ;
vector<double> world ;
world.push_back(0.0) ;
world.push_back(30.0) ;
world.push_back(0.0) ;
world.push_back(30.0) ;
size_t nPOIs = 10 ;
size_t nSteps = 30 ;
size_t nPop = 15 ;
size_t nRuns = 1 ;
for (size_t i = 0; i < nRuns; i++){
std::cout << "Initialising rover domain " << i << "...\n" ;
SingleRover testDomain(world, nPOIs, nSteps, nPop) ;
int buffSize = 100 ;
char fileDir[buffSize] ;
sprintf(fileDir,"Results/30_square/Random_worlds/100_epochs/Eigen/%d",(int)i) ;
char mkdir[buffSize] ;
sprintf(mkdir,"mkdir -p %s",fileDir) ;
system(mkdir) ;
char eFile[buffSize] ;
sprintf(eFile,"%s/results.txt",fileDir) ;
std::cout << eFile << std::endl ;
testDomain.OutputPerformance(eFile) ;
char tFile[buffSize] ;
sprintf(tFile,"%s/trajectories.txt",fileDir) ;
char pFile[buffSize] ;
sprintf(pFile,"%s/POIs.txt",fileDir) ;
testDomain.OutputTrajectories(tFile,pFile) ;
char nnFile[buffSize] ;
sprintf(nnFile,"%s/NNs",fileDir) ;
testDomain.OutputNNs(nnFile) ;
size_t nEp = 100 ;
std::cout << "Executing " << nEp << " epochs...\n" ;
testDomain.ExecuteLearning(nEp) ;
std::cout << "Executing learned NN policies from stored file...\n" ;
char ttFile[buffSize] ;
sprintf(ttFile,"%s/trajectories_test.txt",fileDir) ;
char ppFile[buffSize] ;
sprintf(ppFile,"%s/POIs_test.txt",fileDir) ;
testDomain.ExecutePolicy(nnFile, ttFile, ppFile, 4, 2, 8) ;
}
std::cout << "Test complete!\n" ;
return 0 ;
}