第13章 非線形計画法1
p.183 13.3 数値例
$$z=(x_1-0.4)^2+(x_1^2-x_2)^2$$
|
|
optim関数
|
|
res1
$par
[1] 0.3999843 0.1599676
$value
[1] 6.418712e-10
$counts
function gradient
65 NA
$convergence
[1] 0
$message
NULL
res2
$par
[1] 0.3999996 0.1599998
$value
[1] 1.90708e-13
$counts
function gradient
44 8
$convergence
[1] 0
$message
NULL
nlm関数
|
|
iteration = 0
Step:
[1] 0 0
Parameter:
[1] 0.7 0.1
Function Value
[1] 0.2421
Gradient:
[1] 1.692004 -0.779999
iteration = 1
Step:
[1] -0.5671855 0.2614676
Parameter:
[1] 0.1328145 0.3614676
Function Value
[1] 0.1896057
Gradient:
[1] -0.7170319 0.6876567
iteration = 2
Step:
[1] 0.1649014 -0.1289381
Parameter:
[1] 0.2977159 0.2325294
Function Value
[1] 0.03116773
Gradient:
[1] -0.3759261 0.2877904
iteration = 3
Step:
[1] 0.1700224 -0.1027900
Parameter:
[1] 0.4677383 0.1297395
Function Value
[1] 0.01251654
Gradient:
[1] 0.3020677 -0.1780783
iteration = 4
Step:
[1] -0.07571050 0.03934948
Parameter:
[1] 0.3920278 0.1690890
Function Value
[1] 0.0003008131
Gradient:
[1] -0.04009667 0.03080731
iteration = 5
Step:
[1] 0.008790654 -0.005936946
Parameter:
[1] 0.4008185 0.1631520
Function Value
[1] 6.902751e-06
Gradient:
[1] -0.002364139 0.004994147
iteration = 6
Step:
[1] 0.0005560509 -0.0011409333
Parameter:
[1] 0.4013745 0.1620111
Function Value
[1] 2.716608e-06
Gradient:
[1] 0.001290329 0.001820160
iteration = 7
Step:
[1] -0.0002615382 -0.0007293589
Parameter:
[1] 0.4011130 0.1612817
Function Value
[1] 1.390881e-06
Gradient:
[1] 0.0016016819 0.0007812045
iteration = 8
Step:
[1] -0.0008547694 -0.0012077649
Parameter:
[1] 0.4002582 0.1600740
Function Value
[1] 8.427007e-08
Gradient:
[1] 0.0007304588 -0.0002643501
iteration = 9
Step:
[1] -0.0002260824 -0.0001034215
Parameter:
[1] 0.4000321 0.1599705
Function Value
[1] 4.07474e-09
Gradient:
[1] 0.0001541471 -0.0001093301
iteration = 10
Step:
[1] -3.469470e-05 2.288681e-05
Parameter:
[1] 0.3999974 0.1599934
Function Value
[1] 2.708321e-11
Gradient:
[1] 3.720641e-06 -8.042856e-06
iteration = 11
Parameter:
[1] 0.3999986 0.1599982
Function Value
[1] 2.371377e-12
Gradient:
[1] -1.683298e-07 -2.551870e-07
相対勾配が 0 に近くなっています
現在の繰り返しでおそらく解が得られたでしょう
res
$minimum
[1] 2.371377e-12
$estimate
[1] 0.3999986 0.1599982
$gradient
[1] -1.683298e-07 -2.551870e-07
$code
[1] 1
$iterations
[1] 11
BBパッケージ
|
|
ans1<-BBoptim(x0,model)
iter: 0 f-value: 0.2421 pgrad: 1.692
Successful convergence.
ans2<-spg(x0,model)
iter: 0 f-value: 0.2421 pgrad: 1.692
ans1
$par
[1] 0.4000003 0.1599993
$value
[1] 1.070274e-12
$gradient
[1] 2.365078e-06
$fn.reduction
[1] 0.2421
$iter
[1] 9
$feval
[1] 11
$convergence
[1] 0
$message
[1] “Successful convergence”
$cpar
method M
2 50
ans2
$par
[1] 0.3999964 0.1599958
$value
[1] 1.447905e-11
$gradient
[1] 4.911558e-06
$fn.reduction
[1] 0.2421
$iter
[1] 9
$feval
[1] 11
$convergence
[1] 0
$message
[1] “Successful convergence”