为提高优化方法中敏度计算的精度和效率,比较研究了拟梯度、复数步长微分和自动微分三种数值方法原理及实现。采用操作符重载和模板技术实现复数步长微分和自动微分,并将自动微分前向模式和反向模式结合起来计算Hesse矩阵。研究表明:拟梯度能有效地减少函数求值次数,但对高度非线性函数其计算精度较差;复数步长微分方法简单,能得到机器精度的梯度值,但需要处理复数,计算量较大;自动微分在函数求值的同时并行计算高阶精确导数值,计算量适中。
To enhancing accuracy and efficiency of sensitivity analysis in optimization, three numerical methods: quasi-gradient, complex-step derivative and automatic differentiation, are studied and compared form theory, implementations and applications. An implementation of automatic differentiation using operator overloading and templates is de- scribed in detail, which provides a flexible way to compute hesse matrix by combining forward & reverse methods. The re- suits of numerical examples show that: quasi-gradient has the best efficiency, bht its precision is very poor when used in high nonlinear problems. Complex-step derivative is accurate and easy to implement with high computational expense. Automatic differentiation can get exact high order derivatives simultaneously with function evaluating and with compromise computational expense.