|
| 1 | +/// To use this example, run and implement the 2Drobot-RU case study. |
| 2 | +/// Then copy to this folder the files is.h5, ss.h5, minttm.h5, maxttm.h5, |
| 3 | +/// mintm.h5, maxtm.h5, minatm.h5 and maxatm.h5 |
| 4 | + |
| 5 | +// Run: make |
| 6 | +// ./GPU |
| 7 | + |
| 8 | + |
| 9 | +// Code: Ben Wooding 4 Jan 2024 |
| 10 | + |
| 11 | +#include <iostream> |
| 12 | +#include <vector> |
| 13 | +#include <functional> |
| 14 | +#include "../../src/IMDP.h" |
| 15 | +#include "../../src/MDP.h" |
| 16 | +#include <armadillo> |
| 17 | +#include <chrono> |
| 18 | + |
| 19 | +using namespace std; |
| 20 | +using namespace arma; |
| 21 | + |
| 22 | +/* |
| 23 | + ################################# PARAMETERS ############################################### |
| 24 | + */ |
| 25 | + |
| 26 | +// Set the dimensions |
| 27 | +const int dim_x = 2; |
| 28 | +const int dim_u = 2; |
| 29 | +const int dim_w = 0; |
| 30 | + |
| 31 | +/* |
| 32 | + ################################# MAIN FUNCTION ############################################## |
| 33 | + */ |
| 34 | + |
| 35 | +int main() { |
| 36 | + |
| 37 | + /* ###### create IMDP object ###### */ |
| 38 | + IMDP mdp(dim_x,dim_u,dim_w); |
| 39 | + |
| 40 | + /* ###### load the different spaces ###### */ |
| 41 | + mdp.loadStateSpace("ss.h5"); |
| 42 | + mdp.loadInputSpace("is.h5"); |
| 43 | + |
| 44 | + /* ###### load matrices and vectors ######*/ |
| 45 | + mdp.loadMinTargetTransitionVector("minttm.h5"); |
| 46 | + mdp.loadMaxTargetTransitionVector("minttm.h5"); |
| 47 | + mdp.loadMinAvoidTransitionVector("minatm.h5"); |
| 48 | + mdp.loadMaxAvoidTransitionVector("maxatm.h5"); |
| 49 | + mdp.loadMinTransitionMatrix("mintm.h5"); |
| 50 | + mdp.loadMaxTransitionMatrix("maxtm.h5"); |
| 51 | + |
| 52 | + |
| 53 | + /* ###### storeMDP, choose optimization as pessimistic = true, or optimistic = false, also choose how many steps to save MDP from ######*/ |
| 54 | + mdp.finiteHorizonReachControllerSortedStoreMDP(true,1); |
| 55 | + |
| 56 | + mdp.saveTransitionMatrix(); |
| 57 | + mdp.saveAvoidTransitionVector(); |
| 58 | + mdp.saveTargetTransitionVector(); |
| 59 | + |
| 60 | + /* ###### save controller ######*/ |
| 61 | + mdp.saveController(); |
| 62 | + |
| 63 | + return 0; |
| 64 | +} |
| 65 | + |
0 commit comments