Parameter estimation - estimate integers only

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.

Antworten (2)

Jeff Miller
Jeff Miller am 28 Okt. 2019

0 Stimmen

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 Kommentar

Matt J
Matt J am 28 Okt. 2019
Bearbeitet: Matt J am 28 Okt. 2019
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.

Melden Sie sich an, um zu kommentieren.

Matt J
Matt J am 28 Okt. 2019

0 Stimmen

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 Kommentare

I tried using ga for integer only and my results were pretty inaccurate - have I got the correct syntax? (I just want the gear to be an integer, the speed doesn't have to be). Thank you
lb=[5;1] %speed;gear
ub=[120;9]
estfcn=@(x)gafunc(x,output,options);
options2=gaoptimset('Generations',30,'PlotFcn',@gaplotbestf,'Display','iter');
xOpt = ga(estfcn,2,[],[],[],[],lb,ub,[],2,options2);
Matt J
Matt J am 1 Nov. 2019
Bearbeitet: Matt J am 1 Nov. 2019
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.
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');

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 28 Okt. 2019

Kommentiert:

am 4 Nov. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by