Parameter estimation - estimate integers only

조회 수: 1 (최근 30일)
Mo Jay
Mo Jay 2019년 10월 28일
댓글: Mo Jay 2019년 11월 4일
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