enforce smooth parameter variation in model fit across space

27 views (last 30 days)
Genetic algorithm ga() was used to fit a model to data taken across 3D space.
In this problem, 6 parameters are fit for each spatial point, which takes up to 2 minutes on a laptop; there are 2000 points. Fitting the model to each and every point sequentially takes 1-2 days.
As a first-pass, each point was considered independently, even though the physics-based model parameters must vary smoothly over space. What is a computationally-efficient way to force this smooth spatial variation on all 6 parameters (ideally without requiring a supercomputer or several days of processing)?
The 6 parameters only vary by about one order of magnitude, but I'm not able to say that their variation across XYZ space can be described by some simple function. At present, an optimal fit of the 6 parameters is obtained using ga() to minimize an objective function, as below:
function optimalParamsfor1Point = DoGeneticAlgFit(RawDatafor1Point,BackgroundData)
% setup steps ...
% ----------- DO THE OPTIMIZATION -----------------------------------------
options = optimoptions('...');
optimalParamsfor1Point = ga(@objfun,6,A,b,Aeq,beq,lb,ub,nlcon,options);
% -------------------------------------------------------------------------
function cost = objfun(x)
% given 6 element vector x, RawDatafor1Point, and BackgroundData, return a cost.
% Low cost means parameters in vector x accurately describe raw data.
...
cost = RMS(rawdatvstime - modelestimatevstime)
end
end
So existing code has this structure (N=2000):
% inputs:
% RawXYZData is a Nx1 cell of recorded data vs time for each point
% XYZ is a Nx3 matrix of known XYZ coordinates
% BackgroundData is a struct containing fixed constants
% output:
optimalParams = nan(N,6); % matrix will hold best fit parameters for each point
for i = 1:N
optimalParams(XYZpoint,:) = DoGeneticAlgFit(RawXYZData{i},BackgroundData)
end
A solution to the whole problem has Nx6 (12,000) parameters. I have a solution now composed of N individual solutions, but I would like to impose another constraint: smooth variation across XYZ space.
More description on what I am doing:
I have used a 3D mapper system to measure interactions between a set of antennas. The mapper moves to a point and plays an excitation signal for some time while responses are measured across the system. So, at each point I have a time series of excitation and responses.
An electrical circuit model, with some unknown parameters that depend on the position, describes the interactions. Knowing the model, the excitation, and the responses I can identify best fit parameters.
Seems that I should just look at the shape of parameter solutions for independently-solved points and then pick a function (example, polynomial in X, Y, & Z) and solve globally for the terms of this function. To me this appears to be a messy undertaking: Suppose I assume a quartic equation in 3 space variables (35 terms) and then solve for those terms across my 6 parameters. This would be optimizing 210 unknowns simultaneously.
Is there a more straightforward approach?

Answers (1)

Star Strider
Star Strider on 18 Dec 2025 at 17:39
It likely depends on your problem. If it involves integrating a set of nonlinear ordinary differential equations, and if the parameters span a large range of orders-of-magnitude, use a stiff solver such as ode15s or ode23s instead of ode45.
Does your problem optimise the parameters, or fit them to data?
I would consider the entire model together, and estimate all the parameters simultaneously.
  5 Comments
Brett
Brett ongeveer 10 uur ago
To Torsten's question:
"What kind of model do you use to compute "modelestimatevstime" ?"
It is an algebraic relation, but not a simple closed form equation.
Thank you Star Strider for the example code:
Your solution is very close to what I already have at each point in space. Now I want an efficient way to merge all points so that my parameters (your "Theta") vary smoothly between nearby points.
More description on what I am doing:
I have used a 3D mapper system to measure interactions between a set of antennas. The mapper moves to a point and plays an excitation signal for some time while responses are measured across the system. So, at each point I have a time series of excitation and responses.
An electrical circuit model, with some unknown parameters that depend on the position, describes the interactions. Knowing the model, the excitation, and the responses I can identify best fit parameters.
Seems that I should just look at the shape of parameter solutions for independently-solved points and then pick a function (example, polynomial in X, Y, & Z) and solve globally for the terms of this function. To me this appears to be a messy undertaking: Suppose I assume a quartic equation in 3 space variables (35 terms) and then solve for those terms across my 6 parameters. This would be optimizing 210 unknowns simultaneously.
Is there a more straightforward approach?
Star Strider
Star Strider ongeveer 10 uur ago
My pleasure!
I 'sort of' understand what you're doing (I'm an amateur radio operator). I don't entirely because I don't understand how you're defining the points for the exciter or antenna array. (In my chemical kinetics model, the data are functions only of time, and the model fits the equations by varying the parameter values, integrating the equations, and comparing the integrated equation results to the data.) I'm not certain that I understand how you're defining the parameters in your spatial model, although I suspect some sort of inverse-square approach might be necesary. Are you determining all the parameters for the entire antenna array for each exciter position? If so, that may be the best you can hope for. I'm not certain there would be a way to combine those estimates, or plot them with respect to the different exciter positions. If the antennas are omnidirectionsl, this task might be easier than if they were directional.
It would help to have some sort of description (in code as well as symbolic), and the appropriate data to fit it.

Sign in to comment.

Products


Release

R2025b

Community Treasure Hunt

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

Start Hunting!