title: Variable number of parameters for scipy optimize with L-BFGS-B algorithm
body: <p>I am looking for the correct approach to use a variable number of parameters as input for the optimizer in scipy.</p>
  
  <p>I have a set of input parameters p1,...,pn and I calculate a quality criteria with a function func(p1,...,pn). I want to minimize this value.</p>
  
  <p>The input parameters are either 0 or 1 indicating they should be used or not. I cannot simply delete all unused ones from the parameter list, since my function for the quality criteria requires them to be "0" to remove unused terms from equations.</p>
  
  <pre><code>def func(parameters):
      ...calculate one scalar as quality criteria...
  
  solution = optimize.fmin_l_bfgs_b(func,parameters,approx_grad=1,bounds=((0.0, 5.0),...,(0.0,5.0)) # This will vary all parameters
  </code></pre>
  
  <p>Within my code the optimizer runs without errors, but of course all given parameters are changed to achieve the best solution.</p>
  
  <p>Is there a way to have e.g. 10 input parameters for func, but only 5 of them are used in the optimizer?</p>
  
  <p>So far I can only think of changing my func definition in a way that I will not need the "0" input from unused parameters. I would appreciate any ideas how to avoid that.</p>
  
  <p>Thanks a lot for the help!</p>