<?php
for ( $n=1; $n<=100; $n++ ){
$th[$n] = 0.02*$n;
$ys[$n] = 0.5*$th[$n];
$cs[$n] = $ys[$n] ;
}
$h =0.01;
$time=1;
do {
for ( $s=1; $s<=99; $s++ ){
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
$c1 = $cs[$s] + $m * $h;
$y1 = $ys[$s] + $n * $h;
$l1 = $y1 / $th[$s];
$pp = 0;
If ($l1 < 0){
$l1 =0;
}
If ($l1 < 0){
$pp =1;
}
If ($l1 > 0.99){
$pp =1;
}
If ($l1 > 0.99){
$l1 =0.5;
}
If ($c1 < 0.001){
$pp =1;
}
If ($c1 < 0.001){
$c1 =0.5;
}
$u[$s][$m][$n] = Log($c1) + Log(1 - $l1);
If ($pp > 0){
$u[$s][$m][$n] =-999;
}
}
}
}
for ( $s=1; $s<=99; $s++ ){
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
$c1 = $cs[$s] + $m * $h;
$y1 = $ys[$s] + $n * $h;
$l1 = $y1 / $th[$s+1];
$pp = 0;
If ($l1 < 0){
$l1 =0;
}
If ($l1 < 0){
$pp =1;
}
If ($l1 > 0.99){
$pp =1;
}
If ($l1 > 0.99){
$l1 =0.5;
}
If ($c1 < 0.001){
$pp =1;
}
If ($c1 < 0.001){
$c1 =0.5;
}
$w[$s][$m][$n] = Log($c1) + Log(1 - $l1);
If ($pp > 0){
$w[$s][$m][$n] =-999;
}
}
}
}
for ( $s=1; $s<=99; $s++ ){
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
for ( $q=-5; $q<=5; $q++ ){
$v[$s][$m][$n][$q] =-999;
}
}
}
}
$s = 1;
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
$q = $n - $m;
$v[$s][$m][$n][$q] = $u[$s][$m][$n];
}
}
for ( $s=2; $s<=99; $s++ ){
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
for ( $q=-5; $q<=5; $q++ ){
$u1 = $u[$s][$m][$n];
$c1 = $cs[$s] + $m * $h;
$y1 = $ys[$s] + $n * $h;
$qx = $q + $m - $n;
$t=0;
If ($qx > 5){
$t = 1000;
}
If ($qx < -5){
$t = 1000;
}
$vs = -999;
do {
for ( $mx=-1; $mx<=1; $mx++ ){
for ( $nx=-1; $nx<=1; $nx++ ){
$pp = 0;
$w1 = $w[$s-1][$mx][$nx];
If ($w1 > $u1){
$pp = 1;
}
$c2 = $cs[$s-1] + $mx * $h;
$y2 = $ys[$s-1] + $nx * $h;
If ($y2 > $y1){
$pp = 1;
}
If ($c2 > $c1){
$pp = 1;
}
If ($v[$s-1][$mx][$nx][$qx] <-900){
$pp=1;
}
$v1 = $u1 + $v[$s-1][$mx][$nx][$qx];
If ($pp > 0){
$v1=-999;
}
If ($v1 > $vs){
$mxs=$mx;
}
If ($v1 > $vs){
$nxs=$nx;
}
If ($v1 > $vs){
$vs=$v1;
}
}
}
$v[$s][$m][$n][$q]=$vs;
$gotoc[$s][$m][$n][$q]=$mxs;
$gotoy[$s][$m][$n][$q]=$nxs;
$t=150;
}
while($t < 100);
}
}
}
}
$s = 100;
$vs = -999;
for ( $m=-1; $m<=1; $m++ ){
for ( $n=-1; $n<=1; $n++ ){
$c1 = $cs[$s] + $m * $h;
$y1 = $ys[$s] + $n * $h;
$l1=$y1/$th[$s];
$u1=Log($c1) + Log(1 - $l1);
$qx = $m - $n;
for ( $mx=-1; $mx<=1; $mx++ ){
for ( $nx=-1; $nx<=1; $nx++ ){
$pp = 0;
$w1 = $w[$s-1][$mx][$nx];
If ($w1 > $u1){
$pp = 1;
}
$c2 = $cs[$s-1] + $mx * $h;
$y2 = $ys[$s-1] + $nx * $h;
If ($y2 > $y1){
$pp = 1;
}
If ($c2 > $c1){
$pp = 1;
}
If ($v[$s-1][$mx][$nx][$qx] <-900){
$pp=1;
}
$v1 = $u1 + $v[$s-1][$mx][$nx][$qx];
If ($pp > 0){
$v1=-999;
}
If ($v1 > $vs){
$ms=$m;
}
If ($v1 > $vs){
$ns=$n;
}
If ($v1 > $vs){
$mxs=$mx;
}
If ($v1 > $vs){
$nxs=$nx;
}
If ($v1 > $vs){
$vs=$v1;
}
}
}
}
}
$opc[100] = $ms;
$opy[100] = $ns;
$opc[99] = $mxs;
$opy[99] = $nxs;
$opq[99] = $ms - $ns;
for ( $t=1; $t<=98; $t++ ){
$s = 99 - $t;
$opc[$s] = $gotoc[$s+1][$opc[$s+1]] [$opy[$s+1]][$opq[$s+1]];
$opy[$s] = $gotoy[$s+1][$opc[$s+1]] [$opy[$s+1]][$opq[$s+1]];
$opq[$s] = $opq[$s + 1] + $opc[$s + 1] - $opy[$s + 1];
}
for ( $s=1; $s<=100; $s++ ){
$cs[$s] = $cs[$s] + $opc[$s] * $h;
$ys[$s] = $ys[$s] + $opy[$s] * $h;
}
$e=0;
for ( $s=1; $s<=100; $s++ ){
$e=$e+$opc[$s]*$opc[$s]+$opy[$s]*$opy[$s];
}
If ($e < 5){
$h=$h/2;
}
print($e);
print(",");
print($vs);
print(";");
$time = $time + 1;
}
while($time < 10);
?>
最終更新:2009年08月30日 00:18