45 #ifndef ILQGAMES_CONSTRAINT_SINGLE_DIMENSION_CONSTRAINT_H 46 #define ILQGAMES_CONSTRAINT_SINGLE_DIMENSION_CONSTRAINT_H 48 #include <ilqgames/constraint/time_invariant_constraint.h> 49 #include <ilqgames/utils/types.h> 51 #include <glog/logging.h> 61 const std::string& name =
"")
64 threshold_(threshold),
65 keep_below_(keep_below) {}
68 float Evaluate(
const VectorXf& input)
const {
69 return (keep_below_) ? input(dim_) - threshold_ : threshold_ - input(dim_);
74 void Quadraticize(Time t,
const VectorXf& input, MatrixXf* hess,
75 VectorXf* grad)
const {
78 CHECK_EQ(hess->rows(), input.size());
79 CHECK_EQ(hess->cols(), input.size());
80 CHECK_EQ(grad->size(), input.size());
83 const float lambda = Lambda(t);
86 const float sign = (keep_below_) ? 1.0 : -1.0;
87 const float x = input(dim_);
88 const float g = sign * (x - threshold_);
92 ModifyDerivatives(t, g, &dx, &ddx);
95 (*hess)(dim_, dim_) += ddx;
100 const Dimension dim_;
101 const float threshold_;
102 const bool keep_below_;