Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions roofit/roofitcore/src/RooMinimizerFcn.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ void RooMinimizerFcn::setOptimizeConstOnFunction(RooAbsArg::ConstOpCode opcode,
/// Evaluate function given the parameters in `x`.
double RooMinimizerFcn::operator()(const double *x) const
{
unsigned nDim = getNDim();
int nChanged = 0;
for (unsigned i = 0; i < _cachedInput.size(); ++i) {
if (_cachedInput[i] != x[i]) ++nChanged;
_cachedInput[i] = x[i];
}

if(_cachedInput.empty()) {
_cachedInput.resize(nDim);
for (unsigned i = 0; i < nDim; i++) {
_cachedInput[i] = x[i];
}
}

// TODO: doc
const bool shouldDirtyInhibit = nChanged > 2;

if (shouldDirtyInhibit) {
RooAbsArg::setDirtyInhibit(true);
}

// Set the parameter values for this iteration
for (unsigned index = 0; index < getNDim(); index++) {
if (_logfile)
Expand All @@ -90,6 +111,10 @@ double RooMinimizerFcn::operator()(const double *x) const
double fvalue = _funct->getVal();
RooAbsReal::setHideOffset(true);

if (shouldDirtyInhibit) {
RooAbsArg::setDirtyInhibit(false);
}

fvalue = applyEvalErrorHandling(fvalue);

// Optional logging
Expand Down
1 change: 1 addition & 0 deletions roofit/roofitcore/src/RooMinimizerFcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class RooMinimizerFcn : public RooAbsMinimizerFcn {
RooAbsReal *_funct = nullptr;
std::unique_ptr<ROOT::Math::IBaseFunctionMultiDim> _multiGenFcn;
mutable std::vector<double> _gradientOutput;
mutable std::vector<double> _cachedInput;
};

#endif
Expand Down
Loading