# forum.alglib.net

ALGLIB forum
 It is currently Wed Aug 15, 2018 7:17 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.

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Passing parameters to optimizerPosted: Wed Nov 08, 2017 5:08 pm

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?

Stepan

Top

 Post subject: SolutionPosted: Thu Nov 09, 2017 11:21 am

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

 Post subject: Re: Passing parameters to optimizerPosted: Thu Nov 09, 2017 1:42 pm

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

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot] and 2 guests

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

Search for: