アットウィキロゴ

ui

Function checku(th As Single, bp As Single, wp As Single) As Single
Dim ls As Single
Dim cs As Single
Dim us As Single
Dim ys As Single
Dim ws As Single
Dim l1 As Single
Dim c1 As Single
Dim u1 As Single
Dim l2 As Single
Dim y2 As Single
Dim y1 As Single
Dim c2 As Single
Dim u2 As Single
Dim h As Single
Dim lp As Single
Dim t1 As Single
Dim t2 As Single
Dim e As Single
Dim s As Single
e = 10 ^ (-5)
h = 0.1
ls = (bp + 0.1) / th
ys = th * ls
cs = th * ls - bp
us = Log(cs) + Log(1 - ls)
t2 = 0
Do Until t2 > 10
t1 = 0
Do Until t1 > 100
l1 = ls + h
If l1 > 0.99 Then l1 = ls
c1 = th * l1 - bp
y1 = th * l1
u1 = Log(c1) + Log(1 - l1)
l2 = ls - h
If l2 < 0.01 Then l2 = ls
c2 = th * l2 - bp
If c2 < 0.01 Then l2 = ls
c2 = th * l2 - bp
u2 = Log(c2) + Log(1 - l2)
If u1 > us Then ls = l1
If u1 > us Then us = u1
If u2 > us Then ls = l2
If u2 > us Then us = u2
If (lp - ls) ^ 2 < e Then t1 = 1000
lp = ls
t1 = t1 + 1
Loop
h = h / 2
t2 = t2 + 1
Loop
checku = us
End Function
Function seeku(th As Single, bp As Single, wp As Single) As Single
Dim ls As Single
Dim cs As Single
Dim us As Single
Dim ys As Single
Dim ws As Single
Dim l1 As Single
Dim c1 As Single
Dim u1 As Single
Dim l2 As Single
Dim y2 As Single
Dim y1 As Single
Dim c2 As Single
Dim u2 As Single
Dim h As Single
Dim lp As Single
Dim t1 As Single
Dim t2 As Single
Dim e As Single
Dim s As Single
Dim the As Single
the = 1.1
e = 10 ^ (-5)
h = 0.1
ls = (bp + 0.1) / th
ys = th * ls
cs = th * ls - bp
us = Log(cs) + Log(1 - ls)
ws = Log(cs) + Log(1 - ys / the)
If ws > w1 Then us = -999
t2 = 0
Do Until t2 > 10
t1 = 0
Do Until t1 > 100
l1 = ls + h
If l1 > 0.99 Then l1 = ls
c1 = th * l1 - bp
y1 = th * l1
u1 = Log(c1) + Log(1 - l1)
w1 = Log(c1) + Log(1 - y1 / the)
If w1 > wp Then u1 = -999
l2 = ls - h
If l2 < 0.01 Then l2 = ls
c2 = th * l2 - bp
If c2 < 0.01 Then l2 = ls
c2 = th * l2 - bp
u2 = Log(c2) + Log(1 - l2)
w2 = Log(c2) + Log(1 - y2 / the)
If w2 > wp Then u2 = -999
If u1 > us Then ls = l1
If u1 > us Then us = u1
If u2 > us Then ls = l2
If u2 > us Then us = u2
If (lp - ls) ^ 2 < e Then t1 = 1000
lp = ls
t1 = t1 + 1
Loop
h = h / 2
t2 = t2 + 1
Loop
seeku = us
End Function
Private Sub Command1_Click()
Dim u(-100 To 100, 1 To 100) As Single
Dim uk(-100 To 100, 1 To 100) As Single
Dim b(-100 To 100) As Single
Dim w(1 To 100) As Single
Dim m As Single
Dim n As Single
Dim w0 As Single
Dim th As Single
th = 1
For m = -100 To 100
b(m) = 0.001 * m
Next
w1 = Log(0.4) + Log(0.4)
ww = (Log(0.7) + Log(0.7) - w1) / 100
For n = 1 To 100
w(n) = w1 + ww * n
Next
For m = -100 To 100
For n = 1 To 100
u(m, n) = seeku(th, b(m), w(n))
Next
Next
For m = -100 To 100
For n = 1 To 100
uk(m, n) = checku(th, b(m), w(n))
Next
Next
For m = -100 To 100
For n = 1 To 100
If u(m, n) > uk(m, n) Then u(m, n) = -999
If u(m, n) = uk(m, n) Then u(m, n) = -999
Next
Next
For n = 1 To 100
Debug.Print n, u(0, n)
Next
End Sub
最終更新:2009年08月05日 23:51