Go to the documentation of this file.
20 using namespace gtsam;
33 noiseModel::Diagonal::Sigmas(
Vector3(0.3, 0.3, 0.1));
38 noiseModel::Diagonal::Sigmas(
Vector3(0.2, 0.2, 0.1));
50 noiseModel::Diagonal::Sigmas(
Vector3(0.2, 0.2, 0.1));
52 constraintUncertainty);
58 initialEstimate.insert(1,
x1);
60 initialEstimate.insert(2,
x2);
62 initialEstimate.insert(3,
x3);
64 initialEstimate.insert(4,
x4);
66 initialEstimate.insert(5,
x5);
68 return {
graph, initialEstimate};
79 param.
verbosity = NonlinearOptimizerParams::SILENT;
106 if (
H) (*H) =
Vector1(1).transpose();
132 if (H1) (*H1) =
Vector1(2 *
x).transpose();
133 if (H2) (*H2) =
Vector1(-1).transpose();
152 X(0),
a, noiseModel::Isotropic::Precision(1, 2));
154 X(0),
Y(0), noiseModel::Isotropic::Precision(1, 2 *
b));
171 double m = (
a -
x) * (
a -
x);
172 double n =
b * (
y -
x *
x) * (
y -
x *
x);
181 double a = 1.0,
b = 100.0;
184 *std::static_pointer_cast<Rosenbrock1Factor>(
graph.
at(0));
186 *std::static_pointer_cast<Rosenbrock2Factor>(
graph.
at(1));
193 std::mt19937
rng(42);
194 std::uniform_real_distribution<double> dist(0.0, 100.0);
195 for (
size_t i = 0;
i < 50; ++
i) {
196 double x = dist(
rng);
197 double y = dist(
rng);
219 param.
verbosity = NonlinearOptimizerParams::SILENT;
221 double x = 3.0,
y = 5.0;
223 initialEstimate.
insert<
double>(
X(0),
x);
224 initialEstimate.
insert<
double>(
Y(0),
y);
250 param.
verbosity = NonlinearOptimizerParams::SILENT;
const Symbol key1('v', 1)
static int runAllTests(TestResult &result)
double PolakRibiere(const Gradient ¤tGradient, const Gradient &prevGradient)
Polak-Ribiere formula for computing β, the direction of steepest descent.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Simple non-linear optimizer that solves using non-preconditioned CG.
Vector evaluateError(const double &x, OptionalMatrixType H) const override
evaluate error
Factor for the second term of the Rosenbrock function. f2 = (y - x*x)
std::shared_ptr< This > shared_ptr
shared_ptr to this class
#define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance)
Check the Jacobians produced by a factor against finite differences.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const double d[K][N]
#define EXPECT(condition)
NoiseModelFactorN< double, double > Base
GaussianFactorGraphValuePair Y
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Pose2 priorMean(0.0, 0.0, 0.0)
double f2(const Vector2 &x)
Verbosity verbosity
The printing verbosity during optimization (default SILENT)
std::shared_ptr< GaussianFactorGraph > linearize(const Values &linearizationPoint) const
Linearize a nonlinear factor graph.
static NonlinearFactorGraph GetRosenbrockGraph(double a=1.0, double b=100.0)
Get a nonlinear factor graph representing the Rosenbrock Banana function.
double f(const NonlinearFactorGraph &graph, double x, double y)
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
const sharedFactor at(size_t i) const
double error(const Values &values) const
Eigen::Matrix< double, 1, 1 > Vector1
TEST(NonlinearConjugateGradientOptimizer, Optimize)
const Symbol key2('v', 2)
double DaiYuan(const Gradient ¤tGradient, const Gradient &prevGradient, const Gradient &direction)
The Dai-Yuan formula for computing β, the direction of steepest descent.
noiseModel::Diagonal::shared_ptr SharedDiagonal
Rosenbrock2Factor(Key key1, Key key2, const SharedNoiseModel &model=nullptr)
NoiseModelFactorN< double > Base
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
Evaluate derivatives of a nonlinear factor numerically.
double rosenbrock_func(double x, double y, double a=1.0, double b=100.0)
True Rosenbrock Banana function.
void insert(Key j, const Vector &value)
noiseModel::Base::shared_ptr SharedNoiseModel
Rosenbrock1Factor(Key key, double a, const SharedNoiseModel &model=nullptr)
noiseModel::Diagonal::shared_ptr model
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
const gtsam::Symbol key('X', 0)
const Values & optimize() override
Factor Graph consisting of non-linear factors.
void insert(Key j, const Value &val)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
double FletcherReeves(const Gradient ¤tGradient, const Gradient &prevGradient)
Fletcher-Reeves formula for computing β, the direction of steepest descent.
size_t maxIterations
The maximum iterations to stop iterating (default 100)
Matrix * OptionalMatrixType
NonlinearFactorGraph graph
double HestenesStiefel(const Gradient ¤tGradient, const Gradient &prevGradient, const Gradient &direction)
std::uint64_t Key
Integer nonlinear key type.
std::tuple< NonlinearFactorGraph, Values > generateProblem()
Vector evaluateError(const double &x, const double &y, OptionalMatrixType H1, OptionalMatrixType H2) const override
evaluate error
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
A non-templated config holding any types of Manifold-group elements.
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:16:49