76 y.map(objectiveDerivatives_ - derivativesOld_, activeDesignVars_);
77 s.map(correctionOld_, activeDesignVars_);
79 scalar ys = globalSum(
s*
y);
81 if (counter_ == 1 && scaleFirstHessian_)
83 scalar scaleFactor = ys/globalSum(
y*
y);
84 Info<<
"Scaling Hessian with factor " << scaleFactor <<
endl;
85 forAll(activeDesignVars_, varI)
87 HessianInvOld_[varI][varI] *= scaleFactor;
92 if (ys < curvatureThreshold_)
95 <<
" y*s is below threshold! y*s=" << ys <<
endl;
99 <<
"Hessian curvature index " << ys <<
endl;
104 + (ys + globalSum(leftMult(
y, HessianInvOld_)*
y))/
sqr(ys)*outerProd(
s,
s)
107 outerProd(rightMult(HessianInvOld_,
y),
s)
108 + outerProd(
s, leftMult(
y, HessianInvOld_))
117 if (counter_ < nSteepestDescent_)
119 Info<<
"Using steepest descent to update design variables" <<
endl;
120 correction_ = -eta_*objectiveDerivatives_;
127 activeDerivs.
map(objectiveDerivatives_, activeDesignVars_);
130 -etaHessian_*rightMult(HessianInv_, activeDerivs)
135 forAll(activeDesignVars_, varI)
137 correction_[activeDesignVars_[varI]] = activeCorrection[varI];
142 derivativesOld_ = objectiveDerivatives_;
143 correctionOld_ = correction_;
144 HessianInvOld_ = HessianInv_;
150 if (optMethodIODict_.headerOk())
152 optMethodIODict_.readEntry(
"HessianInvOld", HessianInvOld_);
153 optMethodIODict_.readEntry(
"derivativesOld", derivativesOld_);
154 optMethodIODict_.readEntry(
"correctionOld", correctionOld_);
155 optMethodIODict_.readEntry(
"counter", counter_);
156 optMethodIODict_.readEntry(
"eta", eta_);
158 label n = HessianInvOld_.n();
176 coeffsDict().lookupOrDefault<scalar>(
"etaHessian", 1)
180 coeffsDict().lookupOrDefault<label>(
"nSteepestDescent", 1)
182 activeDesignVars_(0),
185 coeffsDict().lookupOrDefault<bool>(
"scaleFirstHessian",
false)
189 coeffsDict().lookupOrDefault<scalar>(
"curvatureThreshold", 1
e-10)
200 !coeffsDict().readIfPresent(
"activeDesignVariables", activeDesignVars_)
205 Info<<
"\t Did not find explicit definition of active design variables."
206 <<
" Treating all available ones as active" <<
endl;
235 correctionOld_ = oldCorrection;
247 optMethodIODict_.add<
scalarField>(
"derivativesOld", derivativesOld_,
true);
248 optMethodIODict_.add<
scalarField>(
"correctionOld", correctionOld_,
true);
249 optMethodIODict_.add<
label>(
"counter", counter_,
true);