Parameter estimation - estimate integers only

1 次查看(过去 30 天)
Hello,
Is there any way I can use one of the optimisation solvers for parameter estimation to just estimate integers eg I am using parameter estimation to guess the gear number of a vehicle model, hence why it must be an integer.
Thank you.

回答(2 个)

Jeff Miller
Jeff Miller 2019-10-28
One way to do this is to write your objective function to return an error function that is linearly interpolated between two integers. Schematically it looks something like this;
function errCompromise = errorFn(x)
% This function receives real values of x suggested by fminsearch or some other optimization routine
xLower = floor(x);
xUpper = ceil(x);
errLower = realErrorFn(xLower);
errUpper = realErrorFn(xUpper);
errCompromise = errLower * (xUpper-x) + errUpper * (x - xLower);
function realErrorFn(x)
% Compute your error function here.
% This function will only get integer values of x
end
end
Note that x will always be driven toward xLower or xUpper, whichever gives the lower error score, and that x will cross over integer boundaries when that reduces error (because fminsearch, etc, know nothing about integer boundaries).
You can extend the same sort of idea if you have more than one integer parameter. Or try fminsearcharb , which uses this technique.
  1 个评论
Matt J
Matt J 2019-10-28
编辑:Matt J 2019-10-28
Note that this is only reliable, however, when used in conjunction with fminsearch and not when used with one of the Optimization Toolbox's higher-dimensional, derivative-based solvers. The scheme will violate differentiability assumptions of something like fmincon for example. Also, any additional constraints that are imposed could prevent x from being driven toward an integer-valued solution.

请先登录,再进行评论。


Matt J
Matt J 2019-10-28
If your objective and constraints are linear, you can use intlinprog. Otherwise, if you have the Global Optimization Toolbox, and you have no equality constraints, you can use ga.
  3 个评论
Matt J
Matt J 2019-11-1
编辑:Matt J 2019-11-1
Yes, the syntax looks fine. Since you only have 2 unknown variables, can't you do a surface plot of estfcn and see approximately where the solution lies? Then you can set your bounds more tightly around that area.
If nothing else, a surface plot would be a good trouble shoooting method, letting you see if the solution that ga is finding is far from the global minimum or not. If it isn't, it would suggest a bug in your objective function, not a failure on the part of ga.
Mo Jay
Mo Jay 2019-11-4
Ok will try that thank you. I think because I have to use simulink for the estimation that's why it is a bit complicated, since my estimation function has to include simulating the model with the estimated parameters :
function G= gafunc(x,output_meas,options)
%% current estimation
VehV=x(1);
Gear_num=x(2);
test=sim('TqShape_sim_mF',[],options);
%% Output battery voltage
Vmeas=output_meas;
test = test.get('logsout');
Vest = test.get('V_out').Values;
%% Compare simulated results to desired curve
G=goodnessOfFit(Vest.Data,Vmeas.Data,'NRMSE');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by