Description Usage Arguments Details Value Note Author(s) Examples
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.
1 2 3 | hmpMDPWriter(file = "r.hmp", rate = 0.1, rateBase = 1,
precision = 1e-05,
desc = "HMP file created using hmpMDPWriter in R")
|
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 |
precision |
The precision used when checking if probabilities sum to one. |
desc |
Description of the model. |
The functions which can be used are:
setWeights(labels, duration)
: Set the
labels of the weights used in the actions. labels
is a vector of label names, duration
A number
defining which label that corresponds to duration/time,
e.g. if the first entry in labels is time then
duration = 1
. The function must be called before
starting building the model.
process()
:
Starts a (sub)process.
endProcess()
:
Ends a (sub)process.
stage(label=NULL)
:
Starts a stage.
endStage()
: Ends a
(sub)process.
state(label=NULL)
: Starts a
state. Returns the states index number sIdx.
endState()
: Ends a stage.
action(label=NULL, weights, prob,
statesNext=NULL)
: Starts an action. Parameter
weights
must be a vector of action weights,
prob
must contain triples of (scope, idx,pr). The
scope
can be 3 values: 0 - A transition to the
next stage in the father process, 1 - A transition to
next stage in the current process, 2 - A transition to a
child process (stage zero in the child process).
idx
in the pair denote the index of the state at
the stage considered, e.g. if scope=1 and idx=2 we
consider state number 3 at next stage in the current
process (number from zero). Note scope = 3 is not
supported in the hmp file format! statesNext
is
the number of states in the next stage of the process
(only needed if have a transition to the father).
endAction()
: Ends an action.
closeWriter()
: Close the writer. Must be
called when the model description has finished.
A list of functions.
Note all indexes are starting from zero (C/C++ style).
Lars Relund lars@relund.dk
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.