本文整理汇总了C++中nox::abstract::Group::getNormF方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::getNormF方法的具体用法?C++ Group::getNormF怎么用?C++ Group::getNormF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nox::abstract::Group
的用法示例。
在下文中一共展示了Group::getNormF方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
NOX::Solver::TensorBased::implementGlobalStrategy(NOX::Abstract::Group& newGrp,
double& in_stepSize,
const NOX::Solver::Generic& s)
{
bool ok;
counter.incrementNumLineSearches();
isNewtonDirection = false;
NOX::Abstract::Vector& searchDirection = *tensorVecPtr;
if ((counter.getNumLineSearches() == 1) || (lsType == Newton))
{
isNewtonDirection = true;
searchDirection = *newtonVecPtr;
}
// Do line search and compute new soln.
if ((lsType != Dual) || (isNewtonDirection))
ok = performLinesearch(newGrp, in_stepSize, searchDirection, s);
else if (lsType == Dual)
{
double fTensor = 0.0;
double fNew = 0.0;
double tensorStep = 1.0;
bool isTensorDescent = false;
const Abstract::Group& oldGrp = s.getPreviousSolutionGroup();
double fprime = slopeObj.computeSlope(searchDirection, oldGrp);
// Backtrack along tensor direction if it is descent direction.
if (fprime < 0)
{
ok = performLinesearch(newGrp, in_stepSize, searchDirection, s);
assert(ok);
fTensor = 0.5 * newGrp.getNormF() * newGrp.getNormF();
tensorStep = in_stepSize;
isTensorDescent = true;
}
// Backtrack along the Newton direction.
ok = performLinesearch(newGrp, in_stepSize, *newtonVecPtr, s);
fNew = 0.5 * newGrp.getNormF() * newGrp.getNormF();
// If backtracking on the tensor step produced a better step, then use it.
if (isTensorDescent && (fTensor <= fNew))
{
newGrp.computeX(oldGrp, *tensorVecPtr, tensorStep);
newGrp.computeF();
}
}
return ok;
}
示例2: return
double NOX::MeritFunction::SumOfSquares::
computef(const NOX::Abstract::Group& grp) const
{
if ( !(grp.isF()) ) {
utils->err()
<< "ERROR: NOX::MeritFunction::SumOfSquares::computef() - "
<< "F has not been computed yet!. Please call "
<< "computeF() on the group passed into this function."
<< std::endl;
throw "NOX Error";
}
return (0.5 * grp.getNormF() * grp.getNormF());
}
示例3: switch
double NOX::StatusTest::NormF::computeNorm(const NOX::Abstract::Group& grp)
{
if (!grp.isF())
return -1.0;
double norm;
int n = grp.getX().length();
switch (normType)
{
case NOX::Abstract::Vector::TwoNorm:
norm = grp.getNormF();
if (scaleType == Scaled)
norm /= sqrt(1.0 * n);
break;
default:
norm = grp.getF().norm(normType);
if (scaleType == Scaled)
norm /= n;
break;
}
return norm;
}
示例4:
bool NOX::Direction::ModifiedNewton::rescueBadNewtonSolve(const NOX::Abstract::Group& grp) const
{
//! Check if the "rescue" option has been selected
if (!doRescue)
return false;
//! See if the group has compute the accuracy
double accuracy;
NOX::Abstract::Group::ReturnType status = oldJacobianGrpPtr->getNormLastLinearSolveResidual(accuracy);
// If this functionality is not supported in the group, return false
/* NOTE FROM TAMMY: We could later modify this to acutally caluclate
the error itself if it's just a matter of the status being
NotDefined. */
if (status != NOX::Abstract::Group::Ok)
return false;
// Check if there is any improvement in the relative residual
double normF = grp.getNormF();
// If we can't reduce the relative norm at all, we're not happy
if (accuracy >= normF)
return false;
// Otherwise, we just print a warning and keep going
if (utils->isPrintType(NOX::Utils::Warning))
utils->out() << "WARNING: NOX::Direction::ModifiedNewton::compute - Unable to achieve desired linear solve accuracy." << std::endl;
return true;
}
示例5: getNormModelResidual
void
NOX::Solver::TensorBased::printDirectionInfo(std::string dirName,
const NOX::Abstract::Vector& dir,
const NOX::Abstract::Group& soln,
bool isTensorModel) const
{
double dirNorm = dir.norm();
double residual = getNormModelResidual(dir, soln, isTensorModel);
double residualRel = residual / soln.getNormF();
double fprime = getDirectionalDerivative(dir, soln);
double fprimeRel = fprime / dirNorm;
if (utilsPtr->isPrintType(NOX::Utils::Details))
{
utilsPtr->out() << " " << dirName << " norm of model residual = "
<< utilsPtr->sciformat(residual, 6) << " (abs) "
<< utilsPtr->sciformat(residualRel, 6) << " (rel)" << std::endl;
utilsPtr->out() << " " << dirName << " directional derivative = "
<< utilsPtr->sciformat(fprime, 6) << " (abs) "
<< utilsPtr->sciformat(fprimeRel, 6) << " (rel)" << std::endl;
utilsPtr->out() << " " << dirName << " norm = "
<< utilsPtr->sciformat(dirNorm, 6) << std::endl;
}
}
示例6:
double NOX::LineSearch::Polynomial::
computeValue(const NOX::Abstract::Group& grp, double phi)
{
double value = phi;
if (suffDecrCond == AredPred)
{
value = grp.getNormF();
}
return value;
}
示例7:
bool NOX::Direction::Broyden::doRestart(NOX::Abstract::Group& soln,
const NOX::Solver::LineSearchBased& solver)
{
// Test 1 - First iteration!
if (solver.getNumIterations() == 0)
return true;
// Test 2 - Frequency
if (cnt >= cntMax)
return true;
// Test 3 - Last step was zero!
if (solver.getStepSize() == 0.0)
return true;
// Test 4 - Check for convergence rate
convRate = soln.getNormF() / solver.getPreviousSolutionGroup().getNormF();
if (convRate > maxConvRate)
return true;
return false;
}
示例8: if
// **************************************************************************
// *** computeForcingTerm
// **************************************************************************
double NOX::Direction::Utils::InexactNewton::
computeForcingTerm(const NOX::Abstract::Group& soln,
const NOX::Abstract::Group& oldsoln,
int niter,
const NOX::Solver::Generic& solver,
double eta_last)
{
const std::string indent = " ";
if (forcingTermMethod == Constant) {
if (printing->isPrintType(NOX::Utils::Details)) {
printing->out() << indent << "CALCULATING FORCING TERM" << std::endl;
printing->out() << indent << "Method: Constant" << std::endl;
printing->out() << indent << "Forcing Term: " << eta_k << std::endl;
}
if (setTolerance)
paramsPtr->sublist(directionMethod).sublist("Linear Solver").
set("Tolerance", eta_k);
return eta_k;
}
// Get linear solver current tolerance.
// NOTE: These values are changing at each nonlinear iteration and
// must either be updated from the parameter list each time a compute
// is called or supplied during the function call!
double eta_km1 = 0.0;
if (eta_last < 0.0)
eta_km1 = paramsPtr->sublist(directionMethod).
sublist("Linear Solver").get("Tolerance", 0.0);
else
eta_km1 = eta_last;
// Tolerance may have been adjusted in a line search algorithm so we
// have to account for this.
const NOX::Solver::LineSearchBased* solverPtr = 0;
solverPtr = dynamic_cast<const NOX::Solver::LineSearchBased*>(&solver);
if (solverPtr != 0) {
eta_km1 = 1.0 - solverPtr->getStepSize() * (1.0 - eta_km1);
}
if (printing->isPrintType(NOX::Utils::Details)) {
printing->out() << indent << "CALCULATING FORCING TERM" << std::endl;
printing->out() << indent << "Method: " << method << std::endl;
}
if (forcingTermMethod == Type1) {
if (niter == 0) {
eta_k = eta_initial;
}
else {
// Return norm of predicted F
// do NOT use the following lines!! This does NOT account for
// line search step length taken.
// const double normpredf = 0.0;
// oldsoln.getNormLastLinearSolveResidual(normpredf);
// Create a new vector to be the predicted RHS
if (Teuchos::is_null(predRhs)) {
predRhs = oldsoln.getF().clone(ShapeCopy);
}
if (Teuchos::is_null(stepDir)) {
stepDir = oldsoln.getF().clone(ShapeCopy);
}
// stepDir = X - oldX (i.e., the step times the direction)
stepDir->update(1.0, soln.getX(), -1.0, oldsoln.getX(), 0);
// Compute predRhs = Jacobian * step * dir
if (!(oldsoln.isJacobian())) {
if (printing->isPrintType(NOX::Utils::Details)) {
printing->out() << "WARNING: NOX::InexactNewtonUtils::resetForcingTerm() - "
<< "Jacobian is out of date! Recomputing Jacobian." << std::endl;
}
const_cast<NOX::Abstract::Group&>(oldsoln).computeJacobian();
}
oldsoln.applyJacobian(*stepDir, *predRhs);
// Compute predRhs = RHSVector + predRhs (this is the predicted RHS)
predRhs->update(1.0, oldsoln.getF(), 1.0);
// Compute the norms
double normpredf = predRhs->norm();
double normf = soln.getNormF();
double normoldf = oldsoln.getNormF();
if (printing->isPrintType(NOX::Utils::Details)) {
printing->out() << indent << "Forcing Term Norm: Using L-2 Norm."
<< std::endl;
}
//.........这里部分代码省略.........