Mehdi in MATLAB Answers
Última actividad el 21 de Mzo. de 2024

I have s SimBiology model in which the stochiometry of some equations depend on a model parameter called "DAR" as you can see below. I have DAR and some other paameters to change and see their effect on some observables. Once I change DAR and create a SimFunction, The stochiometry of equations do not change. Is there any way to use simFunction object and see the effect of DAR on the stchiometry. I can change the stochiometry in loop but I want it to be chnage as I use simFunction. Thanks reactionObj = addreaction(model,'Media.ADC_ext -> Media.Ab_ext + Media.PL_ext'); set (reactionObj, 'Stoichiometry', [-1 1 sbioselect(model,'Name','DAR').Value]) set (reactionObj, 'ReactionRate', 'kdec*Media.ADC_ext'); set (reactionObj, 'Notes', 'ADCs lose their payload, to produce unconjugated antibody and free payload'); set (reactionObj, 'Name', 'r1');
Colton Harper in MATLAB Answers
Última actividad el 15 de Sept. de 2020

In March of 2020, there was a question about parfor loops and simbiology. (https://www.mathworks.com/matlabcentral/answers/510565-issues-with-doses-variants-in-parfor-loop-in-simbiology?s_tid=srchtitle) I currently use a parfor loop, but my model is fairly large and uses a lot of molecules -- around 40 species and 40 reactions. As a result, it takes a very long time to obtain my results. I was wondering if you think SimFunction (along with 'UseParallel' and 'AutoAccelerate') would be appropriate for me to use. -- Below, you'll find that I use a parfor appoach and make sure the files are accessible through the latter two functions. After seeing the aforementioned post, I'm wondering if I should be using SimFunction, sbiosimulate, sbioaccelerate, sbioensemblerun, or another method to optimize my approach. Here is the general structure for what I am trying to accomplish: I am using SimBiology 2019b. The solver I need to use is SSA, monte carlo style. I have a chemical reaction network set up. I add an event at 3000 seconds to set the concentration of an 'input' species to a given value. I have a species in the chemical reaction network that I view as the 'output' species. My goal is to run 100 simulations for each given input amount. Then, I would like to increase the input amount over 100 steps in a uniformly increasing manner at each step and observe the behavior of the 'output' species. Here is the structure of my code: for i = 1:100 %100 steps with uniform increasing 'input' species amounts sbioloadproject('model.sbproj'); cs = getconfigset(m1, 'default'); cs.SolverType = 'ssa'; solver = cs.SolverOptions; solver.LogDecimation = 1000; inputSpecies = sbioselect(m1,'Type','species','Name','inputSpecies'); %The 'input' species inputSpecies.InitialAmount = 0; parameterTimeunits = addparameter(m1,'Timeunits',1.0,'ValueUnits','minute','ConstantValue',true); parameterMolunits = addparameter(m1,'Molunits',1.0,'ValueUnits','molecule','ConstantValue',true); inputSpecies = addevent(m1, '(time/Timeunits) >= 3000', ['inputSpecies = (1500000*' num2str(i) ')*Molunits']); sbiosaveproject modelParallel.sbproj m1 inputSpecies clear m1; %simulate the model parfor j=1:100 %Number of simulation runs per input step [m1,inputSpecies] = loadSimBiologyModel('modelParallel.sbproj'); [t,x,names] = sbiosimulate(m1); parsave(['StochasticTest_Input' num2str(i) '_Instance' num2str(j)], inputSpecies, t, x, names); end end function [m2,inputSpecies2] = loadSimBiologyModel(filename) sbioloadproject(filename); m2 = m1; inputSpecies2 = inputSpecies; end function parsave(fname,inputSpecies,t,x, names) save(fname,'inputSpecies','t','x','names'); end %I'll then take all these datafiles, interpolate them, and combine it into one dateset. %Then I'll observe the amount of output over time for the varying range of input. With my current approach, I haven't become very familiar with parameters or doses. Would you be able to provide me some insights on A.) if SimFunciton (along with 'UseParallel' and 'AutoAccelerate') is appropriate and if so, B.) since the parameters and doses don't seem applicable to my setup, how can I adapt the function inputs appropriately? Any tips, suggestions, or critiques are happily welcomed. If you need any more info, please let me know.
Abed Alnaif in MATLAB Answers
Última actividad el 12 de Dic. de 2019

Hello, I'm having trouble simultaneously simulating multiple parameterizations of a model using simfunctions and scenarios, in R2019b. Please refer to the example below. Is there a proper way of doing this? I think I could get around this error be inputting all of the parameterizations when calling 'createSimFunction', but this is not possible in my application because I do not know a priori how many different parameterizations I plan to simulate. Thank you, Abed % The following works: sbioloadproject('insulindemo','m1'); variants = getvariant(m1); singleMeal = sbioselect(m1,'Name','Single Meal'); sObj = SimBiology.Scenarios; add(sObj,'cartesian','variants',variants); add(sObj,'cartesian','dose',singleMeal); sObj.verify(m1); f = createSimFunction(m1,sObj,{'[Plasma Glu Conc]','[Plasma Ins Conc]'},[]); sd = f(sObj,24); % But the following triggers an error: nIndivs = 2; % number of parameterizations (let's pretend each individual has different parameterizations -- although in this example they have the same parameterization). for iEntry = 1:sObj.NumberOfEntries sObj = sObj.updateEntry(iEntry,'Content',repmat(sObj.getEntry(iEntry).Content,nIndivs,1)); end sObj.verify(m1); sd2 = f(sObj,24);
Abed Alnaif in MATLAB Answers
Última actividad el 6 de Dic. de 2019

