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


C++ VariableList::lowerExists方法代码示例

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


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

示例1: CreateApplicationOptimizer

OptError NewtonProblem::CreateApplicationOptimizer(OptimizeClass * &objfcn,
						   NLP0 * &func)
{
  OptError error;
  int numVar = GetNumVar();
  VariableList* variables = GetVariables();
  CompoundConstraint* constraints = 0;

  AppLauncher * launcher = GetAppLauncher();
  USERFCN0APP userFcn = &(launcher->run_app);
  INITFCNAPP initFcn = &(launcher->init_app);

  if(userFcn == NULL)
  {
    error.value = -4;
    error.msg = "Error loading  user function";
    return error;
  }
  else if(initFcn == NULL)	
  {
    error.value = -4;
    error.msg = "Error loading init function";
    return error;
  }

  if ((variables->linearExists()) || (variables->nonlinearExists()))
  {
    cout << "Newton does not support linear or nonlinear constraints." << endl;
    cout << "Linear and nonlinear constraints being ignored." << endl;
  }
  if ((variables->upperExists()) || (variables->lowerExists()))
  {
    constraints = new CompoundConstraint(Constraint(variables->GetBoundConstraints()));
  }

  FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn,
				     launcher, constraints);
  myFunc->setIsExpensive(true);
  if(searchType_ == trustPDS)
    myFunc->setSpecOption(NoSpec);
  func = myFunc;

  if ((variables->upperExists()) || (variables->lowerExists()))
  {
    objfcn = new OptBCQNewton(myFunc);
  }
  else
  {
    objfcn = new OptQNewton(myFunc);
  }

  error.value = 0;
  error.msg = "Success";
  return error;
}	
开发者ID:OpenCMISS-Dependencies,项目名称:optpp,代码行数:55,代码来源:NewtonProblem.C

示例2: CreateApplicationOptimizer

OptError CGProblem::CreateApplicationOptimizer(OptimizeClass* &objfcn,
					       NLP0* &func)
{
  OptError error;

  int numVar = GetNumVar();
  VariableList* variables = GetVariables();
  AppLauncher* launcher = GetAppLauncher();
  USERFCN0APP userFcn = &(launcher->run_app);
  INITFCNAPP initFcn = &(launcher->init_app);

  if ((variables->upperExists()) || (variables->lowerExists()) ||
      (variables->linearExists()) || (variables->nonlinearExists()))
  {
    cout << "CG does not support constraints." << endl;
    cout << "Constraints being ignored" << endl;
  }

  FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn,
				     launcher);
  myFunc->setIsExpensive(true);
  func = myFunc;

  objfcn = new OptCG(myFunc);

  error.value = 0;
  error.msg = "Success";
  return error;
}	
开发者ID:OpenCMISS-Dependencies,项目名称:optpp,代码行数:29,代码来源:CGProblem.C

示例3: SetParameters

void NewtonProblem::SetParameters(OptimizeClass* objfcn)
{
  Problem::SetParameters(objfcn);

  DOMElement* searchXML = GetParameterXML();
  VariableList* variables = GetVariables();

  string gradMult, searchSize, maxBack;

  OptNewtonLike * objfcnNewt = (OptNewtonLike *) objfcn;

  if(searchType_ == trustPDS)
  {
    objfcnNewt->setSearchStrategy(TrustPDS);

    gradMult =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
    if (gradMult != "")
      objfcnNewt->setGradMult(atof(gradMult.c_str()));

    searchSize =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("searchSize")));
    if (searchSize != "")
      objfcnNewt->setSearchSize(atoi(searchSize.c_str()));
  }
  else if (searchType_ == lineSearch)
  {
    objfcnNewt->setSearchStrategy(LineSearch);

    maxBack =
      XMLString::transcode(searchXML->getAttribute(XMLString::transcode("maxBTIter")));
    if (maxBack != "")
      objfcnNewt->setMaxBacktrackIter(atoi(maxBack.c_str()));
  }
  else if (searchType_ == trustRegion)
  {
    if ((variables->upperExists()) || (variables->lowerExists()))
    {
      cout << "Newton with Trust Region does not support bounds." << endl;
      cout << "Using Line Search instead." << endl;
      objfcnNewt->setSearchStrategy(LineSearch);
    }
    else
    {
      objfcnNewt->setSearchStrategy(TrustRegion);
      gradMult =
	XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
      if (gradMult != "")
	objfcnNewt->setGradMult(atof(gradMult.c_str()));
    }
  }
  else
  {
    cerr << "Unrecognized search strategy type" << endl;
    exit(1);
  }
}
开发者ID:OpenCMISS-Dependencies,项目名称:optpp,代码行数:57,代码来源:NewtonProblem.C

示例4: CreateFunctionOptimizer

