Mantid
Loading...
Searching...
No Matches
MinimizerStatus.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2026 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9#include <boost/python/args.hpp>
10#include <boost/python/class.hpp>
11
12using namespace boost::python;
13
14namespace {
17struct MinimizerStatusNamespace {};
18} // namespace
19
21 auto pythonClass = class_<MinimizerStatusNamespace, boost::noncopyable>(
22 "MinimizerStatus",
23 "The status strings a function minimizer reports through a fit's OutputStatus, and the test for "
24 "whether one of them means the fit converged. Mirrors Mantid::API::MinimizerStatus so Python "
25 "callers do not have to hard code the wording.",
26 no_init);
27
28 pythonClass.def("isConverged", &Mantid::API::MinimizerStatus::isConverged, (arg("status"), arg("strict") = false),
29 "Whether a fit OutputStatus means the minimizer converged. With strict=True only 'success' "
30 "counts; otherwise the tolerance-limited stopping conditions do too, because a minimizer "
31 "started from an already-optimal set of parameters stops that way routinely.");
32 pythonClass.staticmethod("isConverged");
33
34 pythonClass.attr("SUCCESS") = Mantid::API::MinimizerStatus::SUCCESS;
35 pythonClass.attr("CHANGES_IN_FUNCTION_TOO_SMALL") = Mantid::API::MinimizerStatus::CHANGES_IN_FUNCTION_TOO_SMALL;
36 pythonClass.attr("CHANGES_IN_PARAMETER_TOO_SMALL") = Mantid::API::MinimizerStatus::CHANGES_IN_PARAMETER_TOO_SMALL;
37}
void export_MinimizerStatus()
const std::string CHANGES_IN_FUNCTION_TOO_SMALL
Reported by Levenberg-Marquardt when the change in the cost function between iterations has fallen be...
bool isConverged(const std::string &status, const bool strict=false)
Whether a Fit "OutputStatus" string should be treated as a converged fit.
const std::string CHANGES_IN_PARAMETER_TOO_SMALL
Reported by Levenberg-Marquardt when the change in the parameter values between iterations has fallen...
const std::string SUCCESS
Reported when a minimizer has fully converged.