Help defining normalized SSE for problem based objective function
Ältere Kommentare anzeigen
Hi all, I'm using problem-based solving to fit some coefficients in a differential equation to some experimental data that I'm reading in from an Excel file. Everything is working well. But I have some issues in that I'm working with multiple data sets simulaneously that span a wide range of responses and the sets at the high end of the distribution are forcing the fit at the expense of the datasets at the low end of the distribution just due to the fact that I'm using a sum-square-error objective function:
obj = sum(sum((myfcn - experimentalData{5:height(experimentalData),3:width(experimentalData)}).^2));
There are individual data sets in each column of the experimentalData table with different ranges. I want to scale the objective function calculation by the mean of these datasets.
I have calculated the mean for each one:
cAverage(i) = mean(experimentalData{5:height(experimentalData),i+2}); % there are two dummy columns before the data
What I want is a simple expression to divide the delta between the result of the calculated function and the experimental data by the average. So a matrix divided by a vector, by column.
When I type manually in the script prompt the right equation for this:
(myfcn - experimentalData{5:height(experimentalData),3:width(experimentalData)})./cAverage,
it appears to work, but when I edit the formula to
add this in and run the script, I'm getting an error for the argument dimensions must agree.
Can someone give me a clue how to do a normalized SSE objective function?
Thanks,
Tony
Antworten (1)
add this in and run the script, I'm getting an error for the argument dimensions must agree.
Well, we have no idea what you've done to ensure that myfcn is the same size as your experimentalData block, but assuming you have, then,
selection = experimentalData{5:height(experimentalData),3:width(experimentalData)};
Error= ( myfcn-selection./mean(selection,1) );
SSE=sum( Error.^2,'all');
10 Kommentare
Anthony Ozzello
am 3 Feb. 2022
Matt J
am 3 Feb. 2022
That doesn't seem very different from what I proposed,
Error = ( myfcn-selection)./mean(selection,1);
Anthony Ozzello
am 3 Feb. 2022
Anthony Ozzello
am 3 Feb. 2022
I can't tell what error you're seeing (because you didn't post it). I also can't advise how to set up the objective function because I can't see from your code which variables are the optimization variables and which are the fixed parameters.
I would recommend abandoning the problem-based framework for this, though. There's no real advantage to it when you don't have linear constraints. For this, I woudl just use lsqcurvefit().
Also, because this is an ODE optimization, you will probably need to be familiar with,
Anthony Ozzello
am 3 Feb. 2022
this is beyond what lsqcurvefit() can handle
That's doubtful. SSE minimization is exactly what lsqcurvefit is for. In any case, there's no reaon to think the problem-based framework is going to do any better. It's just a wrapper for lsqcurvefit(0 and other solver-based methods.
In your code, you have this,
fcn2optimexpr(@RtoODE,r,z,n,nComponents,tspan,y0, experimentalData)
Which of these are variables that you are trying to optimize? One thing that's definitely wrong is that the list of variables is only supposed to include optimvars. Therefore, experimentalData should not be there.
Anthony Ozzello
am 3 Feb. 2022
Anthony Ozzello
am 3 Feb. 2022
Anthony Ozzello
am 3 Feb. 2022
Kategorien
Mehr zu Choose a Solver finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!