ClearAll["Global`*"] \[Alpha]=0.3; \[Beta]=0.95; \[Delta]=0.1; \[Sigma]=1.5; size=99; K=Range[0.1,5,4.9/(size)]; V=Table[0,{size}]; ast=With[{n=size}, obj= ParallelTable[ If[i^\[Alpha]+(1-\[Delta])*i-j<0,-10^9, ((i^\[Alpha]+(1-\[Delta])*i-j)^(1-\[Sigma])-1)/(1-\[Sigma])], {i,0.1,5,4.9/n},{j,0.1,5,4.9/n}]; loops=0; \[Epsilon]=99999; Print[ Grid[{{"loop number ",Dynamic[loops]," with distance ", Dynamic[NumberForm[\[Epsilon], ExponentFunction->(If[-10<#<10,Null,#]&)]]}}]]; NestWhile[ Transpose[SortBy[#,First][[-1]]&/@Table[{obj[[i,j]]+\[Beta]*#[[1,j]], Range[0.1,5,4.9/n][[j]]},{i,n+1},{j,n+1}]//Parallelize]&, {Table[0,n+1],Table[0,n+1]},(loops++;\[Epsilon]=Norm[#1[[1]]-#2[[1]]]; Norm[#1[[1]]-#2[[1]]]>10^-6)&,2] ];
Mathematica 教學:Value function iterations for deterministic cake eating problem
由 戴忠淵 於 2023年2月3日星期五
下午10:01 發表
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~