nlopt_wrapper.cpp
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <iostream>
00003 #include <sstream>
00004 #include <stdlib.h>
00005 #include <vector>
00006 #include <nlopt.h>
00007 
00008 #include "nlopt_solver.h"
00009 //#include "eus_function.cpp"
00010 
00011 int result = 0;
00012 NLoptSolver* nos_buf;
00013 
00014 extern "C"{
00015 int get_result(){ return result+5 ; }
00016 }
00017 
00018 extern "C"{
00019 int stop(){
00020         if ( nos_buf ) nos_buf->stop() ;
00021         return 0 ;
00022 }
00023 }
00024 
00025 extern "C"{
00026 double* optimize(double* x,
00027                 const double* x_min,
00028                 const double* x_max,
00029                 int (*f)(double*,double*), int (*df)(double*,double*),
00030                 int (*g)(double*,double*), int (*dg)(double*,double*),
00031                 int (*h)(double*,double*), int (*dh)(double*,double*),
00032                 int m_x, int m_g, int m_h,
00033                 double ftol, double xtol, double eqthre, int max_eval, double max_time,
00034                 int log,
00035                 Optimization::NLopt::Algorithm algorithm,
00036                 double* fbuf, double* dfbuf, double* gbuf, double* dgbuf, double* hbuf, double* dhbuf) {
00037   // if ( ! nos_buf ) {
00038         NLoptSolver nos(x, x_min, x_max, f, df, g, dg, h, dh, m_x, m_g, m_h, ftol,xtol,eqthre,max_eval,max_time,
00039                         (Optimization::NLopt::Algorithm) algorithm);
00040         nos_buf = &nos ;
00041         free(nos.fbuf); free(nos.dfbuf); free(nos.gbuf);
00042         free(nos.dgbuf); free(nos.hbuf); free(nos.dhbuf);
00043         nos.fbuf = fbuf ; nos.dfbuf = dfbuf ;
00044         nos.gbuf = gbuf ; nos.dgbuf = dgbuf ;
00045         nos.hbuf = hbuf ; nos.dhbuf = dhbuf ;
00046         result = nos.Optimize();
00047         if ( log ) nos.output_result(result) ;
00048         nos_buf = 0 ;
00049         return x;
00050 }
00051 }


eus_nlopt
Author(s):
autogenerated on Fri Apr 19 2019 03:45:18