标签:https spl images new problem for mes pop 梯度
博客转自:https://www.cnblogs.com/lcchuguo/p/5407709.html
简单介绍
ipopt是一个解决非线性规划最优化问题的工具集,当然,它也能够用于解决线性规划问题的求解。它提供了c/c++接口,很易于使用。
解决类似以下的非线性问题:
Ipopt工具採用内点法求解非线性优化问题。
需要计算
1. 梯度
计算目标函数的梯度,和约束条件Jacobian矩阵
2. Hessian矩阵
delta and lambda are parameters for object function and constraints functions (lambda is multiplier of Lagrangian)
求解以下的最优化问题:
至此,准备工作已经就绪,接下来调用Ipopt 的API接口进行计算。
1.get_nlp_info设置以下的參数
2.get_bounds_info 设置以下的參数
3.get_start_point设置以下參数
4.eval_f设置以下參数
5.eval_grad_f设置目标函数的梯度
6.eval_g设置约束条件
7.eval_jac_g设置Jacobian矩阵
8.eval_h设置Hessian矩阵
i. 目标函数
ii. 约束1
iii. 约束2
9.finalize_solution求解
源代码位于: https://github.com/coin-or/Ipopt, 附带的例子在/path2Ipopt/Ipopt-3.12.11/Ipopt/examples.
自己定义类继承于TNLP (public TNLP),使用命名空间:Ipopt (using namespace Ipopt),程序实现下面的虚函数即可
/**@name Overloaded from TNLP */ //@{ /** Method to return some info about the nlp */ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, Index& nnz_h_lag, IndexStyleEnum& index_style); /** Method to return the bounds for my problem */ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, Index m, Number* g_l, Number* g_u); /** Method to return the starting point for the algorithm */ virtual bool get_starting_point(Index n, bool init_x, Number* x, bool init_z, Number* z_L, Number* z_U, Index m, bool init_lambda, Number* lambda); /** Method to return the objective value */ virtual bool eval_f(Index n, const Number* x, bool new_x, Number& obj_value); /** Method to return the gradient of the objective */ virtual bool eval_grad_f(Index n, const Number* x, bool new_x, Number* grad_f); /** Method to return the constraint residuals */ virtual bool eval_g(Index n, const Number* x, bool new_x, Index m, Number* g); /** Method to return: * 1) The structure of the jacobian (if "values" is NULL) * 2) The values of the jacobian (if "values" is not NULL) */ virtual bool eval_jac_g(Index n, const Number* x, bool new_x, Index m, Index nele_jac, Index* iRow, Index *jCol, Number* values); /** Method to return: * 1) The structure of the hessian of the lagrangian (if "values" is NULL) * 2) The values of the hessian of the lagrangian (if "values" is not NULL) */ virtual bool eval_h(Index n, const Number* x, bool new_x, Number obj_factor, Index m, const Number* lambda, bool new_lambda, Index nele_hess, Index* iRow, Index* jCol, Number* values); //@} /** @name Solution Methods */ //@{ /** This method is called when the algorithm is complete so the TNLP can store/write the solution */ virtual void finalize_solution(SolverReturn status, Index n, const Number* x, const Number* z_L, const Number* z_U, Index m, const Number* g, const Number* lambda, Number obj_value, const IpoptData* ip_data, IpoptCalculatedQuantities* ip_cq); //@}
NLP 4:Interfacing your NLP to Ipopt 流程翻译
标签:https spl images new problem for mes pop 梯度
原文地址:https://www.cnblogs.com/flyinggod/p/12953392.html