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


C++ EnvPtr类代码示例

本文整理汇总了C++中EnvPtr的典型用法代码示例。如果您正苦于以下问题:C++ EnvPtr类的具体用法?C++ EnvPtr怎么用?C++ EnvPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Environment

void AMPLOsiUT::setUp()
{
  EnvPtr env = (EnvPtr) new Environment();
  env->setLogLevel(LogNone);
  iface_ = (MINOTAUR_AMPL::AMPLInterfacePtr) new AMPLInterface(env);
  engine_ptr_ = (OsiLPEnginePtr) new OsiLPEngine(env);
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:7,代码来源:AMPLOsiUT.cpp

示例2: setInitialOptions

void setInitialOptions(EnvPtr env)
{
  env->getOptions()->findBool("presolve")->setValue(true);
  env->getOptions()->findBool("use_native_cgraph")->setValue(true);
  env->getOptions()->findBool("nl_presolve")->setValue(true);
  env->getOptions()->findBool("separability")->setValue(false);
  env->getOptions()->findBool("perspective")->setValue(false);
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:8,代码来源:mipdecoqg.cpp

示例3:

MultilinearTermsHandler::MultilinearTermsHandler(EnvPtr env, ProblemPtr problem)
  : env_(env), problem_(problem)
{
  logger_  = env->getLogger();
  eTol_ = env->getOptions()->findDouble("ml_feastol")->getValue();
  maxGroupSize_ = (UInt) env_->getOptions()->findInt("ml_max_group_size")->getValue();
  augmentCoverFactor_ = env_->getOptions()->findDouble("ml_cover_augmentation_factor")->getValue();

  initialTermCoverSize_ = 0;

}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:11,代码来源:MultilinearTermsHandler.cpp

示例4: get_current_env

ExprPtr Sym::eval()
{
	EnvPtr env = get_current_env();
	ExprPtr value = env->value_of(static_pointer_cast<Sym>(shared_from_this()));

	if (value == nullptr) {
		ostringstream oss;
		oss << "void variable " << m_name;
		throw Error(oss.str());
	}

	return value;
}
开发者ID:duyanning,项目名称:finelisp,代码行数:13,代码来源:Sym.cpp

示例5: RandomBrStats

RandomBrancher::RandomBrancher(EnvPtr env, HandlerVector handlers)
{
  logger_ = env->getLogger();
  timer_ = env->getNewTimer();
  stats_ = new RandomBrStats();
  stats_->calls = 0;
  stats_->time = 0.0;
  handlers_ = handlers;
  seed_ = env->getOptions()->findInt("rand_seed")->getValue();
  if (seed_ == 0) {
    srand(time(NULL));
  } else {
    srand(seed_);
  }
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:15,代码来源:RandomBrancher.cpp

示例6: ParQGStats

ParQGHandler::ParQGHandler(EnvPtr env, ProblemPtr minlp, EnginePtr nlpe)
: env_(env),
  minlp_(minlp),
  nlCons_(0),
  nlpe_(nlpe),
  nlpStatus_(EngineUnknownStatus),
  objVar_(VariablePtr()),
  oNl_(false),
  rel_(RelaxationPtr()),
  relobj_(0.0)
{
  intTol_ = env_->getOptions()->findDouble("int_tol")->getValue();
  solAbsTol_ = env_->getOptions()->findDouble("feasAbs_tol")->getValue();
  solRelTol_ = env_->getOptions()->findDouble("feasRel_tol")->getValue();
  npATol_ = env_->getOptions()->findDouble("solAbs_tol")->getValue();
  npRTol_ = env_->getOptions()->findDouble("solRel_tol")->getValue();
  logger_ = env->getLogger();

  stats_ = new ParQGStats();
  stats_->nlpS = 0;
  stats_->nlpF = 0;
  stats_->nlpI = 0;
  stats_->nlpIL = 0;
  stats_->cuts = 0;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:25,代码来源:ParQGHandler.cpp

示例7: writeSol

void writeSol(EnvPtr env, VarVector *orig_v,
              PresolverPtr pres, SolutionPtr sol, SolveStatus status,
              MINOTAUR_AMPL::AMPLInterface* iface)
{
  if (sol) {
    sol = pres->getPostSol(sol);
  }

  if (env->getOptions()->findFlag("AMPL")->getValue() ||
      true == env->getOptions()->findBool("write_sol_file")->getValue()) {
    iface->writeSolution(sol, status);
  } else if (sol && env->getLogger()->getMaxLevel()>=LogExtraInfo &&
             env->getOptions()->findBool("display_solution")->getValue()) {
    sol->writePrimal(env->getLogger()->msgStream(LogExtraInfo), orig_v);
  }
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:16,代码来源:QGAdv.cpp

示例8:

SOS1Handler::SOS1Handler(EnvPtr env, ProblemPtr problem)
  : env_(env)
{
  logger_ = env->getLogger();
  modProb_ = true;
  modRel_ = true;
  zTol_   = 1e-6;

  problem_  = problem;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:10,代码来源:SOS1Handler.cpp

示例9: defined

IpoptEngine::IpoptEngine(EnvPtr env)
: bndChanged_(false),
  consChanged_(false),
  env_(env),
  etol_(1e-7),
  myapp_(0),
  mynlp_(0),
  sol_(IpoptSolPtr()),      // NULL
  strBr_(false),
  timer_(0),
  ws_(IpoptWarmStartPtr()) // NULL
{
#if defined(USE_IPOPT)  
  problem_ = ProblemPtr();   // NULL
  logger_ = (LoggerPtr) new Logger((LogLevel) env->getOptions()->
      findInt("engine_log_level")->getValue());
  myapp_ = new Ipopt::IpoptApplication();
  setOptionsForRepeatedSolve();

  status_ = EngineError;
  if (env->getOptions()->findBool("use_warmstart")->getValue()==true) {
    prepareWs_ = true;
    useWs_ = true;
  } else {
    prepareWs_ = false;
    useWs_ = false;
  }
  timer_ = env->getNewTimer();

  stats_ = new IpoptStats();
  stats_->calls    = 0;
  stats_->strCalls = 0;
  stats_->time     = 0;
  stats_->ptime    = 0;
  stats_->strTime  = 0;
  stats_->iters    = 0;
  stats_->strIters = 0;
  
#else 
  assert(!"ipopt engine can only be called when compiled with ipopt!")
#endif
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:42,代码来源:IpoptEngine.cpp

示例10: Logger

Transformer::Transformer(EnvPtr env, ConstProblemPtr p)
  : env_(env),
    p_(p),
    yLfs_(0),
    yUniExprs_(0),
    yVars_(0),
    zTol_(1e-12)
{
  logger_ = (LoggerPtr) new Logger((LogLevel)(env->getOptions()
                                              ->findInt("trans_log_level")
                                              ->getValue()));
}
开发者ID:devanandR,项目名称:minotaur,代码行数:12,代码来源:Transformer.cpp

示例11: loadProblem

void loadProblem(EnvPtr env, MINOTAUR_AMPL::AMPLInterface* iface,
                 ProblemPtr &oinst, double *obj_sense)
{
  Timer *timer = env->getNewTimer();
  OptionDBPtr options = env->getOptions();
  JacobianPtr jac;
  HessianOfLagPtr hess;
  const std::string me("qg: ");

  timer->start();
  oinst = iface->readInstance(options->findString("problem_file")->getValue());
  env->getLogger()->msgStream(LogInfo) << me 
    << "time used in reading instance = " << std::fixed 
    << std::setprecision(2) << timer->query() << std::endl;

  // display the problem
  oinst->calculateSize();
  if (options->findBool("display_problem")->getValue()==true) {
    oinst->write(env->getLogger()->msgStream(LogNone), 12);
  }
  if (options->findBool("display_size")->getValue()==true) {
    oinst->writeSize(env->getLogger()->msgStream(LogNone));
  }
  // create the jacobian
  if (false==options->findBool("use_native_cgraph")->getValue()) {
    jac = (MINOTAUR_AMPL::AMPLJacobianPtr) 
      new MINOTAUR_AMPL::AMPLJacobian(iface);
    oinst->setJacobian(jac);

    // create the hessian
    hess = (MINOTAUR_AMPL::AMPLHessianPtr)
      new MINOTAUR_AMPL::AMPLHessian(iface);
    oinst->setHessian(hess);
  }

  // set initial point
  oinst->setInitialPoint(iface->getInitialPoint(), 
      oinst->getNumVars()-iface->getNumDefs());

  if (oinst->getObjective() &&
      oinst->getObjective()->getObjectiveType()==Maximize) {
    *obj_sense = -1.0;
    env->getLogger()->msgStream(LogInfo) << me 
      << "objective sense: maximize (will be converted to Minimize)"
      << std::endl;
  } else {
    *obj_sense = 1.0;
    env->getLogger()->msgStream(LogInfo) << me 
      << "objective sense: minimize" << std::endl;
  }

  delete timer;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:53,代码来源:QGAdv.cpp

示例12: presolve

PresolverPtr presolve(EnvPtr env, ProblemPtr p, size_t ndefs, 
                      HandlerVector &handlers)
{
  PresolverPtr pres = PresolverPtr(); // NULL
  const std::string me("qg: ");

  p->calculateSize();
  if (env->getOptions()->findBool("presolve")->getValue() == true) {
    LinearHandlerPtr lhandler = (LinearHandlerPtr) new LinearHandler(env, p);
    handlers.push_back(lhandler);
    if (p->isQP() || p->isQuadratic() || p->isLinear() ||
        true==env->getOptions()->findBool("use_native_cgraph")->getValue()) {
      lhandler->setPreOptPurgeVars(true);
      lhandler->setPreOptPurgeCons(true);
      lhandler->setPreOptCoeffImp(true);
    } else {
      lhandler->setPreOptPurgeVars(false);
      lhandler->setPreOptPurgeCons(false);
      lhandler->setPreOptCoeffImp(false);
    }
    if (ndefs>0) {
      lhandler->setPreOptDualFix(false);
    } else {
      lhandler->setPreOptDualFix(true);
    }

    if (!p->isLinear() && 
        true==env->getOptions()->findBool("use_native_cgraph")->getValue() && 
        true==env->getOptions()->findBool("nl_presolve")->getValue() 
       ) {
      NlPresHandlerPtr nlhand = (NlPresHandlerPtr) new NlPresHandler(env, p);
      handlers.push_back(nlhand);
    }

    // write the names.
    env->getLogger()->msgStream(LogExtraInfo) << me 
      << "handlers used in presolve:" << std::endl;
    for (HandlerIterator h = handlers.begin(); h != handlers.end(); 
        ++h) {
      env->getLogger()->msgStream(LogExtraInfo) << me 
        << (*h)->getName() << std::endl;
    }
  }

  pres = (PresolverPtr) new Presolver(p, env, handlers);
  pres->standardize(); 
  if (env->getOptions()->findBool("presolve")->getValue() == true) {
    pres->solve();
  }
  return pres;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:51,代码来源:QGAdv.cpp

示例13: sepDetection

//For separability detection: Check separability if problem is not linear.
//TransSepPtr sepDetection(EnvPtr env, ProblemPtr p)
void sepDetection(EnvPtr env, ProblemPtr p)
{
  TransSepPtr sep = TransSepPtr();
  const std::string me("PDEqg: ");

  if (env->getOptions()->findBool("separability")->getValue() == true) {
    if (p -> isLinear()) {
      env ->getLogger()->msgStream(LogInfo) << me
        << "Problem is linear, skipping separability detection" 
        << std::endl;
    } else {
      sep = (TransSepPtr) new TransSep(env, p);
      sep->findSep();
      env ->getLogger()->msgStream(LogDebug) << me
        << "Is problem separable? - "<< sep->getStatus() 
        << std::endl;
    }
  }
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:21,代码来源:mipdecoqg.cpp

示例14: showInfo

int showInfo(EnvPtr env)
{
  OptionDBPtr options = env->getOptions();
  const std::string me("qg: ");

  if (options->findBool("display_options")->getValue() ||
      options->findFlag("=")->getValue()) {
    options->write(std::cout);
    return 1;
  }

  if (options->findBool("display_help")->getValue() ||
      options->findFlag("?")->getValue()) {
    showHelp();
    return 1;
  }

  if (options->findBool("display_version")->getValue() ||
      options->findFlag("v")->getValue()) {
    env->getLogger()->msgStream(LogNone) << me <<
      "Minotaur version " << env->getVersion() << std::endl;
    env->getLogger()->msgStream(LogNone) << me 
      << "Quesada-Grossmann (LP/NLP) algorithm for convex MINLP" << std::endl;
    return 1;
  }

  if (options->findString("problem_file")->getValue()=="") {
    showHelp();
    return 1;
  }

  env->getLogger()->msgStream(LogInfo)
    << me << "Minotaur version " << env->getVersion() << std::endl
    << me << "Quesada-Grossmann (LP/NLP) algorithm for convex MINLP"
    << std::endl;
  return 0;
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:37,代码来源:QGAdv.cpp

示例15: writeBnbStatus

void writeBnbStatus(EnvPtr env, BranchAndBound *bab, double obj_sense)
{

  const std::string me("qg: ");
  int err = 0;

  if (bab) {
    env->getLogger()->msgStream(LogInfo)
      << me << std::fixed << std::setprecision(4) 
      << "best solution value = " << obj_sense*bab->getUb() << std::endl
      << me << std::fixed << std::setprecision(4)
      << "best bound estimate from remaining nodes = "
      << obj_sense*bab->getLb() << std::endl
      << me << "gap = " << std::max(0.0,bab->getUb() - bab->getLb())
      << std::endl
      << me << "gap percentage = " << bab->getPerGap() << std::endl
      << me << "time used (s) = " << std::fixed << std::setprecision(2) 
      << env->getTime(err) << std::endl
      << me << "status of branch-and-bound: " 
      << getSolveStatusString(bab->getStatus()) << std::endl;
    env->stopTimer(err); assert(0==err);
  } else {
    env->getLogger()->msgStream(LogInfo)
      << me << std::fixed << std::setprecision(4)
      << "best solution value = " << INFINITY << std::endl
      << me << std::fixed << std::setprecision(4)
      << "best bound estimate from remaining nodes = " << INFINITY << std::endl
      << me << "gap = " << INFINITY << std::endl
      << me << "gap percentage = " << INFINITY << std::endl
      << me << "time used (s) = " << std::fixed << std::setprecision(2) 
      << env->getTime(err) << std::endl 
      << me << "status of branch-and-bound: " 
      << getSolveStatusString(NotStarted) << std::endl;
    env->stopTimer(err); assert(0==err);
  }
}
开发者ID:ashutoshmahajan,项目名称:minotaur,代码行数:36,代码来源:QGAdv.cpp


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