[SciPy-User] optimization routines can not handle infinity values

Enrico Avventi eavventi@yahoo...
Mon Sep 20 09:20:24 CDT 2010


so, updating the situation a bit...

i wrote a new scalar search method that allows functions that tends to
infinity.
it works quite well on toy examples like

phi(x) = - d*x - log(1-x)

or

phi(x) = -d*x + (1-x)^-k

i changed the line searh method and fmin_bfgs to detect when a function is
not defined
everywhere and call the appropriate line search method.

i also added test cases (consisting of the obove functions with d=100 and
random k
between 1 and 5) for checking if the new scalar search  returns valid points
- i.e satisfying
wolfe conditions. all tests old and new seems topass.

the last thing i want to check before submitting the patch is if this works
in my problem
as it is a real-world and high dimensional. so the perfect test case.
unfortunately i couldn't
try it out.

the problem i stumbled with is that i rely on some fortran code wrapped with
f2py.
i recompiled it after installing the development version of numpy and scipy
but nonetheless
this is what i get:

In [1]: run graph_test.py
[[ 1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.]
 [ 0.  1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.]
 [ 1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.  0.]
 [ 0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.]
 [ 1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.]
 [ 0.  1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.]
 [ 1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.  0.]
 [ 0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.]
 [ 1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.]
 [ 0.  1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.]
 [ 1.  1.  1.  0.  1.  1.  1.  0.  1.  1.  1.  0.]
 [ 0.  1.  0.  1.  0.  1.  0.  1.  0.  1.  0.  1.]]
check: 4.68754204281 34.9603190301
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)


RuntimeError: module compiled against ABI version 1000009 but this version
of numpy is 2000000
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

/home/avventi/my_code/python_code/xspectral/graph_test.py in <module>()
     33 print "check:", min(np.linalg.eig(L+dL)[0].real),
max(np.linalg.eig(L+dL)[0].real)
     34
---> 35 Sigma = compute_moment(fL,A,B,F,G,H,D)
     36 print "R_0="
     37 print Sigma[0:m,0:m]

/home/avventi/my_code/python_code/xspectral/armalib.pyc in
compute_moment(Lambda, A, B, F, G, H, D)
    359     from numpy import zeros, zeros_like, dot, concatenate, shape,
bmat, kron,
eye

    360     from numpy.linalg import
inv

--> 361     from slycot import
sb03md

    362     n1 =
A.shape[0]

    363     n2 =
F.shape[0]



/usr/lib/python2.6/site-packages/slycot/__init__.pyc in
<module>()


2

      3 # Analysis routines (5/40
wrapped)



----> 4 from analysis import
ab01nd,ab05md,ab05nd,ab07nd,ab08nd


5

      6 # Data analysis routines (0/7
wrapped)





/usr/lib/python2.6/site-packages/slycot/analysis.py in
<module>()

     20 #       MA 02110-1301,
USA.




21

---> 22 from slycot import
_wrapper


23

     24 def ab01nd(n,m,A,B,jobz='N',tol=0,ldwork=None):

ImportError: numpy.core.multiarray failed to import
WARNING: Failure executing file: <graph_test.py>

what did i miss?

On Thu, Sep 16, 2010 at 9:57 AM, Enrico Avventi <eavventi@yahoo.it> wrote:

> sure, no problem. the objective function is
>
> f(\Lambda) = trace(\Sigma \Lambda) -  \int_\Pi \log [G(z) \Lambda
> G(z^-1)']  z^-1 dz
>
> where \Sigma and \Lambda are hermitian matrices, G(z) is complex matrix
> valued and analytic inside the unit disc and the integration is along the
> unit circle. the function is only defined when G(z) \Lambda G(z^-1)' is
> positive definite in the unit circle and tends to infinity when approaching
> a value of \Lambda that makes it losing rank.
> in some special cases you can then substitute w.l.o.g \lambda with some
> linear M(x) where x is a real vector in order to obtain a problem of the
> form that i was talking about.
>
> On Wed, Sep 15, 2010 at 10:16 PM, Sebastian Walter <
> sebastian.walter@gmail.com> wrote:
>
>> well, good luck then.
>>
>> I'm still curious what the objective and constraint functions of your
>> original problem are.
>> Would  it be possible to post it here?
>>
>>
>> On Wed, Sep 15, 2010 at 10:05 PM, Enrico Avventi <eavventi@yahoo.it>wrote:
>>
>>> i'm aware of SDP solvers but they handle only linear objective functions
>>> AFAIK.
>>> and the costraints are not the problem. it is just that the function is
>>> not defined everywhere.
>>> i will experiment by changing the line search methods as i think they are
>>> the only
>>> part of the methods that needs to be aware of the domain.
>>>
>>> thanx for the help, i will post my eventual findings.
>>>
>>> On Wed, Sep 15, 2010 at 6:48 PM, Jason Rennie <jrennie@gmail.com> wrote:
>>>
>>>> On Tue, Sep 14, 2010 at 9:55 AM, enrico avventi <eavventi@yahoo.it>wrote:
>>>>
>>>>>  Some of the routines (fmin_cg comes to mind) wants to check the
>>>>> gradient at points where the objective function is infinite. Clearly in such
>>>>> cases the gradient is not defined - i.e the calculations fail - and the
>>>>> algorithm terminates.
>>>>
>>>>
>>>> IIUC, CG requires that the function is smooth, so you can't use CG for
>>>> your problem.  I.e. there's nothing wrong with fmin_cg.  You really need a
>>>> semidefinite programming solver, such as yalmip or sedumi.  My experience
>>>> from ~5 years ago is that SDP solvers only work on relatively small problems
>>>> (1000s of variables).
>>>>
>>>> http://en.wikipedia.org/wiki/Semidefinite_programming
>>>>
>>>> Jason
>>>>
>>>> --
>>>> Jason Rennie
>>>> Research Scientist, ITA Software
>>>> 617-714-2645
>>>> http://www.itasoftware.com/
>>>>
>>>>
>>>> _______________________________________________
>>>> SciPy-User mailing list
>>>> SciPy-User@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>>
>>>>
>>>
>>> _______________________________________________
>>> SciPy-User mailing list
>>> SciPy-User@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>
>>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100920/14c1075c/attachment-0001.html 


More information about the SciPy-User mailing list