Free Python optimization framework

Sunday, February 3, 2008

bugfix for some scipy NLP solvers (unconstrained)

Another one bugfix have been committed (appered due to some recent svn changes for scipy_cg, scipy_ncg, scipy_powell, scipy_bfgs, scipy_fminbound).
Thanks to Nils Wagner for reporting the issue.
That one was due to definition of exception "isSolved" migrated from BaseProblem.py to ooMisc.py

[Linux] ALGENCAN bug, maybe due to latest glibc

Some days ago I have accepted a proposition for glibc recent version installation from Ubuntu software updates channel, and I guess it's the matter for the bug (while starting ALGENCAN):
StdErr: *** glibc detected *** /usr/bin/python: free(): invalid pointer:
0x00000000008362f0 ***

bugfix for "incorrect func index type" (some OS/Arch)

Some users informed me that some OS/Arch raises the error "incorrect func index type".
As far as we understand for now, it's due to strange nmpy.argmax() return type (numpy.int32 with type id 1810419808, that differs from 1810419616). For more info see discuss in scipy-dev mail lists: url1, url2 .
So some changes committed (also available from OO install page -> openopt.tar.gz) allows to avoid the bug.

Saturday, February 2, 2008

how to change solver default parameters

A new OO doc page entry has been committed:
how to change solver default parameters (via kwargs for p.solve()).

AFAIK it's especially important for global solvers, like GA-based "galileo". However, currently only 3 parameters are available for the solver modification:
population (default 15)
crossoverRate (default 1.0, it means always do crossover)
mutationRate (default 0.05, it means "not very often")
There are some more parameters available for modification, but I lack free time and experience in global optimization.

Old way p.solverParameters.(solvername) = {...} has been removed.

Friday, February 1, 2008

solver settings as kwargs for p.solve()

An openopt user asked: could he modify GLP solver galileo parameters.
Currently it's possible to access some ralg parameters, via for example
p=NSP(...)
p.solverParameters.ralg={'h0':0.1, 'alp':3} #I suspect it's too long to type, isn't it?

(h0 is initial step length approximation, default 1, alp is space dilation parameter, default 2 (fixed for Python implementation, more advanced handling with non-fixed value in fortran version))

For modifying other solvers parameters some minor changes should be done.
Also, I had already decided how to use kwargs (and maybe some args in future, I didn't decided yet which ones) in solve(). I think it will be something like
r = p.solve('galileo', crossoverRate=0.80, mutationRate=0.15)
So, if a kwargs parameter is in dir(solverName.solverName) (i.e. is a solver parameter, like in the ralg case above:
>>>import scikits.openopt, ralg
>>>dir(ralg.ralg)
['__alg__', '__authors__', '__constraintsThatCannotBeHandled__', '__decodeIterFcnArgs__', '__doc__', '__economyMult__', '__expectedArgs__', '__homepage__', '__info__', '__init__', '__isIterPointAlwaysFeasible__', '__iterfcnConnected__', '__license__', '__module__', '__name__', '__solver__', 'alp', 'getRalgDirection', 'getRalgDirection2', 'h0', 'hmult', 'nh', 'q1', 'q2']
), then it will change the value of the solver setting, elseware if it's in dir(p) (i.e. is prob parameter, like maxIter=15) then it will change the prob field value, elseware a error message will be raised.
I intend to implement the changes during this week.

Thursday, January 31, 2008

About prob structure redefinition

I have noticed 2 lines of code sent by an openopt user:

#unfortunately, as openopt is now, this needs to be defined again
#each time it is solved
It is followed by function for prob redefinition:
def setupF2dProblem(init_point, maxIterates):
...
return prob

Let me explain the situation once again. Maybe, you have already noticed the error messages when trying to use prob instance one more time: r=p.solve(...). This problem is due to Python issue 1515: deepcopy doesn't copy instance methods (url)
prob instance contains lots of function handlers, referring to each other, and while running p.solve(...) they seriously changes to other values, and some new fields (function handlers, flags True/False, some new values - Python lists, arrays etc) appear. It's impossible for me to remove all the changes done and successfully keep cleaning the prob instance of all that stuff after solving finish. It may cause inpredictable bugs, appearing once time-to-time, and hunting for this kind is very difficult.
So I decided to wait until Python developers will fix the bug. They informed me of the url for issue 1515 during Python bug day, when I have committed the bugreport (some weeks later pastebin.com will remove the code). So, they recommended me temporary solution - to add the line
d[types.MethodType] = _deepcopy_atomic
to copy.py file (like it's mentioned in the url provided), but modifying Python core sources is inappropriate solution for the case - I can't demand the one from each OO user (moreover, not all of them has write access to Python core files). I haven't tried it by myself as well, so I don't know does it helps or no.
So, it would be nice to increase the bug severity from "normal" (as it is assigned for now) to something bigger, maybe Python developers would increase their efforts to fix the one. Let me also attach in comment the bugreport, since it will disappear soon from pastebin.com.

Tuesday, January 29, 2008

New OO class: GLP (global problem)

New OO class have been created: GLP (global problem)
Currently single GLP solver is "galileo" (by Donald Goodman, alg: Genetic Algorithm; license: GPL)
I have included galileo code to OO. For now it can solve only continuous problems with finite box-bounds. I intend to add handling all-discrete problems as well (AFAIK this solver can't handle mixed discrete-continuous).

For GLP default p.plotOnlyCurrentMinimum = True, while for all other classes default value is False.
Currently stop criteria for GLP are maxIter, maxFunEvals, maxTime, maxCPUTime, fEnough. AFAIK xtol and ftol are inappropriate stop criteria for GLP class. I intend to add something like maxNonSuccess = 15 (number of iterations when better value haven't been obtained).
Here's graphical output for the example.