OptError NewtonProblem::CreateFunctionOptimizer(OptimizeClass *
						&objfcn, NLP0 * &func)
{
  OptError error;

  int numVar = GetNumVar();
  int derivOrder = GetDerivOrder();
  VariableList* variables = GetVariables();
  CompoundConstraint* constraints = 0;

  if ((variables->linearExists()) || (variables->nonlinearExists()))
  {
    cout << "Newton does not support linear or nonlinear constraints." << endl;
    cout << "Linear and nonlinear constraints being ignored." << endl;
  }
  if ((variables->upperExists()) || (variables->lowerExists()))
  {
    constraints = new CompoundConstraint(Constraint(variables->GetBoundConstraints()));
  }

  if(derivOrder == 2)
    {
      USERFCN2 userFcn = GetUserFunction2();
      INITFCN initFcn = GetInitFunction();
      if(userFcn == NULL || initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading function";
	  return error;
	}
		
      NLF2 * myFunc = new NLF2(numVar, userFcn, initFcn, constraints);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());

      if ((variables->upperExists()) || (variables->lowerExists()))
      {
	objfcn = new OptBCNewton(myFunc);
      }
      else
      {
	objfcn = new OptNewton(myFunc);
      }

      func = myFunc;
    }
  else if(derivOrder == 1)
    {
      // construct a function with 1st derivative info

      USERFCN1 userFcn = GetUserFunction1();
      INITFCN initFcn = GetInitFunction();
      if(userFcn == NULL || initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading function";
	  return error;
	}

      NLF1 * myFunc = new NLF1(numVar, userFcn, initFcn, constraints);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());

      if ((variables->upperExists()) || (variables->lowerExists()))
      {
	objfcn = new OptBCQNewton(myFunc);
      }
      else
      {
	objfcn = new OptQNewton(myFunc);
      }

      func = myFunc;
    }
  else if(derivOrder == 0)
    {
      INITFCN initFcn = GetInitFunction();
      USERFCN0 userFcn = GetUserFunction0();
      if(userFcn == NULL)
	{
	  error.value = -4;
	  error.msg = "Error loading  user function";
	  return error;
	}
      else if(initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading init function";
	  return error;
	}

      // construct a function with no derivative info 
      // but use finite differences to approximate a first derivative
		
      FDNLF1 * myFunc = new FDNLF1(numVar, userFcn, initFcn, constraints);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());
      if(searchType_ == trustPDS)
	myFunc->setSpecOption(NoSpec);

//.........这里部分代码省略.........
开发者ID:OpenCMISS-Dependencies,项目名称:optpp,代码行数:101,代码来源:NewtonProblem.C

示例5: CreateFunctionOptimizer

OptError CGProblem::CreateFunctionOptimizer(OptimizeClass* &objfcn,
					    NLP0* &func)
{
  OptError error;

  int numVar = GetNumVar();
  int derivOrder = GetDerivOrder();
  VariableList* variables = GetVariables();

  if ((variables->upperExists()) || (variables->lowerExists()) ||
      (variables->linearExists()) || (variables->nonlinearExists()))
  {
    cout << "CG does not support constraints." << endl;
    cout << "Constraints being ignored." << endl;
  }

  // construct a function with 2nd derivative info

  if(derivOrder == 2)
    {
      USERFCN2 userFcn = GetUserFunction2();
      INITFCN initFcn = GetInitFunction();
      if(userFcn == NULL || initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading function";
	  return error;
	}

      NLF2* myFunc = new NLF2(numVar, userFcn, initFcn);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());
      func = myFunc;
    }
  else if(derivOrder == 1)
    {
      // construct a function with 1st derivative info

      USERFCN1 userFcn = GetUserFunction1();
      INITFCN initFcn = GetInitFunction();
      if(userFcn == NULL || initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading function";
	  return error;
	}

      NLF1* myFunc = new NLF1(numVar, userFcn, initFcn);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());
      func = myFunc;
    }
  else if(derivOrder == 0)
    {
      USERFCN0 userFcn = GetUserFunction0();
      INITFCN initFcn = GetInitFunction();
      if(userFcn == NULL || initFcn == NULL)	
	{
	  error.value = -4;
	  error.msg = "Error loading function";
	  return error;
	}

      // construct a function with no derivative info 
      // but use finite differences to approximate a first derivative

      FDNLF1* myFunc = new FDNLF1(numVar, userFcn, initFcn);
      myFunc->setIsExpensive(true);
      myFunc->setX(variables->GetInitialValues());
      func = myFunc;
    }

  objfcn = new OptCG((NLP1 *)func);
  error.value = 0;
  error.msg = "Success";
  return error;
}
开发者ID:OpenCMISS-Dependencies,项目名称:optpp,代码行数:77,代码来源:CGProblem.C


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