Hi Chong, If I understood correctly, it seems to me like you are trying to minimize a least-squares like metric - where the function you are simulating depends on the vector of parameters, and the data represents the quantities you have measured.
Although my C++ is a bit rusty - there are two ways of doing this. The first way, is to wrap up everything up in a class, where the data is held in a class variable. Then, create a functor that performs the calculation that you want, that has access to the data. The second option is to create a closure. You want to create a function, that takes as an input your data, then returns a function with the correct signature for nlopt. Hope this helps! Federico > Message: 1 > Date: Sun, 25 May 2014 11:40:20 -0400 > From: Chong Li <[email protected]> > To: [email protected] > Subject: [NLopt-discuss] help with MLE estimation with NLopt in C++ > Message-ID: > <CAPPgUKJ= > [email protected]> > Content-Type: text/plain; charset="utf-8" > > Hi, dear all: > > I am having some difficulties in using NLopt to maximize the likelihood > function that takes data as an argument. Only the constraint function in > the example in NLopt tutorial has used a data parameter to pass data to the > constraint function. Could anyone help me out with some example code on how > to deal with this or any general way to do a maximum likelihood estimation > with NLopt in C++? > > Thanks a lot for your attention and have a good week ahead! > > > Chong > > > > -- > Chong Li (? ?) > > Department of Economics, > Maxwell School of Citizenship and Public Affairs, > Syracuse University > Syracuse, NY 13244-1020 > > Email:[email protected] > > Mobile: 315-744-2709 > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://ab-initio.mit.edu/pipermail/nlopt-discuss/attachments/20140525/bc83f598/attachment-0001.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > NLopt-discuss mailing list > [email protected] > http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss > > > ------------------------------ > > End of NLopt-discuss Digest, Vol 56, Issue 3 > ******************************************** >
_______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
