Search code examples
drake

Easy way to access individual cost terms?


Let say we call prog.AddCost(...) multiple times and have a triple term cost:

cost(x) = a(x) + b(x) + c(x)

How do we easily access an individual cost?


Solution

  • Each call to AddCost returns a binding, which can be evaluated directly, for instance via EvalBinding in MathematicalProgramResult.