using 3rd party optimization toolbox with simbiology
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
There are 2 third party particle swarm packages available in the file exchange (e.g https://uk.mathworks.com/matlabcentral/fileexchange/25986-constrained-particle-swarm-optimization).
Does anybody know if it's possible to use these with simbiology models? I know there are particle swarm algorithms available in the global optimisation toolbox however, I was interested in trying these algorithms in the toolboxes out. Is Simbiology restricted to using only those algorithms in the Mathworks optimisation toolboxes? I'm not really familiar with the format of the model code with Simbiology so wouldn't know how to "hack" sbproj files to work from the Matlab command line. If there are any links to resources that might explain this then any links would be much appreciated too.
Thanks for any help.
0 Kommentare
Antworten (1)
Arthur Goldsipe
am 26 Okt. 2016
Hi,
Are you using optimization methods to estimate model parameters that best fit a model to data? I'm going to assume so for the rest of my answer.
SimBiology tries to make fitting and estimation tasks easier by providing a command-line function, sbiofit, and a GUI desktop task. This functionality only supports optimization methods that ship with MATLAB, Optimization Toolbox, or Global Optimization Toolbox.
However, you can use any optimization method from any source to estimate parameters in a model if you are willing to do more work. You will need to write an appropriate objective function. For example, if you want to do traditional non-linear least squares, the function might simulate the SimBiology model using a potential set of parameter values, calculate the residuals (the difference between the experimental and predicted values), and sum the squares of the residuals. The optimizer would then minimize this value.
I think the best option for doing the simulations is a SimFunction object. This object makes it easy to simulate a SimBiology model with different parameter values.
Here's a short example showing how to write your own objective function based on a SimFunction and use it with fminsearch:
function paramsOptimal = runOptimization
%%Create fake sample data to fit
time = 0.1:.02:1;
x = 275*exp(-8*time) + randn(size(time));
%%Create a SimFunction
project = sbioloadproject('radiodecay', 'm1'); % Load the model
% The SimFunction simulates the concentration of x over time as a function
% of the initial amount of x and the reaction rate parameter c.
simFunc = createSimFunction(project.m1, {'x', 'Reaction1.c'}, {'x'}, []);
delete(project.m1); % Delete the model once we're done with it.
%%Create an objective function
function f = objectiveFunction(params)
[~, xSimCell] = simFunc(params, [], [], time);
residuals = x(:) - xSimCell{1}(:);
f = sum(residuals.^2);
end
%%Use optimization method fminsearch to estimate the parameters
params0 = [1000, 1];
options = optimset('Display', 'iter');
paramsOptimal = fminsearch(@objectiveFunction, params0, options);
end
-Arthur
2 Kommentare
Arthur Goldsipe
am 8 Dez. 2016
I'm not sure I understand your question, but it is easy to extra names and values from a table. In the context of my example, are you saying you'd like to params0 to be the values stored on the model? If so, you should be able to do something like this:
params0 = simFunc.Parameters.Value'
And sorry I didn't respond earlier. I don't get notified when you post comments. Feel free to contact me directly if you don't hear back from a comment in a timely fashion.
-Arthur
Communitys
Weitere Antworten in SimBiology Community
Siehe auch
Kategorien
Mehr zu Perform Sensitivity Analysis finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!