Search optimal loss function

Dear dynare team, now I have a question. I write the loss function:
Loss = var(inflation)+alpha*var(output)
let the parameters alpha belongs to [0, 0.2, 0.4, …,2]. I use the standard Taylor Rule, policy response parameters take grid values, that is
psi_pi = 0:0.5:5 psi_y = 0:0.25:2.5
How I search policy parameters (psi_pi, psi_y) to minimum loss function value for each given alpha ? thank you so much.

My best,
ZL

Please search the forum, for example Loop over parameters to find maximized welfare

Thanks so much, but in the sample code by you provided:
weight_grid=0:0.01:1;
n_grid_points=length(weight_grid);
var_y=NaN(n_grid_points,1);
var_pi=NaN(n_grid_points,1);
for grid_iter=1:n_grid_points
M_.osr.variable_weights(pi_pos,pi_pos) = weight_grid(grid_iter);
M_.osr.variable_weights(y_pos,y_pos) = (1-weight_grid(grid_iter));
oo_.osr = osr(var_list_,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);
if oo_.osr.error_indicator==0
var_y(grid_iter)=oo_.var(y_pos_var_list_,y_pos_var_list_);
var_pi(grid_iter)=oo_.var(pi_pos_var_list_,pi_pos_var_list_);
end
end
I want to ask this line:
oo_.osr = osr(var_list_,M_.osr.param_names,M_.osr.variable_indices,M_.osr.variable_weights);
what dose it means? What I confused is in reference I saw that M_.osr.param_names, M_.osr.variable_indices, M_.osr.variable_weights are output by an execution of the command osr, so it cannot write in options which specified in command osr. Please help me, thanks a lot.

See

Thank you for professor jpfeifer, I read this right now. Thanks!