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 HessianOld_[varI][varI] /= scaleFactor;
91 scalar sBs = globalSum(leftMult(
s, HessianOld_)*
s);
98 <<
" y*s is below threshold. Using damped form" <<
endl;
99 theta = (scalar(1)-gamma_)*sBs/(sBs - ys);
103 <<
"Hessian curvature index " << ys <<
endl;
105 scalarField r(theta*
y + (scalar(1)-theta)*rightMult(HessianOld_,
s));
110 - outerProd(rightMult(HessianOld_,
s), leftMult(
s/sBs, HessianOld_))
111 + outerProd(r, r/globalSum(
s*r));
121 if (counter_ < nSteepestDescent_)
123 Info<<
"Using steepest descent to update design variables" <<
endl;
124 correction_ = -eta_*objectiveDerivatives_;
131 activeDerivs.
map(objectiveDerivatives_, activeDesignVars_);
134 -etaHessian_*rightMult(HessianInv, activeDerivs)
139 forAll(activeDesignVars_, varI)
141 correction_[activeDesignVars_[varI]] = activeCorrection[varI];
146 derivativesOld_ = objectiveDerivatives_;
147 correctionOld_ = correction_;
148 HessianOld_ = Hessian_;
154 if (optMethodIODict_.headerOk())
156 optMethodIODict_.readEntry(
"HessianOld", HessianOld_);
157 optMethodIODict_.readEntry(
"derivativesOld", derivativesOld_);
158 optMethodIODict_.readEntry(
"correctionOld", correctionOld_);
159 optMethodIODict_.readEntry(
"counter", counter_);
160 optMethodIODict_.readEntry(
"eta", eta_);
162 label n = HessianOld_.n();
182 coeffsDict().lookupOrDefault<scalar>(
"etaHessian", 1)
186 coeffsDict().lookupOrDefault<label>(
"nSteepestDescent", 1)
188 activeDesignVars_(0),
191 coeffsDict().lookupOrDefault<bool>(
"scaleFirstHessian",
false)
195 coeffsDict().lookupOrDefault<scalar>(
"curvatureThreshold", 1
e-10)
202 gamma_(coeffsDict().lookupOrDefault<scalar>(
"gamma", 0.2))
207 !coeffsDict().readIfPresent(
"activeDesignVariables", activeDesignVars_)
212 Info<<
"\t Did not find explicit definition of active design variables."
213 " Treating all available ones as active " <<
endl;
242 correctionOld_ = oldCorrection;
249 optMethodIODict_.add<
scalarField>(
"derivativesOld", derivativesOld_,
true);
250 optMethodIODict_.add<
scalarField>(
"correctionOld", correctionOld_,
true);
251 optMethodIODict_.add<
label>(
"counter", counter_,
true);