Free Python optimization framework

Thursday, June 12, 2008

Connecting IPOPT, Part 3

I have wrote automatic generation of ipopt.opt file. That one is read from current directory; to omit creating of the one (and hence all-defaults or using ipopt.opt file from current directory) use
r = p.solve('ipopt', optFile = False)
(default value for optFile is "auto", also, I intend to provide possibility for loading the file from given location, like
optFile = "\\home\\dmitrey\\myipoptsettings.opt"
).

Currently it consists of 3 lines:
print_level -2 (to suppress annoying huge text output)
tol (p.ftol is put here)
constr_viol_tol (p.contol is put here)


I found it too long and complicated to implement all those parameters with their default values (and hence duplicate ipopt code) that are can be changed by IPOPT developers from time to time (and it's hard to monitor), so to add other fields from ipopt.opt file specification you should use "options" as string (comma and semicolon delimiters can be used here, and space or "=" can be delimiters for option name and value), not as Python *args or **kwargs.

Example:

r = p.solve('ipopt', options = 'dual_inf_tol=1.005; compl_inf_tol 1.005e-4, alpha_for_y dual-and-full')

Let me also remember you that running ipopt from OO requires pyipopt installation, and currently pyipopt is Linux-only. Also, some days ago pyipopt bug related to fail on problems w/o non-linear constraints has been fixed.

Saturday, June 7, 2008

numpy-related bug

If you have encountered problems (during using OO) like the one:
[...]
  File "/usr/lib/python2.5/site-packages/scipy/sparse/base.py", line
139, in spmatrix
@deprecate
TypeError: deprecate() takes exactly 3 arguments (1 given)
then numpy update is recommended (and using OO from latest tarball or svn), as it is mentioned here.

Friday, June 6, 2008

Unified text output

I have turned NLP/NSP/GLP solvers to show unified text output. That one can be edited by user (I'll publish detailed description in OO Doc page ASAP).

Now it's like this for constrained problems:

iter objFunVal log10(maxResidual)
0 6.115e+01 2.13
10 2.360e+01 0.72
20 1.754e+01 0.38
..........
1290 2.015e+01 -6.23

and like this for unconstrained (or those problem-solver pairs which always have feasible iter points, for example some box-bounded problems and solvers):

iter objFunVal
0 -2.825e+06
10 -7.106e+05
...
1570 -4.787e-03

Maximization problems

I have committed some changes, they allows handling of maximization problems

objFunc -> max
(subjected to some constraints)

via p.goal = 'max'
(or 'maximum')

Currently LP, MILP, QP classes have no the possibility, it's only valid for NLP, NSP, GLP

of course, the parameter goal could be used in prob assignment or solve function as well:
p = NLP(..., goal='max')
or
r = p.solve(solverName, ... (other parameters), goal='max')
here's graphical output from modified nlp3.py (using -f instead of f, already in subversion).

Tuesday, June 3, 2008

Connecting IPOPT, Part 2

I intend to have OpenOpt<->IPOPT bridge (via Eric's pyipopt) till next OO release.

However, currently it works for Linux only (and I'm certainly not the one who could try to make it cross-platform) and requires hand-turn of makefile, first of all related to paths (python and numpy directories); also, probably you'll have to add -llapack (provided lapack-dev installation, if you have message "undefined symbol @dswap_") and -lgfortran (if you have "/usr/lib/libipopt.so.0: undefined symbol: _gfortran_concat_string", mb it requires gfortran installation, if you haven't the one installed). For more details see comments here (somehow they are not mentioned in Eric's README file).

So after the issues I have IPOPT working for me. Here's picture below. This one referrs to nlp_bench2.py (from /examples) with modified h3: instead of
(x[-5]+x[-6]-2*M+1.5)**6=0
I have taken
(x[-5]+x[-6]-2*M+1.5)**2=0
(because, as I have noticed, IPOPT handles the constraint so badly that I thought I have bug(s) in IPOPT connection, and hunting for those ones took a long time for me, because that constraint is present in my other NLP tests involved). And (despite IPOPT work probably can be somehow enhances via ipopt.opt file options modification) this is another one proof that having several solvers (like OO provides) is always better than having a single one, even so famous as IPOPT, isn't it?

Sunday, May 18, 2008

major changes for non-linear constraints

After some code cleanup (still there is some more to be done) I have committed some changes for non-linear constraints handling. If your constraints are split, for example
p.c = [c1, c2, c3],
or
p.h = [h1, h2]

some solvers can take benefits (ralg for c and h, ALGENCAN for c; others available for now in OO cannot).

They will take less evaluations for these non-linear constraints.

Thursday, May 8, 2008

blas and lapack issues with CVXOPT installation

As I have made conclusion from my own experience with CVXOPT installation (from source, i.e. tarball), as well as from some user comments, CVXOPT sometimes cannot find lapack and blas, despite they are present.

I noticed that it searches for llapack and lblas, and despite I have libblas.so.3 and liblapack.so.3 (installed in my KUBUNTU 8.04, to /usr/lib, via aptitude) it doesn't work. So I had copied libblas.so.3 and liblapack.so.3 into files libblas.so and liblapack.so (same directory /usr/lib) and now all works ok (mb creating soft links would be enough?).

I hope CVXOPT developers will take it into account, mb this problem happens with some other OSes as well.

P.S. If you intend to use OO<->CVXOPT<->glpk connection don't forget to set BUILD_GLPK=1 in CVXOPT setup.py file. glpk should be already installed.