44 #include <ilqgames/cost/nominal_path_length_cost.h> 45 #include <ilqgames/utils/types.h> 47 #include <glog/logging.h> 51 float NominalPathLengthCost::Evaluate(Time t,
const VectorXf& input)
const {
52 CHECK_LT(dimension_, input.size());
54 const float delta = input(dimension_) - t * nominal_speed_;
56 return 0.5 * weight_ * delta * delta;
59 void NominalPathLengthCost::Quadraticize(Time t,
const VectorXf& input,
60 MatrixXf* hess, VectorXf* grad)
const {
61 CHECK_LT(dimension_, input.size());
66 CHECK_EQ(input.size(), hess->rows());
67 CHECK_EQ(input.size(), hess->cols());
68 CHECK_EQ(input.size(), grad->size());
71 const float delta = input(dimension_) - t * nominal_speed_;
73 const float dx = weight_ * delta;
74 const float ddx = weight_;
76 (*grad)(dimension_) += dx;
77 (*hess)(dimension_, dimension_) += ddx;