title: Passing constants and variables into Scipy.minimize.optimize constraints and boundaries
body: <p>I found how one can pass <code>*args</code> into the main function of <code>scipy.minimize.optimize</code>, see <a href="https://stackoverflow.com/q/25206482/8069403">this question</a>.</p>
  
  <p>But how do I pass constants and variables into constraints and boundaries?</p>
  
  <p><code>P</code> is a variable vector, <code>P0</code> is the initial solution vector, <code>f(P)</code> is the function to minimize, the rest are constant data. Will it work like this?</p>
  
  <pre><code>def constraint_1(P, args):
      M_goal, other_args = args
      M = calc_M_from_P(P, args)  # calculate M from P
      return M-M_goal
  
  # boundary is simply (P0[i]-500, P0[i]+500)
  def get_boundaries(P0): 
      list_bnds = []
      for i in range(len(P0)):
          list_bnds.append((P0[i]-500.0, P0[i]+500.0))
      return tuple(list_bnds)
  
  func = objective(P0, args)
  bnds = get_boundaries(P0)
  con1 = {'type': 'ineq', 'fun': constraint_1}
  
  sol = minimize(func, P0, args = args, method='SLSQP', bound=bnds, constraints = con1)
  </code></pre>