Bird
0
0

You want to solve a nonlinear optimization with constraints and also provide the Jacobian of the constraints for better performance. How do you specify the Jacobian in scipy.optimize.minimize?

hard📝 Application Q9 of 15
SciPy - Advanced Optimization
You want to solve a nonlinear optimization with constraints and also provide the Jacobian of the constraints for better performance. How do you specify the Jacobian in scipy.optimize.minimize?
APass a 'jac' parameter to minimize with a function returning the Hessian matrix.
BAdd a 'jac' key in each constraint dictionary with a function returning the gradient vector.
CInclude the Jacobian inside the objective function.
DSet 'jac' to True in the minimize call.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Jacobian usage in constraints

    Jacobian is the gradient of constraint functions and can be provided per constraint.
  2. Step 2: Identify correct way to specify Jacobian

    Each constraint dictionary can have a 'jac' key with a function returning gradient vector.
  3. Final Answer:

    Add a 'jac' key in each constraint dictionary with a function returning the gradient vector. -> Option B
  4. Quick Check:

    Jacobian per constraint via 'jac' key [OK]
Quick Trick: Jacobian for constraints goes inside each constraint dict [OK]
Common Mistakes:
  • Passing Hessian instead of Jacobian
  • Putting Jacobian in objective instead of constraints
  • Setting 'jac' to True instead of function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes