LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
24 #ifndef LSST_MEAS_MODELFIT_optimizer_h_INCLUDED
25 #define LSST_MEAS_MODELFIT_optimizer_h_INCLUDED
35 namespace lsst {
namespace meas {
namespace modelfit {
91 ndarray::Array<Scalar const,2,1>
const & parameters,
92 ndarray::Array<Scalar,1,1>
const & output
104 ndarray::Array<Scalar const,1,1>
const & parameters,
105 ndarray::Array<Scalar,1,1>
const & residuals
122 ndarray::Array<Scalar const,1,1>
const & parameters,
123 ndarray::Array<Scalar,2,-2>
const & derivatives
142 virtual Scalar computePrior(ndarray::Array<Scalar const,1,1>
const & parameters)
const {
return 1.0; }
159 ndarray::Array<Scalar const,1,1>
const & parameters,
160 ndarray::Array<Scalar,1,1>
const & gradient,
161 ndarray::Array<Scalar,2,1>
const & hessian
163 gradient.deep() = 0.0;
164 hessian.deep() = 0.0;
191 "If true, ignore the SR1 update term in the Hessian, resulting in a Levenberg-Marquardt-like method"
196 "Skip the SR1 update if |v||s| / (|v||s|) is less than this threshold"
201 "If the trust radius falls below this threshold, consider the algorithm converged"
206 "If the maximum of the gradient falls below this threshold, consider the algorithm converged"
211 "relative step size used for numerical derivatives (added to other steps)"
216 "absolute step size used for numerical derivatives (added to other steps)"
221 "step size (in units of trust radius) used for numerical derivatives (added to relative step)"
226 "steps with reduction ratio greater than this are accepted"
231 "the initial trust region will be set to this value"
236 "steps with reduction radio greater than this may increase the trust radius"
241 "steps with length this fraction of the trust radius may increase the trust radius"
246 "when increase the trust region size, multiply the radius by this factor"
251 "steps with reduction radio less than this will decrease the trust radius"
256 "when reducing the trust region size, multiply the radius by this factor"
261 "value passed as the tolerance to solveTrustRegion"
266 "maximum number of iterations (i.e. function evaluations and trust region subproblems) per step"
271 "maximum number of steps"
276 "whether to save all iterations for debugging purposes"
304 bool doRecordDerivatives
317 ndarray::Array<Scalar const,1,1>
const &
nested,
329 ndarray::Array<Scalar const,1,1>
const &
nested,
330 ndarray::Array<Scalar,1,1>
const & gradient,
331 ndarray::Array<Scalar,2,2>
const & hessian
336 ndarray::Array<Scalar,1,1>
const & gradient,
337 ndarray::Array<Scalar,2,2>
const & hessian
342 ndarray::Array<Scalar const,2,1>
const &
parameters,
343 ndarray::Array<Scalar,1,1>
const & output
428 ndarray::Array<Scalar const,1,1>
const & parameters,
436 bool step() {
return _stepImpl(0); }
439 return _stepImpl(0, &recorder, &history);
442 int run() {
return _runImpl(); }
445 return _runImpl(&recorder, &history);
452 ndarray::Array<Scalar const,1,1>
getParameters()
const {
return _current.parameters; }
454 ndarray::Array<Scalar const,1,1>
getResiduals()
const {
return _current.residuals; }
456 ndarray::Array<Scalar const,1,1>
getGradient()
const {
return _gradient; }
458 ndarray::Array<Scalar const,2,2>
getHessian()
const {
return _hessian; }
465 struct IterationData {
468 ndarray::Array<Scalar,1,1> parameters;
469 ndarray::Array<Scalar,1,1> residuals;
471 IterationData(
int dataSize,
int parameterSize);
486 void _computeDerivatives();
492 IterationData _current;
494 ndarray::Array<Scalar,1,1> _step;
495 ndarray::Array<Scalar,1,1> _gradient;
496 ndarray::Array<Scalar,2,2> _hessian;
497 ndarray::Array<
Scalar,2,-2> _residualDerivative;
519 ndarray::Array<Scalar,1,1>
const &
x,
520 ndarray::Array<Scalar const,2,1>
const & F, ndarray::Array<Scalar const,1,1>
const & g,
521 double r,
double tolerance
526 #endif // !LSST_MEAS_MODELFIT_optimizer_h_INCLUDED
void fillObjectiveModelGrid(afw::table::BaseRecord const &record, ndarray::Array< Scalar const, 2, 1 > const ¶meters, ndarray::Array< Scalar, 1, 1 > const &output) const
double skipSR1UpdateThreshold
"Skip the SR1 update if |v||s| / (|v||s|) is less than this threshold" ;
OptimizerHistoryRecorder(afw::table::Schema const &schema)
bool doSaveIterations
"whether to save all iterations for debugging purposes" ;
boost::shared_ptr< Objective const > getObjective() const
OptimizerHistoryRecorder(afw::table::Schema &schema, boost::shared_ptr< Model > model, bool doRecordDerivatives)
void unpackDerivatives(afw::table::BaseRecord const &record, Vector &gradient, Matrix &hessian) const
void unpackDerivatives(afw::table::BaseRecord const &record, ndarray::Array< Scalar, 1, 1 > const &gradient, ndarray::Array< Scalar, 2, 2 > const &hessian) const
double trustRegionInitialSize
"the initial trust region will be set to this value" ;
Base class for Bayesian priors.
OptimizerHistoryRecorder HistoryRecorder
void removeSR1Term()
Remove the symmetric-rank-1 secant term from the Hessian, making it just (J^T J)
double numDiffRelStep
"relative step size used for numerical derivatives (added to other steps)" ;
ndarray::Array< Scalar const, 1, 1 > getResiduals() const
void fillObjectiveValueGrid(ndarray::Array< Scalar const, 2, 1 > const ¶meters, ndarray::Array< Scalar, 1, 1 > const &output) const
Evaluate the Objective on a 1-d grid.
double Scalar
Typedefs to be used for probability and parameter values.
OptimizerObjective(int dataSize_, int parameterSize_)
Base class constructor; must be called by all subclasses.
Abstract base class and concrete factories that define multi-shapelet galaxy models.
Defines the fields and offsets for a table.
Scalar getObjectiveValue() const
bool step(HistoryRecorder const &recorder, afw::table::BaseCatalog &history)
@ FAILED_MAX_OUTER_ITERATIONS
afw::table::Key< int > outer
Base class for optimizer/sampler likelihood functions that compute likelihood at a point.
double trustRegionShrinkReductionRatio
"steps with reduction radio less than this will decrease the trust radius" ;
Base class for objective functions for Optimizer.
Control const & getControl() const
virtual ~OptimizerObjective()
Configuration object for Optimizer.
int maxInnerIterations
"maximum number of iterations (i.e. function evaluations and trust region subproblems) per step" ;
Optimizer(boost::shared_ptr< Objective const > objective, ndarray::Array< Scalar const, 1, 1 > const ¶meters, Control const &ctrl)
double trustRegionShrinkFactor
"when reducing the trust region size, multiply the radius by this factor" ;
virtual Scalar computePrior(ndarray::Array< Scalar const, 1, 1 > const ¶meters) const
Compute the value of the Bayesian prior for the given parameter vector.
ItemVariant const * other
Base class for all records.
double stepAcceptThreshold
"steps with reduction ratio greater than this are accepted" ;
void solveTrustRegion(ndarray::Array< Scalar, 1, 1 > const &x, ndarray::Array< Scalar const, 2, 1 > const &F, ndarray::Array< Scalar const, 1, 1 > const &g, double r, double tolerance)
Solve a symmetric quadratic matrix equation with a ball constraint.
virtual void differentiatePrior(ndarray::Array< Scalar const, 1, 1 > const ¶meters, ndarray::Array< Scalar, 1, 1 > const &gradient, ndarray::Array< Scalar, 2, 1 > const &hessian) const
Compute the first and second derivatives of the Bayesian prior with respect to the parameters.
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
bool noSR1Term
"If true, ignore the SR1 update term in the Hessian, resulting in a Levenberg-Marquardt-like method" ...
#define LSST_CONTROL_FIELD(NAME, TYPE, DOC)
A preprocessor macro used to define fields in C++ "control object" structs.
afw::table::Key< int > inner
A numerical optimizer customized for least-squares problems with Bayesian priors.
A base class for image defects.
@ FAILED_MAX_INNER_ITERATIONS
void unpackDerivatives(ndarray::Array< Scalar const, 1, 1 > const &nested, Vector &gradient, Matrix &hessian) const
virtual bool differentiateResiduals(ndarray::Array< Scalar const, 1, 1 > const ¶meters, ndarray::Array< Scalar, 2,-2 > const &derivatives) const
Evaluate analytic derivatives of the model or signal that they are not available.
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > Matrix
virtual bool hasPrior() const
Return true if the Objective has a Bayesian prior as well as a likelihood.
ndarray::Array< Scalar const, 1, 1 > getParameters() const
int run(HistoryRecorder const &recorder, afw::table::BaseCatalog &history)
double numDiffTrustRadiusStep
"step size (in units of trust radius) used for numerical derivatives (added to relative step)" ;
ndarray::Array< Scalar const, 2, 2 > getHessian() const
int maxOuterIterations
"maximum number of steps" ;
virtual void computeResiduals(ndarray::Array< Scalar const, 1, 1 > const ¶meters, ndarray::Array< Scalar, 1, 1 > const &residuals) const =0
Evaluate the residuals of the model for a given parameter vector.
afw::table::Key< int > state
void apply(int outerIterCount, int innerIterCount, afw::table::BaseCatalog &history, Optimizer const &optimizer) const
OptimizerObjective Objective
double trustRegionGrowStepFraction
"steps with length this fraction of the trust radius may increase the trust radius" ;
void swap(CameraSys &a, CameraSys &b)
double trustRegionGrowFactor
"when increase the trust region size, multiply the radius by this factor" ;
double trustRegionSolverTolerance
"value passed as the tolerance to solveTrustRegion" ;
double trustRegionGrowReductionRatio
"steps with reduction radio greater than this may increase the trust radius" ;
void unpackDerivatives(ndarray::Array< Scalar const, 1, 1 > const &nested, ndarray::Array< Scalar, 1, 1 > const &gradient, ndarray::Array< Scalar, 2, 2 > const &hessian) const
ndarray::Array< Scalar const, 1, 1 > getGradient() const
static boost::shared_ptr< OptimizerObjective > makeFromLikelihood(boost::shared_ptr< Likelihood > likelihood, boost::shared_ptr< Prior > prior=boost::shared_ptr< Prior >())
Return a concrete Objective object built from a Likelihood and Prior.
double minTrustRadiusThreshold
"If the trust radius falls below this threshold, consider the algorithm converged" ;
double gradientThreshold
"If the maximum of the gradient falls below this threshold, consider the algorithm converged" ;
double numDiffAbsStep
"absolute step size used for numerical derivatives (added to other steps)" ;