using 3rd party optimization toolbox with simbiology

조회 수: 2 (최근 30일)
micronaut
micronaut 2016년 10월 26일
댓글: Arthur Goldsipe 2016년 12월 8일
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.

답변 (1개)

Arthur Goldsipe
Arthur Goldsipe 2016년 10월 26일
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
micronaut
micronaut 2016년 11월 3일
thanks for the help with this question. is there any way to automatically extract the parameters and initial conditions? I see they output as tables but it's unclear as to how to extract a list of parameters with name and value. This prevents using the above method for large models because inputting a huge number of parameters would be very labour intensive in order to enable feeding them back into an optimisation function. Same problem for initial conditions.
Arthur Goldsipe
Arthur Goldsipe 2016년 12월 8일
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

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Perform Sensitivity Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by