Skip to content

Commit dfa400f

Browse files
authored
Merge pull request #4 from Kiguli/test
Feature: Store generated MDP during Robust Value Iteration.
2 parents 18689f2 + 1768f87 commit dfa400f

File tree

6 files changed

+2427
-90
lines changed

6 files changed

+2427
-90
lines changed

examples/ex_storeTempMDP/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CC = acpp # check AdaptiveCPP GitHub for correct GPU selection and put inside --acpp-targets="" (see: https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/doc/using-hipsycl.md)
2+
ARCH := $(shell uname -m)
3+
CFLAGS = --acpp-targets="cuda:sm_70;omp" -O3 -lnlopt -lm -I/usr/include/hdf5/serial -L/usr/lib/$(ARCH)-linux-gnu/hdf5/serial -lhdf5 -lglpk -lgsl -lgslcblas -DH5_USE_110_API -larmadillo
4+
5+
# Find all .cpp files in the current directory
6+
CPP_FILES := $(wildcard *.cpp)
7+
8+
# Generate corresponding executable names
9+
EXECUTABLES := $(patsubst %.cpp,%,$(CPP_FILES))
10+
11+
all: $(EXECUTABLES)
12+
13+
# see: below IMDP.cpp replaced with GPU_synthesis.cpp
14+
%: %.cpp ../../src/GPU_synthesis.cpp ../../src/MDP.cpp
15+
$(CC) $^ $(CFLAGS) -o $@
16+
17+
clean:
18+
rm -f $(EXECUTABLES)
19+

examples/ex_storeTempMDP/storeMDP.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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

Comments
 (0)