I don't really understand why the code would be spending a significant amount of time in "isinf", but if it is then probably you want to inline it by moving the definition to nlopt-util.h (as "static inline nlopt_ininf(...) { ... }" or a macro).

On Jul 2, 2012, at 6:21 PM, Benoit Scherrer wrote:

Sorry that should work:


#ifdef _MSC_VER
#include <direct.h>
#endif


int nlopt_isinf(double x) {
#ifdef HAVE_ISINF
          return isinf(x);
#elif defined(_MSC_VER)
        return _finite(x)==0;
#else
    return fabs(x) >= HUGE_VAL * 0.99 ;
#endif
}

On Mon, Jul 2, 2012 at 6:03 PM, Benoit Scherrer <[email protected] > wrote:
Hi,

I'm using nlopt in a project, using the BOBYQA optimization.

I did a runtime profiling of my code with Visual Studio (so under Windows) and surprisingly one of the bottlenecks (after my objective function) was nlopt_isinf
(see screenshots)

A fix might be :

#ifdef MSVC
#include <direct.h>
#endif

int nlopt_isinf(double x) {
#ifdef HAVE_ISINF
          return isinf(x);
#elif MSVC
        return _finite(x)==0;
#else
    return fabs(x) >= HUGE_VAL * 0.99 ;
#endif
}


I Don't know if _finite exists for all WIN32 or only MSVC

B


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

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

Reply via email to