当前位置: 首页>>代码示例>>C++>>正文


C++ SmartPtr::IterationCount方法代码示例

本文整理汇总了C++中ipopt::SmartPtr::IterationCount方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::IterationCount方法的具体用法?C++ SmartPtr::IterationCount怎么用?C++ SmartPtr::IterationCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ipopt::SmartPtr的用法示例。


在下文中一共展示了SmartPtr::IterationCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: solve


//.........这里部分代码省略.........
  } else if (ws_ && ws_->hasInfo() && stats_->calls > 1) {
    status = myapp_->ReOptimizeTNLP(mynlp_);
  } else {
    status = myapp_->OptimizeTNLP(mynlp_);
  }

#if SPEW
  logger_->msgStream(LogDebug) << me_ << "time taken = " << timer_->query() 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "Ipopt's status = " << status 
    << std::endl;
#endif
  //exit(0);

  // See IpReturnCodes_inc.h for the list
  switch (status) {
   case Ipopt::Solve_Succeeded : 
     status_ = ProvenLocalOptimal;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Solved_To_Acceptable_Level :
     status_ = ProvenLocalOptimal;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Infeasible_Problem_Detected :
     status_ = ProvenLocalInfeasible;
     break;
   case Ipopt::Maximum_Iterations_Exceeded :
     status_ = EngineIterationLimit;
     break;
   case Ipopt::Maximum_CpuTime_Exceeded :
     status_ = EngineIterationLimit;
     break;
   case Ipopt::Restoration_Failed :  // don't know what else to do.
     logger_->msgStream(LogInfo) << me_ << "restoration failed, "
       << "assuming local infeasible." << std::endl;
     status_ = ProvenLocalInfeasible;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Diverging_Iterates :
     status_ = ProvenUnbounded;
     break;
   case Ipopt::Search_Direction_Becomes_Too_Small :
     assert(!"Ipopt: search direction becomes too small.");
     break;
   case Ipopt::User_Requested_Stop:
     assert(!"Ipopt: user requested stop.");
     break;
   case Ipopt::Feasible_Point_Found:
     assert(!"Ipopt: feasible point found.");
     break;
   case Ipopt::Error_In_Step_Computation:
   case Ipopt::Not_Enough_Degrees_Of_Freedom:
   case Ipopt::Invalid_Problem_Definition:
   case Ipopt::Invalid_Option:
   case Ipopt::Invalid_Number_Detected:
   case Ipopt::Unrecoverable_Exception:
   case Ipopt::NonIpopt_Exception_Thrown:
   case Ipopt::Insufficient_Memory:
   case Ipopt::Internal_Error:
   default:
     logger_->msgStream(LogNone) << me_ << "error reported." << std::endl;
     status_ = EngineError;
  }
  if (prepareWs_) {
    // save warm start information
    ws_->setPoint(sol_);
  }

  Ipopt::SmartPtr<Ipopt::SolveStatistics> stats = myapp_->Statistics();
  // sometimes, (e.g. when all variables are fixed) ipopt does not solve
  // anything returns an empty Statistics object.
  UInt iters = (Ipopt::IsValid(stats)) ? stats->IterationCount() : 0;
#if SPEW
  logger_->msgStream(LogDebug) << me_ << "solve number = " << stats_->calls
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "number of iterations = " << iters 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "status = " << getStatusString() 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "obj = ";
  if (sol_) {
    logger_->msgStream(LogDebug) << mynlp_->getSolutionValue() << std::endl;
  } else {
    logger_->msgStream(LogDebug) << 1e40 << std::endl;
  }
#endif 
  if (true == strBr_) {
    stats_->strCalls += 1;
    stats_->strTime  += timer_->query();
    stats_->strIters += iters;
  } 
  stats_->time  += timer_->query();
  stats_->iters += iters;
  timer_->stop();

  bndChanged_ = false;
  consChanged_ = false;
  return status_;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:101,代码来源:IpoptEngine.cpp


注:本文中的ipopt::SmartPtr::IterationCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。