binaryMDPWriter: Function for writing an HMDP model to binary files. The...

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/binaryMDPWriter.R

Description

Binary files are efficent for storing large models. Compared to the HMP (XML) format the binary files use less storage space and loading the model is faster.

Usage

1
2
3
  binaryMDPWriter(prefix="",
    binNames=c("stateIdx.bin","stateIdxLbl.bin","actionIdx.bin",
    "actionIdxLbl.bin","actionWeight.bin","actionWeightLbl.bin","transProb.bin"))

Arguments

prefix

A character string with the prefix added to binNames.

binNames

A character vector of length 7 giving the names of the binary files storing the model.

Details

The functions which can be used are:

Seven binary files are created using the following format:

Value

A list of functions.

Note

Note all indexes are starting from zero (C/C++ style).

Author(s)

Lars Relund lars@relund.dk

Examples

  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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Create a small HMDP with two levels
w<-binaryMDPWriter()
w$setWeights(c("Duration","Net reward","Items"))
w$process()
	w$stage()
		w$state(label="M0")
			w$action(label="A0",weights=c(0,0,0),prob=c(2,0,1))
				w$process()
					w$stage()
						w$state(label="D")
							w$action(label="A0",weights=c(0,0,1),prob=c(1,0,0.5,1,1,0.5))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(0,0,0),prob=c(1,0,1))
							w$endAction()
							w$action(label="A1",weights=c(1,2,1),prob=c(1,0,0.5,1,1,0.5))
							w$endAction()
						w$endState()
						w$state(label="C1")
							w$action(label="A0",weights=c(0,0,0),prob=c(1,0,1))
							w$endAction()
							w$action(label="A1",weights=c(1,2,1),prob=c(1,0,0.5,1,1,0.5))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
						w$endState()
						w$state(label="C1")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
						w$endState()
					w$endStage()
				w$endProcess()
			w$endAction()
			w$action(label="A1",weights=c(0,0,0),prob=c(2,0,1))
				w$process()
					w$stage()
						w$state(label="D")
							w$action(label="A0",weights=c(0,0,1),prob=c(1,0,1))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(0,0,0),prob=c(1,0,1))
							w$endAction()
							w$action(label="A1",weights=c(1,2,1),prob=c(1,0,0.5,1,1,0.5))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
						w$endState()
						w$state(label="C1")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
							w$action(label="A1",weights=c(0,10,5),prob=c(0,0,0.5,0,1,0.5))
							w$endAction()
						w$endState()
					w$endStage()
				w$endProcess()
			w$endAction()
		w$endState()
		w$state(label="M1")
			w$action(label="A0",weights=c(0,0,0),prob=c(2,0,1))
				w$process()
					w$stage()
						w$state(label="D")
							w$action(label="A0",weights=c(0,0,1),prob=c(1,0,0.5,1,1,0.5))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(0,0,0),prob=c(1,0,1))
							w$endAction()
						w$endState()
						w$state(label="C1")
							w$action(label="A0",weights=c(0,0,0),prob=c(1,0,1))
							w$endAction()
						w$endState()
					w$endStage()
					w$stage()
						w$state(label="C0")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
						w$endState()
						w$state(label="C1")
							w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1))
							w$endAction()
						w$endState()
					w$endStage()
				w$endProcess()
			w$endAction()
		w$endState()
	w$endStage()
w$endProcess()
w$closeWriter()

stateIdxDf()
actionIdxDf()
actionWeightMat()
transProbMat()
a<-actionInfo()
a                   # ordered by action id
a[order(a$sId),]    # ordered by state id

MDP documentation built on May 2, 2019, 6:48 p.m.

Related to binaryMDPWriter in MDP...