本文整理汇总了C++中ipopt::SmartPtr::get_nlp_info方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::get_nlp_info方法的具体用法?C++ SmartPtr::get_nlp_info怎么用?C++ SmartPtr::get_nlp_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipopt::SmartPtr
的用法示例。
在下文中一共展示了SmartPtr::get_nlp_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IpBlasDcopy
bool
TNLPSolver::zeroDimension(const Ipopt::SmartPtr<Ipopt::TNLP>& tnlp, ReturnStatus &optimizationStatus)
{
int n,m,dum1, dum2;
Ipopt::TNLP::IndexStyleEnum dum3;
tnlp->get_nlp_info(n,m,dum1, dum2, dum3);
double * x_l = new double[n];
double * x_u = new double[n];
double * g_l = (m>0) ? new double[m] : NULL;
double * g_u = (m >0) ? new double[m] : NULL;
tnlp->get_bounds_info(n, x_l, x_u, m, g_l , g_u);
for(int i = 0 ; i < n ; i++) {
if(x_u[i] - x_l[i] > 1e-5)
{
delete [] x_l;
delete [] x_u;
if(m > 0){
delete [] g_l;
delete [] g_u;
}
return 0;
}
}
//Problem has no variables just check if the unique solution given by the bounds is
// feasible or not.
double obj_value;
tnlp->eval_f(n, x_l, true, obj_value);
double * x_sol = new double[n];
IpBlasDcopy(n, x_l, 1, x_sol, 1);
delete [] x_l;
delete [] x_u;
double * g_sol = (m > 0) ? new double [m] : NULL;
tnlp->eval_g(n, x_sol, true, m, g_sol);
optimizationStatus = solvedOptimal;
for(int i = 0 ; i < m ; i++) {
if(g_sol[i] - g_l[i] < - 1e-07 || g_sol[i] - g_u[i] > 1e-07) {
optimizationStatus = provenInfeasible;
delete [] g_l;
delete [] g_u;
double * lam = (m > 0) ? new double[m]: NULL;
CoinFillN(lam,m,0.);
double * z = new double[n];
CoinFillN(z,n,0.);
tnlp->finalize_solution(Ipopt::LOCAL_INFEASIBILITY,
n, x_sol, NULL, NULL,
m, g_sol, NULL, obj_value, NULL, NULL);
if (m > 0) delete [] lam;
delete [] z;
if (m > 0) delete [] g_sol;
delete [] x_sol;
return 1;
}
}
if (m > 0) delete [] g_l;
if (m > 0) delete [] g_u;
double * lam = (m > 0) ? new double[m] : NULL;
CoinFillN(lam,m,0.);
double * z = new double[n];
CoinFillN(z,n,0.);
tnlp->finalize_solution(Ipopt::SUCCESS,
n, x_sol, z, z,
m, g_sol, lam, obj_value, NULL, NULL);
if (m > 0) delete [] lam;
delete [] z;
if (m > 0) delete [] g_sol;
delete [] x_sol;
return 1;
}