Main Content

createmdp

创建马尔可夫决策过程模型

描述

例子

MDP=createmdp((状态,,,,动作creates a Markov decision process model with the specified states and actions.

例子

全部收缩

Create an MDP model with eight states and two possible actions.

MDP = createMDP(8,["up";“下”);

指定国家过渡及其相关的奖励。

% State 1 Transition and Rewardmdp.t(1,2,1)= 1;MDP.R(1,2,1)= 3;MDP.T(1,3,2)= 1;MDP.R(1,3,2)= 1;%状态2过渡和奖励MDP.T(2,4,1)= 1;MDP.R(2,4,1)= 2;MDP.T(2,5,2)= 1;MDP.R(2,5,2)= 1;%状态3过渡和奖励MDP.T(3,5,1)= 1;MDP.R(3,5,1)= 2;MDP.T(3,6,2)= 1;MDP.R(3,6,2)= 4;%状态4过渡和奖励MDP.T(4,7,1)= 1;MDP.R(4,7,1)= 3;MDP.T(4,8,2)= 1;MDP.R(4,8,2)= 2;% State 5 Transition and RewardMDP.T(5,7,1)= 1;MDP.R(5,7,1)= 1;MDP.T(5,8,2)= 1;MDP.R(5,8,2)= 9;%状态6过渡和奖励MDP.T(6,7,1)= 1;MDP.R(6,7,1)= 5;MDP.T(6,8,2)= 1;MDP.R(6,8,2)= 1;%状态7过渡和奖励MDP.T(7,7,1)= 1;MDP.R(7,7,1)= 0;MDP.T(7,7,2)= 1;MDP.R(7,7,2)= 0;% State 8 Transition and RewardMDP.T(8,8,1)= 1;MDP.R(8,8,1)= 0;MDP.T(8,8,2)= 1;MDP.R(8,8,2)= 0;

指定模型的终端状态。

MDP.TerminalStates = [“ S7”;“ S8”];

输入参数

全部收缩

模型状态,指定为以下之一:

  • 正整数 - 指定模型状态的数量。在这种情况下,每个状态都有一个默认名称,例如“ S1”for the first state.

  • 字符串向量 - 指定状态名称。在这种情况下,状态总数等于向量的长度。

模型动作,指定为以下之一:

  • 正整数 - 指定模型操作的数量。在这种情况下,每个操作都有一个默认名称,例如“ A1”对于第一个动作。

  • str一世ng vector — Specify the action names. In this case, the total number of actions is equal to the length of the vector.

输出参数

全部收缩

MDP模型,返回GenericMDP具有以下属性的对象。

Name of the current state, specified as a string.

国家名称,指定为字符串向量与兰gth equal to the number of states.

动作名称,指定为字符串向量,长度等于操作数量。

状态过渡矩阵,指定为3-D数组,该矩阵确定了环境中代理的可能运动。状态过渡矩阵t是一个概率矩阵,指示代理从当前状态移动的可能性s到任何可能的下一个状态S'byperforming action一个t是一个s-经过-s-经过-一个数组,哪里s是州的数量和一个一世sthe number of actions. It is given by:

t (( s ,,,, s ' ,,,, 一个 = p r o b 一个 b 一世 l 一世 t y (( s ' | s ,,,, 一个

从非终端状态出来的过渡概率的总和s遵循给定的操作必须总结一个。因此,必须同时指定从给定状态的所有随机过渡。

例如,指出状态1遵循行动4there is an equal probability of moving to states2or3,,,,use the following:

mdp.t(1,[2 3],4)= [0.5 0.5];

您还可以指定,在采取行动之后,存在某种可能保留在同一状态的可能性。例如:

MDP.T(1,[1 2 3 4],1)= [0.25 0.25 0.25 0.25];

奖励过渡矩阵,指定为3-D阵列,该矩阵确定代理在环境中执行诉讼后获得的奖励。r具有与状态过渡矩阵相同的形状和大小t。从国家移动的奖励stost一个teS'byperforming action一个是(谁)给的:

r = r (( s ,,,, s ' ,,,, 一个

网格世界中的终端状态名称,指定为状态名称的字符串向量。

版本历史记录

在R2019a中引入