scipy.optimize.fmin_cg:“'由于精度损失,未必实现所需误差。'

时间:2015-07-17 11:34:53

标签: python scipy mathematical-optimization minimize

我正在使用scipy.optimize.fmin_cg来最小化一个函数。该函数采用各种数据集,fmin_cg为许多数据集返回好的值,但前3个失败的除外:

DATASET:  0
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 2.988730
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00011672   -0.63965932]

DATASET:  1
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 3.076145
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00013434   -0.58092425]

DATASET:  2
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 3.160507
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00014962   -0.52933729]

DATASET:  3
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.00729686   23.29306024]

DATASET:  4
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.00915456   30.21053839]

DATASET:  5
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.01103431   37.37704849]

DATASET:  6
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03064942  118.1983465 ]

DATASET:  7
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03454471  135.11401129]

DATASET:  8
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03848004  152.4157083 ]

等....................

优化结果从x0 = [500,-1]初始猜测开始,将500降低到大约300会导致所有成功,但无论选择什么值,结果都不会接近预期的任何值。 (应该有很大的差异,我得到的是微小的变化,当它们中的一些之间应该看到最多4的比率。但是,返回数组中的第二个值表现得如预期的那样)

0 个答案:

没有答案