On Jul 23, 2012, at 3:00 AM, ben Thelen wrote:
> 
> I'd observed that upon failure (error raised) in the objective function the 
> optimizer would somehow register this (presumably the same as returning -inf 
> to a max.  objective) and continue to optimize.

I can't replicate this behavior, nor is it what is supposed to be happening.  
As documented in the NLopt manual, raising an exception in your objective (or 
constraint) function is equivalent to a forced stop: it halts the optimization 
and raises the exception to the code that called NLopt:

        
http://jdj.mit.edu/wiki/index.php/NLopt_Python_Reference#Forced_termination

For example, if I modify the Python example in the NLopt tutorial 
(http://jdj.mit.edu/wiki/index.php/NLopt_Tutorial#Example_in_Python) to raise 
an exception in the objective function:

def myfunc(x, grad):
    raise Exception('spam','eggs')
    if grad.size > 0:
        grad[0] = 0.0
        grad[1] = 0.5 / sqrt(x[1])
    return sqrt(x[1])

then it halts the optimization and raises this exception to the caller, as can 
be verified by wrapping the opt.optimize call in try: ... except.

Can you modify the tutorial code in a way that reproduces your problem?

Steven
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to