43 #ifndef ILQGAMES_CONSTRAINT_AFFINE_VECTOR_CONSTRAINT_H 44 #define ILQGAMES_CONSTRAINT_AFFINE_VECTOR_CONSTRAINT_H 46 #include <ilqgames/constraint/time_invariant_constraint.h> 47 #include <ilqgames/utils/types.h> 49 #include <glog/logging.h> 59 const std::string& name =
"")
63 ATA_(A.transpose() * A),
64 AAT_(A * A.transpose()) {
65 CHECK_EQ(A_.rows(), b_.size());
69 float Evaluate(
const VectorXf& input)
const {
70 CHECK_EQ(A_.rows(), input.size());
71 return (A_ * input - b_).norm();
76 void Quadraticize(Time t,
const VectorXf& input, MatrixXf* hess,
77 VectorXf* grad)
const {
80 CHECK_EQ(input.size(), b_.size());
81 CHECK_EQ(hess->rows(), input.size());
82 CHECK_EQ(hess->cols(), input.size());
83 CHECK_EQ(grad->size(), input.size());
86 const float lambda = Lambda(t);
87 const float mu = Mu(t, input);
90 const VectorXf delta = A_ * input - b_;
91 const float value = delta.norm();
94 const VectorXf AT_delta = A_.transpose() * delta;
95 (*grad) += (mu + lambda / value) * AT_delta;
96 (*hess) += (lambda / value) *
97 (AAT_ - AT_delta * AT_delta.transpose() / (value * value)) +