obtaining the same results for unknown values in a cost function using different input values

1 次查看(过去 30 天)
Dear Friends,
I am going to determine two unknow variables (called W and tau-nad) using several input datasets and least squares optimization. the cost function is the RMSE of residual( observed values minus simulated values ). I expect to obtain different values for the unknown parameters when using different set of input values. However, I encounter the constant values for both unknown variables, even when I use different set of input datasets or use different optimization algorithms (e.g., GA). I observe the upper bound of the definded/ intriduced range for each one of the unknown parameters. I mean I observed values around 0.6 and 1.5 for W and tau-nad, respectivelly. I also test several optimization methods including GA with no success. it seems that there is a problem with my codes. I attached my code and I would be thankful if you could help me with this problem.
fun2= @(params) cost_function3(params, observed_reflectivity, C, T, H_r, theta);
options = optimoptions('fmincon','Display','iter');
[x2, fval] = fmincon(fun, initial_guess, [], [], [], [], [0,0], [0.6,1.5], [], options);
fun = @(params) cost_function(params, observed_reflectivity, C, T, H_r, theta);
[x,resnorm,residual,exitflag,output,lambda,jacobian] =lsqnonlin(fun, initial_guess, [0,0], [0.6,1.5]);
function epsilon_r = calculate_permittivity(C, T, W)
W_t = 0.0286+0.00307.*C;
n_d = 1.634 - 0.00539 * C + 2.75 * 10^(-5)* C.^2;
K_d = 0.0395 - 4.038 * 10^(-4)* C;
n_b = (8.86 + 0.00321 * T) + (-0.0644 + 7.96 * 10^(-4)* T).* C + (2.97 * 10^(-4) - 9.6 * 10^(-6)* T) .* C.^2;
K_b = (0.738 - 0.00903 * T + 8.57 * 10^(-5) * T.^2) + (-0.00215 + 1.47 * 10^(-4) * T).* C + (7.36 * 10^(-5) - 1.03 * 10^(-6) * T + 1.05 * 10^(-8) * T.^2) .* C.^2;
n_u = (10.3 - 0.0173 * T) + (6.5 * 10^(-4) + 8.82 * 10^(-5) * T) .* C + (-6.34 * 10^(-6) - 6.32 * 10^(-7) * T) .* C.^2;
K_u = (0.7 - 0.017 * T + 1.78 * 10^(-4) * T.^2) + (0.0161 + 7.25 * 10^(-4) * T) .* C + (-1.46 * 10^(-4) - 6.03 * 10^(-6) * T - 7.87 * 10^(-9) * T.^2) .* C.^2;
% if W <= W_t
% ns = n_d + (n_b - 1) .* W;
% ks = K_d + K_b .* W;
% else
ns = n_d + (n_b - 1) .* W_t + (n_u - 1) .* (W - W_t);
ks = K_d + K_b .* W_t + K_u .* (W - W_t);
% end
real_permittivity = ns.^2 - ks.^2;
imaginary_permittivity = 2 * ns .* ks;
epsilon_r = complex(real_permittivity, imaginary_permittivity);
end
function R_vv = calculate_R_vv(C, T, W, theta)
epsilon_r = calculate_permittivity(C, T, W);
R_vv = (epsilon_r .* cos(deg2rad(theta)) - sqrt(epsilon_r - sin(deg2rad(theta)).^2)) ./ (epsilon_r .* cos(deg2rad(theta)) + sqrt(epsilon_r - sin(deg2rad(theta)).^2));
end
function R_hh = calculate_R_hh(C, T, W, theta)
epsilon_r = calculate_permittivity(C, T, W);
R_hh = (cos(deg2rad(theta)) - sqrt(epsilon_r - sin(deg2rad(theta)).^2))./ (cos(deg2rad(theta)) + sqrt(epsilon_r - sin(deg2rad(theta)).^2));
end
function G_GP_star = calculate_G_GP_star(C, T, W, theta)
R_vv = calculate_R_vv(C, T, W, theta);
R_hh = calculate_R_hh(C, T, W, theta);
G_GP_star = (abs((R_vv - R_hh) ./ 2)).^2;
end
function ref_eff = reflectivity_model(params, C, T, H_r, theta)
W = params(1);
tau_nad = params(2);
ref_GP_star = calculate_G_GP_star(C, T, W, theta);
ref_eff = exp(-((2 * tau_nad) ./ cos(deg2rad(theta))) - (H_r .* (cos(deg2rad(theta))).^(-1)) .* ref_GP_star);
end
function rmse = cost_function3(params, observed_reflectivity, C, T, H_r, theta)
% W = params(1);
% tau_nad = params(2);
modeled_reflectivity = reflectivity_model(params,C, T, H_r, theta);
rmse = (sum((modeled_reflectivity - observed_reflectivity).^2));
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by