Hello, I'm having a hard time restricting output times when calling simfunctions. Is there a way to do this? I thought that the 't_output' argument would do this, but it appears that this argument only specifies certain output times that should be included (see example below). Is there a way to restrict the output times to only certain specified times? Thank you, Abed sbioloadproject('insulindemo', 'm1'); normSim = createSimFunction(m1,{},{'[Plasma Glu Conc]','[Plasma Ins Conc]'},'Dose'); singleMeal = sbioselect(m1,'Name','Single Meal'); mealTable = getTable(singleMeal); tOutput = 23.99; tStop = 24; simData = normSim([],tStop,mealTable,tOutput); simData.Time % can we restrict output times to only 23.99?
Abed Alnaif in MATLAB Answers
Última actividad el 4 de Dic. de 2019

Hello, I get the following error when trying to accelerate a simfunction in R2019b. Is there a way I could specifically identify the culprit of this error? Warning: Following error occurred while testing a MEX file created for SimBiology acceleration: Accelerated results for initialAssignment rules did not match the unaccelerated results. Check that initialAssignment rule expressions and any user-defined functions are valid and supported for code generation as described in the Language, Function, and Object Support in MATLAB documentation. If this problem persists, contact Technical Support. Click here for more information.
Jeremy Huard in Discussions
Última actividad el 22 de Mzo. de 2019

*What is it?* |SimFunction| allows you to _perform multiple simulations in a single line of code_ by providing an interface to execute SimBiology® models like a regular MATLAB function. Consider the following similarity: If you want to calculate the value of the sine function at multiple times defined in the variable t, you use the following syntax: >> y = sin(t) If mymodel represents a |SimFunction|, you can simulate your model with multiple parameter sets using the following syntax: >> simulationData = mymodel(parameterValues, stopTime, dose) <.> *What is it good for?* _Multiple simulations_ Because it allows you to perform multiple simulations in a single line of code by providing a matrix of parameter values or variants or a cell array of dosing tables, it is particularly suited for * parameter and dose scans * Monte Carlo simulations * customized analyses that require multiple model simulations such as a customized optimization _Performance_ SimFunctions are optimized for performance as they are automatically <https://www.mathworks.com/help/simbio/ug/accelerating-model-simulations-and-analyses.html accelerated> at the first function execution, which converts the model into compiled C code. Those simulations can be distributed to multiple cores or to a cluster and run in parallel if Parallel Computing Toolbox™ is available thanks to its <https://www.mathworks.com/help/simbio/ref/createsimfunction.html#namevaluepairarguments built-in parallelization> or within a <https://www.mathworks.com/help/distcomp/parfor.html parfor> loop. _Simulation deployment_ Since SimFunction objects cannot be changed once created, they can be shared with others without the risk of altering the model inadvertently. Also, you can use SimFunctions to integrate a SimBiology model into a customized MATLAB App and <https://es.mathworks.com/matlabcentral/answers/244644-how-can-i-use-matlab-compiler-to-make-a-stand-alone-script-including-simfunction-objects compile it as standalone application> to share with anyone without the need of a MATLAB license. <.> *How does it work?* Create a <https://www.mathworks.com/help/simbio/ref/simfunctionobject.html SimFunction object> using the <https://www.mathworks.com/help/simbio/ref/createsimfunction.html createSimFunction> method by choosing: # which parameters it should take as inputs # which targets will be dosed # which model quantities it should return # which sensitivities it should return if any <</matlabcentral/discussions/uploaded_files/60/simFunction.gif>> Have a look at the following example from the SimBiology documentation for an executable script to help you get started: <https://www.mathworks.com/help/simbio/ug/perform-a-parameter-scan.html Perform a Parameter Scan>. Tips and Tricks: Use SimFunction for easy and fast model simulations in scripts simbiology simfunction simulation