Excluding data points from optimization process using createOptimProblem function
6 次查看(过去 30 天)
显示 更早的评论
I have a objective function which produces a 2x13 vector output based on a mathematical model. I'm using 'createOptimProblem' function with 'lsqcurvefit' to compare this output to experimental data of same size, producing a theoretical fit to my experimental data. The problem is that some of my experimental datapoints have huge error, and because of that I would like to exclude them from the optimization process. I would still like to have the fit based on my model to cover the full range of 2x13 points, but I would like the 'lsqcurvefit' function to exclude the experimental datapoints of my choosing when it's calculating the residual error. The attached image shows an example of fit where the experimental datapoints highlighted with green circles are ones I would like to exclude from the residual error calculation. Is there a way to do this using the createOptimProblem function or could you think better ways to do this?
0 个评论
回答(1 个)
Matt J
2021-8-12
编辑:Matt J
2021-8-12
Instead of using lsqcurvefit's calculation of the residual error, why not do your own cusotmized calculation after the optimization is complete? The thing you want to do has nothing to do with the optimization process that I can see.
4 个评论
Matt J
2021-8-12
编辑:Matt J
2021-8-12
There's no reason your ydata needs to be organized as a 2xN matrix. Discard the undesired values using a logical index keep and arrange ydata as a vector. Here's how you might wrap your current model fuction mdl(x,xdata) to accomplish this:
ydata_new=ydata(keep); %new ydata
mdl_new=@(x,xdata) wrapper(x,xdata,keep); %new objective function
function [ypred,varargout]=wrapper(x,xdata,keep)
[ypred,varargout(1:nargout-1)]=mdl(x,xdata);
ypred=ypred(keep);
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!