Osr by grid search

hello everyone

I have a problem about grid search for the optimal simple rule(osr)
my model have 24 endogenouse variables and 24 equations
one of equation is below monetary policy rule:

phivariant = landa1phivariant(-1)+landa2pi(-1)+landa3*Y(-1)+epsilon
where : phivariant=money growth , pi= inflation and Y = output
I also have a quadratic loss function of inflation and outputgap

i need to find optimal coefficients of landa1 , landa2 and landa3 that minimized loss function
also i want to use policy rule in alternative time and get impulse responses

can i use grid search for finding this coefficient in dynare?
I know below osr command :

inflation 1;
y 1;
osr_params gammax0 gammac0 gamma_y_ gamma_inf_;
gammarr = 0;
gammax0 = 0.2;
gammac0 = 1.5;
gamma_y_ = 8;
gamma_inf_ = 3;

but i don,t know after present parameter , what is value for parameters and how can find it? is it initial value?

also i know how to write a loop over different values for a parameter like :

rhos = 0.8:0.05:1.05;
for i=1:length(rhos);
rho = rhos(i);
if info;
disp('Computation fails for rho = ’ num2str(rho)]);
// results can be saved here

for finding osr by grid search, do we must mix osr command with loop command?
does osr command apply grid search for finding optimal coeficients?
what is the value of parameters after present parameters and how can find it?

I need to find optimal monetary policy by osr in dynare

please told me anything about my problem that you know.
and introduse some dynare sources about this problem and osr command mechanism.
and recommend your suggestion that can run the model better.

i attach my mod file.

Alireza Bagherpour
finalmodel6.mod (2 KB)

I think there is a misunderstanding here: osr will precisely do the search for the parameters which minimize the objective. So you need not do grid search when using osr, you can just remove the loop.

The loop around stoch_simul for doing a grid search is a very inefficient way of doing what osr does. However it can be useful in order to give a good starting point to the optimization algorithm implemented in osr.