-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
50 lines (40 loc) · 1.12 KB
/
main.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
//
// Benchmarking Distributed Inexact Policy Iteration for Large-Scale Markov Decision Processes
// Bachelor Thesis - Robin Sieber - 2023 - ETH Zürich
//
#include <petscvec.h>
#include <mpi.h>
#include <iostream>
#include <random>
#include "utils/Timer.h"
#include "utils/Logger.h"
#include "MDP.h"
int main(int argc, char** argv)
{
// Initialize PETSc
PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
Timer t;
// Setup MDP
t.start();
MDP mdp;
mdp.setValuesFromOptions();
mdp.loadFromBinaryFile(mdp.file_P_, mdp.file_g_);
t.stop("MDP setup + loading took: ");
Vec V0;
VecCreateMPI(PETSC_COMM_WORLD, mdp.localNumStates_, mdp.numStates_, &V0);
VecSet(V0, 1.0);
IS optimalPolicy;
Vec optimalCost;
t.start();
//mdp.inexactPolicyIteration(V0, optimalPolicy, optimalCost);
mdp.benchmarkIPI(V0, optimalPolicy, optimalCost);
t.stop("iPI took: ");
t.start();
mdp.writeVec(optimalCost, mdp.file_cost_);
mdp.writeIS(optimalPolicy, mdp.file_policy_);
t.stop("Writing took: ");
mdp.~MDP();
// Finalize PETSc
PetscFinalize();
return 0;
}