本文整理汇总了C++中VariableList::GetBoundConstraints方法的典型用法代码示例。如果您正苦于以下问题:C++ VariableList::GetBoundConstraints方法的具体用法?C++ VariableList::GetBoundConstraints怎么用?C++ VariableList::GetBoundConstraints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableList
的用法示例。
在下文中一共展示了VariableList::GetBoundConstraints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
//.........这里部分代码省略.........