forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 3:04 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Passing parameters to optimizer
PostPosted: Wed Nov 08, 2017 5:08 pm 
Offline

Joined: Wed Jul 18, 2012 1:14 pm
Posts: 9
Hey,
I use BFGS optimizer and I'd like to run a parallel loop few optimization procedures. In order to do this I should provide unique (parameters to) objective function for each parallel stream. How can I do this with alglib? Can I run optimizer by passing unique pointers to it?

My current objective function defined as
Code:
void function3_func(const real_1d_array &x, double &func, void *ptr)
{
   func = -d_Likelihood(delta_tk, c, x[0],x[1], x[2], NN, y_ob, (int)TT);
}


How can I pass unique y_ob in parallel?

Thx in advance,
Stepan


Top
 Profile  
 
 Post subject: Solution
PostPosted: Thu Nov 09, 2017 11:21 am 
Offline

Joined: Wed Jul 18, 2012 1:14 pm
Posts: 9
If someone need it. I used the following constructions:
Code:
void function2_func(const real_1d_array &x, double &func, void *ptr)
{
   InputData data_tmp = *((InputData *)ptr);
   func = -c_Likelihood(x[0], x[1], x[2], data_tmp.N, data_tmp.R, data_tmp.Q, data_tmp.NN);
}

Code:
struct InputData
{
   int R,Q,NN;
   double  N;
};

InputData data;
simulated_data.Q = Q_tmp; simulated_data.N = N_tmp;
simulated_data.R = c_tmp; simulated_data.NN = N_tmp;
...
alglib::minbleicoptimize( state, function2_func, NULL, (void*)&data);


Top
 Profile  
 
 Post subject: Re: Passing parameters to optimizer
PostPosted: Thu Nov 09, 2017 1:42 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Yes, that's exactly how it is intended to work! :))


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group