matlab: minimization/optimization algorithm -
i use function multiple outputs farina4
computes coefficients a
, b
, e
, f
, vector out_p5tads_final
(1 x n array) through minimization of system of equations using data input set p5tads
(1 x n array):
function [a b e f fval out_p5tads_final] = farina4(p5tads) f = @(coeff)calculs_farina4(coeff,p5tads); [ans,fval] = fminsearchcon(f,coeff0,[0 0 0 0],[1 1 1 1]);% fminsearch constrains = ans(1); b = ans(2); e = ans(3); f = ans(4); out_p5tads_final = p5tads_farina4(a,b,e,f); function out_coeff = calculs_farina4(coeff0,p5tads) %bla-bla-bla end function out_p5tads = p5tads_farina4(a,b,e,f) %bla-bla-bla end end
after calculating a
, b
, e
, f
, out_p5tads_final
need calculate/minimize rms function respect out_p5tads_f4
.
rms = sqrt(mean((p5tads(:) - out_p5tads_f4(:)).^2))*100
and repeat function farina4
in order find optimal set of parameters a
, b
, e
, f
, out_p5tads_final
.
i trying build algorithm of such optimization , not see way far. instance, seems not possible introduce function multiple output inside above rms equation unless there way index somehow output of function farina4
. if there can alternative optimization algorithm rms without fminsearch (or similar) ?
a b e , f values between 0 , 1 out_p5tads_final (1 x 10) array
% function out_coeff = calculs_farina4(coeff0,p5tads) % mmmm = p5tads(1); mmmr = p5tads(2); rmmr = p5tads(3); mmrm = p5tads(4); mmrr = p5tads(5); rmrm = p5tads(6); rmrr = p5tads(7); mrrm = p5tads(8); mrrr = p5tads(9); rrrr = p5tads(10); % = coeff0(1); b = coeff0(2); e = coeff0(3); f = coeff0(4); % f_mmmm = mmmm - ((a^2*b^2*(a + b) + e^2*f^2*(e + f))/2); f_mmmr = mmmr - (a^2*b^2*(e + f) + e^2*f^2*(a + b)); f_rmmr = rmmr - ((a^2*f^2*(b + e) + b^2*e^2*(a + f))/2); f_mmrm = mmrm - 2*a*b*e*f; f_mmrr = mmrr - b*f*(a^3 + e^3) + a*e*(a^3 + f^3); f_rmrm = rmrm - 2*a*b*e*f; f_rmrr = rmrr - 2*a*b*e*f; f_mrrm = mrrm - ((a^2*b^2*(e + f) + e^2*f^2*(a + b))/2); f_mrrr = mrrr - (a^2*f^2*(b + e) + b^2*e^2*(a + f)); f_rrrr = rrrr - ((a^2*f^2*(a + f) + b^2*e^2*(b + e))/2); % out_coeff = f_mmmm^2 + f_mmmr^2 + f_rmmr^2 + f_mmrm^2 + f_mmrr^2 + f_rmrm^2 + f_rmrr^2 + f_mrrm^2 + f_mrrr^2 + f_rrrr^2; end % function out_p5tads = p5tads_farina4(a,b,e,f) % p_mmmm = ((a^2*b^2*(a + b) + e^2*f^2*(e + f))/2); p_mmmr = (a^2*b^2*(e + f) + e^2*f^2*(a + b)); p_rmmr = ((a^2*f^2*(b + e) + b^2*e^2*(a + f))/2); p_mmrm = 2*a*b*e*f; p_mmrr = b*f*(a^3 + e^3) + a*e*(a^3 + f^3); p_rmrm = 2*a*b*e*f; p_rmrr = 2*a*b*e*f; p_mrrm = ((a^2*b^2*(e + f) + e^2*f^2*(a + b))/2); p_mrrr = (a^2*f^2*(b + e) + b^2*e^2*(a + f)); p_rrrr = ((a^2*f^2*(a + f) + b^2*e^2*(b + e))/2); % out_p5tads = [p_mmmm,p_mmmr,p_rmmr,p_mmrm,p_mmrr,p_rmrm,p_rmrr,p_mrrm,p_mrrr,p_rrrr]; end end
thanks in advance !
19/08/2014 3:35 pm
i need optimal set of coefficients b e f rms value , calculated from
rms = sqrt(mean((p5tads(:) - out_p5tads_f4(:)).^2))*100
is minimal. here, vector p5tads used calculate/optimize set of b e f coefficients, in turn used calculate vector out_p5tads_f4. code should run desired number of optimizations cycles (e.g. default 100) , select series of b e f , out_p5tads_f4 afforded minimal rms error value (with respect out_p5tads_f4).
Comments
Post a Comment