nlopt

Trouble installing nloptr package on R 3.3.0

喜夏-厌秋 提交于 2019-12-22 07:57:19
问题 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’

Minimization with R nloptr package - multiple equality constraints

試著忘記壹切 提交于 2019-12-22 06:27:14
问题 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 ) ) } #

trouble with Installing nloptr by locally on Ubuntu

落爺英雄遲暮 提交于 2019-12-21 21:20:16
问题 I'm currently using open source (R and ubuntu) to work for my organization. The problem is that we could NOT use internet which means if I want to install some package or software, I have to download it from other pc and transfer it to the working PC. As you might know by now, I'm having trouble with installing the nloptr package on Ubuntu 12.04 with R3.1.3. Attempt 1 I've placed 'nlopt-2.4.2.tar.gz' on 'home' folder. The reason why I did this is that because the 'configure' source code shows

NLopt with Armadillo data

限于喜欢 提交于 2019-12-21 20:37:07
问题 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

Pointer to function to member function

萝らか妹 提交于 2019-12-21 20:27:01
问题 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

Unexpected behaviour of ftol_abs and ftol_rel in NLopt

泪湿孤枕 提交于 2019-12-13 18:40:26
问题 UPDATE: For anyone else who visits this page, it is worth having a look at this SO question and answer as I suspect the solution there is relevant to the problem I was having here. This question duplicates one I have asked on the julia-users mailing list, but I haven't gotten a response there (admittedly it has only been 4 days), so thought I would ask here. I am calling the NLopt API from Julia, although I think my question is independent of the Julia language. I am trying to solve an

NLopt with univariate optimization

╄→尐↘猪︶ㄣ 提交于 2019-12-12 16:40:39
问题 Anyone know if NLopt works with univariate optimization. Tried to run following code: using NLopt function myfunc(x, grad) x.^2 end opt = Opt(:LD_MMA, 1) min_objective!(opt, myfunc) (minf,minx,ret) = optimize(opt, [1.234]) println("got $minf at $minx (returned $ret)") But get following error message: > Error evaluating untitled LoadError: BoundsError: attempt to access 1-element Array{Float64,1}: 1.234 at index [2] in myfunc at untitled:8 in nlopt_callback_wrapper at /Users/davidzentlermunro/

Error while installing a tar.gz package in R

左心房为你撑大大i 提交于 2019-12-12 12:20:10
问题 When i try to install a R package nlopt-2.4.2.tar.gz from http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz , using sudo R CMD INSTALL nlopt-2.4.2.tar.gz , I get the following Error : Error in untar2(tarfile, files, list, exdir, restore_times) : unsupported entry type ‘’ 回答1: It's not an R package! If you perform the tar, zip dance: tar xvfz nlopt-2.4.2.tar.gz and look at the README, you get: NLopt is a library for nonlinear local and global optimization, for functions with and without

Fitting 2d gauss function in C++ too slow

↘锁芯ラ 提交于 2019-12-11 18:49:18
问题 I'm trying to fit a 2d gauss function to an image (in cv::Mat format), and I'm using the NLopt library. I put my object function like this: for(i for each row) for(j for each col) { //compute the gauss function value double valuenow=x[0]*exp(-( x[3]*(j-x[1])*(j-x[1]) + 2*x[4]*(j-x[1])*(i-x[2]) + x[5]*(i-x[2])*(i-x[2]) )); //add square residual to result result+=(valuenow-fitdata.at<double>(i,j))*(valuenow-fitdata.at<double>(i,j)); } return result; My matrix is about 1000*1000 size, I'm using

R packages with Rcpp and nloptr

醉酒当歌 提交于 2019-12-11 05:17:54
问题 I have been building an r-package that runs RcppParallel and calls nloptr from the cpp in parallel. Currently, the package will not build as it can't find the 'nloptrAPI.h' file. The build log outputs: * checking dependencies in R code ... NOTE Namespaces in Imports field not imported from: ‘RcppArmadillo’ ‘nloptr’ My question is if there is a simple fix for this. Or if I would have to rewrite the function to call 'nlopt' from the cpp version and add a 'makevars' file to the package. The src