文書の過去の版を表示しています。
mmdp_create.ageing.matrix = function(S) { R = max(S)-min(S) n = length(S) if( R != n-1 ) { stop("age space is not regular and/or does not begin with 0.") } max.S = max(S) P = rbind(cbind(0,diag(rep(1,max.S))),0) P[max.S+1,max.S+1] = 1 rownames(P)=S colnames(P)=S return(P) } S.Dgr = c(0:4) S.Age = c(0:10) P.Dgr = matrix(c( 9/10, 1/10, 0, 0, 0, 0, 9/10, 1/10, 0, 0, 0, 0, 9/10, 1/10, 0, 0, 0, 0, 9/10, 1/10, 1, 0, 0, 0, 0), nrow=5, ncol=5, byrow=TRUE) rownames(P.Dgr) = c(0:4) colnames(P.Dgr) = c(0:4) P.Age = mmdp_create.ageing.matrix(S.Age) P.Hrd = mmdp_create.age.replacement.matrix(S.Age,4) P.Dgr.2 = mmdp_expand.P.2(list(P.Dgr,P.Age)) P.Hrd.2 = mmdp_expand.P.2(list(mmdp_create.replacement.matrix(S.Dgr),P.Hrd)) P = array(0,dim=c(dim(P.Dgr.2)[1],dim(P.Dgr.2)[2],2)) P[,,1] = P.Dgr.2 P[,,2] = P.Hrd.2 C.Opr.Dgr = c(0,0,0,0,2000) C.Opr.Age = rep(0,11) C.Rpl.Dgr = c(150,150,150,150,150) C.Rpl.Age = rep(0,11) C.Opr.Opr = mmdp_expand.R.2(list(C.Opr.Dgr,C.Opr.Age)) C.Rpl.Rpl = mmdp_expand.R.2(list(C.Rpl.Dgr,C.Rpl.Age)) Cost = cbind(C.Opr.Opr,C.Rpl.Rpl) R = -Cost mdp_eval_policy_iterative(P,R,0.95,c(rep(1,5*6),rep(2,5*5))) mdp_value_iteration(P,R,0.95)