hmpMDPWriter: Function for writing an HMDP model to a hmp file (XML). The...

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/hmpMDPWriter.R

Description

HMP files are in XML format and human readable using e.g. a text editor. HMP files are not suitable for storing large HMDP models since text files are very verbose. Moreover, approximation of the weights and probabilities may occur since the parser writing the hmp file may no output all digits. If you consider large models then use the binary file format instead.

Usage

1
2
3
  hmpMDPWriter(file = "r.hmp", rate = 0.1, rateBase = 1,
    precision = 1e-05,
    desc = "HMP file created using hmpMDPWriter in R")

Arguments

file

The name of the file storing the model (e.g. mdp.hmp).

rate

The interest rate (used if consider discounting).

rateBase

The time where the rate is taken over, e.g. if the rate is 0.1 and rateBase is 365 days then we have an interest rate of 10 percent over the year.

precision

The precision used when checking if probabilities sum to one.

desc

Description of the model.

Details

The functions which can be used are:

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
# Create a small HMDP with two levels
w<-hmpMDPWriter()
w$setWeights(c("Duration","Net reward","Items"),duration=1)
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), statesNext=0)
			  w$endAction()
			w$endState()
			w$state(label="C1")
			  w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1), statesNext=0)
			  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), statesNext=0)
			  w$endAction()
			w$endState()
			w$state(label="C1")
			  w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1), statesNext=0)
			  w$endAction()
			  w$action(label="A1",weights=c(0,10,5),prob=c(0,0,0.5,0,1,0.5), statesNext=0)
			  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), statesNext=0)
			  w$endAction()
			w$endState()
			w$state(label="C1")
			  w$action(label="A0",weights=c(1,4,0),prob=c(0,0,1), statesNext=0)
			  w$endAction()
			w$endState()
		  w$endStage()
		w$endProcess()
	  w$endAction()
	w$endState()
  w$endStage()
w$endProcess()
w$closeWriter()

# have a look at the hmp file
xmlTreeParse("r.hmp",useInternalNodes=TRUE)

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

Related to hmpMDPWriter in MDP...