InequalityPenaltyFunction.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 
21 namespace gtsam {
22 
23 /* ************************************************************************* */
25  const {
26  return [this](const double& x, OptionalJacobian<1, 1> H = {}) {
27  return this->operator()(x, H);
28  };
29 }
30 
31 /* ************************************************************************* */
33  if (x < 0) {
34  if (H) {
35  H->setConstant(0);
36  }
37  return 0;
38  } else {
39  if (H) {
40  H->setConstant(1);
41  }
42  return x;
43  }
44 }
45 
46 /* ************************************************************************* */
47 double SmoothRampPoly2::operator()(const double& x,
48  OptionalJacobian<1, 1> H) const {
49  if (x <= 0) {
50  if (H) {
51  H->setZero();
52  }
53  return 0;
54  } else if (x < epsilon_) {
55  if (H) {
56  H->setConstant(2 * a_ * x);
57  }
58  return a_ * pow(x, 2);
59  } else {
60  if (H) {
61  H->setOnes();
62  }
63  return x - epsilon_ / 2;
64  }
65 }
66 
67 /* ************************************************************************* */
68 double SmoothRampPoly3::operator()(const double& x,
69  OptionalJacobian<1, 1> H) const {
70  if (x <= 0) {
71  if (H) {
72  H->setZero();
73  }
74  return 0;
75  } else if (x < epsilon_) {
76  if (H) {
77  H->setConstant(3 * a_ * pow(x, 2) + 2 * b_ * x);
78  }
79  return a_ * pow(x, 3) + b_ * pow(x, 2);
80  } else {
81  if (H) {
82  H->setOnes();
83  }
84  return x;
85  }
86 }
87 
88 /* ************************************************************************* */
89 double SoftPlusFunction::operator()(const double& x,
90  OptionalJacobian<1, 1> H) const {
91  if (H) {
92  H->setConstant(1 / (1 + std::exp(-k_ * x)));
93  }
94  return std::log(1 + std::exp(k_ * x)) / k_;
95 }
96 
97 } // namespace gtsam
H
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
Definition: gnuplot_common_settings.hh:74
gtsam::InequalityPenaltyFunction::function
virtual UnaryScalarFunc function() const
Definition: InequalityPenaltyFunction.cpp:24
gtsam::SmoothRampPoly3::a_
double a_
Definition: InequalityPenaltyFunction.h:112
gtsam::SmoothRampPoly3::operator()
virtual double operator()(const double &x, OptionalJacobian< 1, 1 > H={}) const override
Definition: InequalityPenaltyFunction.cpp:68
x
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
Definition: gnuplot_common_settings.hh:12
gtsam::SoftPlusFunction::operator()
virtual double operator()(const double &x, OptionalJacobian< 1, 1 > H={}) const override
Definition: InequalityPenaltyFunction.cpp:89
gtsam::SmoothRampPoly2::a_
double a_
Definition: InequalityPenaltyFunction.h:83
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
gtsam::SmoothRampPoly2::epsilon_
double epsilon_
Definition: InequalityPenaltyFunction.h:82
exp
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
Definition: ArrayCwiseUnaryOps.h:97
gtsam::SoftPlusFunction::k_
double k_
Definition: InequalityPenaltyFunction.h:137
gtsam::SmoothRampPoly3::epsilon_
double epsilon_
Definition: InequalityPenaltyFunction.h:111
ceres::pow
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
gtsam::InequalityPenaltyFunction::UnaryScalarFunc
std::function< double(const double &x, OptionalJacobian< 1, 1 > H)> UnaryScalarFunc
Definition: InequalityPenaltyFunction.h:31
gtsam::SmoothRampPoly2::operator()
virtual double operator()(const double &x, OptionalJacobian< 1, 1 > H={}) const override
Definition: InequalityPenaltyFunction.cpp:47
gtsam
traits
Definition: SFMdata.h:40
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
gtsam::RampFunction::Ramp
static double Ramp(const double x, OptionalJacobian< 1, 1 > H={})
Definition: InequalityPenaltyFunction.cpp:32
gtsam::SmoothRampPoly3::b_
double b_
Definition: InequalityPenaltyFunction.h:113
gtsam::InequalityPenaltyFunction::operator()
virtual double operator()(const double &x, OptionalJacobian< 1, 1 > H={}) const =0
InequalityPenaltyFunction.h
Ramp function to compute inequality constraint violations.


gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:01:50