43 #include <ilqgames/cost/extreme_value_cost.h> 44 #include <ilqgames/utils/types.h> 46 #include <glog/logging.h> 51 float ExtremeValueCost::Evaluate(Time t,
const VectorXf& input)
const {
53 ExtremeCost(t, input, &evaluated);
58 void ExtremeValueCost::Quadraticize(Time t,
const VectorXf& input,
59 MatrixXf* hess, VectorXf* grad)
const {
60 const Cost* extreme_cost = ExtremeCost(t, input);
63 extreme_cost->Quadraticize(t, input, hess, grad);
66 const Cost* ExtremeValueCost::ExtremeCost(Time t,
const VectorXf& input,
67 float* evaluated)
const {
68 const Cost* extreme_cost;
69 float extreme_value = (is_min_) ? std::numeric_limits<float>::infinity()
70 : -std::numeric_limits<float>::infinity();
72 for (
const auto& cost : costs_) {
73 const float value = cost->Evaluate(t, input);
74 if (!(!(is_min_ && value < extreme_value) &&
75 !(!is_min_ && value > extreme_value))) {
76 extreme_value = value;
77 extreme_cost = cost.get();
78 if (evaluated) *evaluated = value;
82 CHECK_NOTNULL(extreme_cost);