title: Build scipy objective function dynamically
body: <p>What I am trying to accomplish:
  Trying to use the scipy optimize minimize feature and build the lambda objective function dynamically. </p>
  
  <p>So I want 1 function to build and return a lambda and I want it to take in arguments.  So for example I want to build:</p>
  
  <pre><code>def build_lambdas([params]):
     for param in params:
       lambda.var = param.var
       lambda.coeff = param.coeff
  </code></pre>
  
  <p>y = 4 + 3y
  or 
  y = 2x + 5y + 4z 
  or 
  y = 5x + 3z + 2r + 0.5p</p>
  
  <p>depending on whatever I pass in.</p>
  
  <p>What's the best way to accomplish this?  I've seen a number of examples for trying to dynamically update the values of x within a lambda, but what I'm after is doing this with the variable and the coefficient to be optimized.  </p>
  
  <p>So I'm looking for ideas, tips, examples.</p>
  
  <p>Thanks in advance!</p>