69 if (counter_ > nPrevSteps_)
73 newOrder[0] = nPrevSteps_ - 1;
74 for (label i = 1; i < nPrevSteps_; ++i)
78 list.reorder(newOrder);
81 list[nPrevSteps_ - 1] =
f;
85 list[counter_ - 1] =
f;
95 (objectiveDerivatives_ - derivativesOld_, activeDesignVars_);
96 pivotFields(y_, yRecent);
99 scalarField sActive(correctionOld_, activeDesignVars_);
100 pivotFields(s_, sActive);
103 <<
"y fields" <<
nl << y_ <<
endl;
105 <<
"s fields" <<
nl << s_ <<
endl;
111 Info<<
"Using steepest descent to update design variables" <<
endl;
112 correction_ = -eta_*objectiveDerivatives_;
120 label nSteps(
min(counter_, nPrevSteps_));
121 label nLast(nSteps - 1);
122 scalarField q(objectiveDerivatives_, activeDesignVars_);
125 for (label i = nLast; i > -1; --i)
127 r[i] = 1./globalSum(y_[i]*s_[i]);
128 a[i] = r[i]*globalSum(s_[i]*q);
133 globalSum(y_[nLast]*s_[nLast])/globalSum(y_[nLast]*y_[nLast]);
137 for (label i = 0; i < nSteps; ++i)
139 b = r[i]*globalSum(y_[i]*q);
140 q += s_[i]*(a[i] -
b);
146 correction_[activeDesignVars_[varI]] = -etaHessian_*q[varI];
155 if (counter_ < nSteepestDescent_)
157 steepestDescentUpdate();
166 derivativesOld_ = objectiveDerivatives_;
167 correctionOld_ = correction_;
173 if (optMethodIODict_.headerOk())
175 optMethodIODict_.readEntry(
"y", y_);
176 optMethodIODict_.readEntry(
"s", s_);
177 optMethodIODict_.readEntry(
"derivativesOld", derivativesOld_);
178 optMethodIODict_.readEntry(
"counter", counter_);
179 optMethodIODict_.readEntry(
"eta", eta_);
180 optMethodIODict_.readEntry(
"correctionOld", correctionOld_);
184 if (activeDesignVars_.empty())
186 activeDesignVars_ =
identity(derivativesOld_.size());
197 const dictionary&
dict
205 coeffsDict().getOrDefault<scalar>(
"etaHessian", 1)
209 coeffsDict().getOrDefault<label>(
"nSteepestDescent", 1)
211 activeDesignVars_(0),
214 coeffsDict().getOrDefault<label>(
"nPrevSteps", 10)
228 Info<<
"\t Did not find explicit definition of active design variables. "
229 <<
"Treating all available ones as active " <<
endl;
258 correctionOld_ = oldCorrection;
266 optMethodIODict_.add<
scalarField>(
"derivativesOld", derivativesOld_,
true);
267 optMethodIODict_.add<
scalarField>(
"correctionOld", correctionOld_,
true);
268 optMethodIODict_.add<label>(
"counter", counter_,
true);