Search code examples
drake

Check if initial guess is feasible


How do we verify that an initial guess is feasible?

There should be some API call prog.CheckInitialGuess feasible or something like that, so we don't need to add a lot of extra code to do this.


Solution

  • We do have a function CheckSatisfiedAtInitialGuess You could call it through

    prog.CheckSatisfiedAtInitialGuess(prog.GetAllConstraints());
    

    to check whether all constraints are satisfied.

    If you want to return the infeasible constraints, you can try

    std::vector<Binding<Constraint>> failed_constraints;
    for (const auto& constraint : prog.GetAllConstraints()) {
      if (!prog.CheckSatisfied(constraint, prog.initial_guess())) {
        failed_constraints.push_back(constraint);
      }
    }