nlopt

NLopt SLSQP discards good solution in favour of older, worse solution

只谈情不闲聊 提交于 2019-12-10 17:29:29
问题 I'm solving a standard optimisation problem from Finance - portfolio optimisation. The vast majority of the time, NLopt is returning a sensible solution. However, on rare occasions, the SLSQP algorithm appears to iterate to the correct solution, and then for no obvious reason it chooses to return a solution from about one third of the way through the iterative process that is very obviously suboptimal. Interestingly, changing the initial parameter vector by a very small amount can fix the

How to add a library in C++?

偶尔善良 提交于 2019-12-08 04:16:30
问题 Iam new to C++ and I am trying to add NLopt library to C++ using VS 2013. NLopt is a non-linear optimization library (http://ab-initio.mit.edu/wiki/index.php/NLopt_C-plus-plus_Reference#Compiling_and_linking_your_program_to_NLopt). NLopt has a DLL file and .h file and I cannot figure out a way to get them work. I appreciate if anyone can give me a quick guide on how to import this library. Thank you in advance. 回答1: Here's what you'd want to go through: DLLs in Visual C++ - http://msdn

Trouble installing nloptr package on R 3.3.0

老子叫甜甜 提交于 2019-12-05 13:42:46
I can't install the package nloptr 1.0.4 on R 3.3.0. The messages are the following: > install.packages("nloptr") Installing package into ‘/Users/fgomesbarros/Library/R/3.3/library (as ‘lib’ is unspecified) trying URL 'https://cran.revolutionanalytics.com/src/contrib/nloptr_1.0.4.tar.gz' Content type 'application/octet-stream' length 353942 bytes (345 KB) ================================================== downloaded 345 KB * installing *source* package ‘nloptr’ ... ** package ‘nloptr’ successfully unpacked and MD5 sums checked checking for g++... g++ checking whether the C++ compiler works...

Minimization with R nloptr package - multiple equality constraints

不羁的心 提交于 2019-12-05 08:41:30
Is it possible to specify more than one equality constraint in nloptr function in R? The code that I am trying to run is the following: eval_f <- function( x ) { return( list( "objective" = x[3]^2+x[4]^2, "gradient" = c( 0, 0, 2*x[3], 2*x[4] ) ) ) } # constraint functions # equalities eval_g_eq <- function( x ) { constr <- c( x[1] + x[2] + x[3] - 4, x[1]^2 + x[2]^2 + x[4] - 15 ) grad <- c( c(1, 1, 1, 0), c(2*x[1], 2*x[2], 0, 1) ) return( list( "constraints"=constr, "jacobian"=grad ) ) } # initial values x0 <- c( 1, 5, 5, 1 ) local_opts <- list( "algorithm" = "NLOPT_LD_MMA", "xtol_rel" = 1.0e-7

Pointer to function to member function

≡放荡痞女 提交于 2019-12-04 12:26:32
I want to use a library (nlopt) that has a function set_min_objective which takes a pointer to a numerical function myfunc and find its minimum. I would like to create a class that will contain a suitably initialized member function. set_min_objective would then find an optimum in a specific instance (myP in the example below). The call sequence is: opt.set_min_objective(myfunc, NULL); and I would like to use something like: opt.set_min_objective(myP.f, NULL); the error I get when compiling this is: main.cpp: In function 'int main()': main.cpp:79:34: error: no matching function for call to

NLopt with Armadillo data

随声附和 提交于 2019-12-04 12:00:26
The NLopt objective function looks like this: double myfunc(const std::vector<double> &x, std::vector<double> &grad, void *my_func_data) x is the data being optimized, grad is a vector of gradients, and my_func_data holds additional data. I am interested in supplying Armadillo matrices A and B to void *my_func_data . I fiddled with Armadillo's member functions mat A(5,5); mat B(5,5); double* A_mem = A.memptr(); double* B_mem = B.memptr(); which gives me a pointers to the matrices A and B. I was thinking of defining another pointer to these pointers: double** CombineMat; int* Arow = A.n_rows;

Installing nloptr on Linux

梦想的初衷 提交于 2019-12-03 05:37:58
问题 I am trying to install the R package nloptr on a CentOS Linux machine that doesn't have internet connection as follows: install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source") This command in turn looks for the following file online http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz However, this fails since there is no internet connection to the machine. I tried the suggestion from the following stackoverflow post: trouble with Installing nloptr by locally on Ubuntu I

Installing nloptr on Linux

谁说我不能喝 提交于 2019-12-02 19:08:23
I am trying to install the R package nloptr on a CentOS Linux machine that doesn't have internet connection as follows: install.packages("/home/ravi/nloptr_1.0.4.tar.gz", repos = NULL, type="source") This command in turn looks for the following file online http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz However, this fails since there is no internet connection to the machine. I tried the suggestion from the following stackoverflow post: trouble with Installing nloptr by locally on Ubuntu I changed the URL in configure and configure.ac files as follows: NLOPT_URL="file:///home//ravi//${NLOPT