Topic: ERROR with *args in openopt

I seem to have some problem running my old programs with the new version of openopt. When I run my program with openopt v0.28, I encounter this error

  File "./identiPy.py", line 148, in <module>                                                                                             
    res = prob.solve(solverString)                                                                                                         
  File "/usr/lib/python2.6/site-packages/openopt/kernel/baseProblem.py", line 219, in solve                                               
    return runProbSolver(self, *args, **kwargs)                                                                                           
  File "/usr/lib/python2.6/site-packages/openopt/kernel/runProbSolver.py", line 114, in runProbSolver                                     
    p.__prepare__()                                                                                                                       
  File "/usr/lib/python2.6/site-packages/openopt/kernel/baseProblem.py", line 628, in __prepare__                                         
    setNonLinFuncsNumber(self,  s)                                                                                                         
  File "/usr/lib/python2.6/site-packages/openopt/kernel/ooMisc.py", line 160, in setNonLinFuncsNumber                                     
    setattr(p, 'n'+userFunctionType, asfarray(FV(*(X, ) + args)).size)                                                                     
TypeError: leastSquareFunc() takes at least 2 arguments (1 given)                                                                         



The program runs fine with an older version (0.24) of openopt. The problem is that openopt does not recognize the extra arguments being passed to the function (*args) and these are not being passed to the objective funuction.

I ran a simple rosenbrock function optimization by passing fictitious arguments to the objective function just to check this - I run into identical problems (works fine with v0.24 though)



  File "openOptInterface.py", line 11, in <module>
    res = prob.solve('scipy_powell')
  File "/usr/lib/python2.6/site-packages/openopt/kernel/baseProblem.py", line 219, in solve
    return runProbSolver(self, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/openopt/kernel/runProbSolver.py", line 114, in runProbSolver
    p.__prepare__()
  File "/usr/lib/python2.6/site-packages/openopt/kernel/baseProblem.py", line 628, in __prepare__
    setNonLinFuncsNumber(self,  s)
  File "/usr/lib/python2.6/site-packages/openopt/kernel/ooMisc.py", line 160, in setNonLinFuncsNumber
    setattr(p, 'n'+userFunctionType, asfarray(FV(*(X, ) + args)).size)
TypeError: rosenbrock() takes exactly 2 arguments (1 given)




Please HELP!!

Arun

Last edited by arunpksh (2010-03-29 20:47:49)

Re: ERROR with *args in openopt

Give me example of code (without of any external libraries) to deal with.

Re: ERROR with *args in openopt

Thanks for the timely reply. Here is a sample code that produces the error (rosenbrock function example).

Re: ERROR with *args in openopt

well, I have committed bugfix for it.

Re: ERROR with *args in openopt

thanks a lot - my program works fine now.

Arun