title: scipy.optimize.minimize with general array indexing
body: <p>I want to solve an optimization problem with the method 'COBYLA' in scipy.optimize.minimize as follows:</p>
  
  <pre><code>test = spopt.minimize(testobj, x_init, method='COBYLA', constraints=cons1)
  y = test.x
  print 'solution x =', y
  </code></pre>
  
  <p>However, since the program is quite large, a scalable way to write the objective function (and the constraints) is to use a general index for the arguments. For example, if I could use <code>x['parameter1']</code> or <code>x.param1</code> instead of <code>x[0]</code>, then the program would be easier to read and debug. I tried both writing <code>x</code> as an object or a <code>pandas Series</code> with general indexing like <code>x['parameter1']</code>, as follows:</p>
  
  <pre><code>def testobj(x):
      return x['a']**2 + x['b'] + 1
  
  def testcon1(x):
      return x['a']
  
  def testcon2(x):
      return x['b']
  
  def testcon3(x):
      return 1 - x['a'] - x['b']
  
  
  x_init = pd.Series([0.1, 0.1])
  x_init.index = ['a','b']
  
  cons1 = ({'type': 'ineq', 'fun': testcon1}, \
      {'type': 'ineq', 'fun': testcon2}, \
      {'type': 'ineq', 'fun': testcon3})
  </code></pre>
  
  <p>but whenever I pass that into the <code>minimize</code> routine, it throws an error:</p>
  
  <pre><code>return x['a']**2 + x['b'] + 1
  ValueError: field named a not found
  </code></pre>
  
  <p>It works perfectly if I use the normal numpy array. Perhaps I'm not doing it right, but is that a limitation of the minimize function that I have to use numpy array and not any other data structure? The scipy documentation on <a href="http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.optimize.minimize.html" rel="nofollow">this topic</a> mentions that the initial guess has to be ndarray, but I'm curious how is the routine calling the arguments, because for <code>pandas Series</code> calling the variable with <code>x[0]</code> or <code>x['a']</code> are equivalent.</p>