Contents
Perform hybrid optimization using sbiofit
This example shows how to configure sbiofit to perform a hybrid optimization, that is, first running the optimization using the global solver particleswarm, followed by another minimization function fminunc after the global solver terminates.
Load Data
load(fullfile(matlabroot,'examples','simbio','data10_32R.mat')) gData = groupedData(data); gData.Properties.VariableUnits = {'','hour','milligram/liter','milligram/liter'};
Create a two-compartment model with infusion dose
pkmd = PKModelDesign; pkc1 = addCompartment(pkmd,'Central'); pkc1.DosingType = 'Infusion'; pkc1.EliminationType = 'linear-clearance'; pkc1.HasResponseVariable = true; pkc2 = addCompartment(pkmd,'Peripheral'); model = construct(pkmd); configset = getconfigset(model); configset.CompileOptions.UnitConversion = true; dose = sbiodose('dose','TargetName','Drug_Central'); dose.StartTime = 0; dose.Amount = 100; dose.Rate = 50; dose.AmountUnits = 'milligram'; dose.TimeUnits = 'hour'; dose.RateUnits = 'milligram/hour'; responseMap = {'Drug_Central = CentralConc','Drug_Peripheral = PeripheralConc'}; paramsToEstimate = {'log(Central)','log(Peripheral)','Q12','Cl_Central'}; estimatedParam = estimatedInfo(paramsToEstimate,'InitialValue',[1 1 1 1]);
Define the options for hybrid optimization
rng('default'); globalMethod = 'particleswarm'; options = optimoptions(globalMethod); hybridMethod = 'fminunc'; % Use optimset for fminsearch. Use optimoptions for fminunc and % patternsearch. hybridopts = optimoptions(hybridMethod); options = optimoptions(options,'HybridFcn',{hybridMethod,hybridopts});
Fit data
unpooledFit = sbiofit(model,gData,responseMap,estimatedParam,dose,globalMethod,... options,'Pooled',false,'UseParallel',true,'ProgressPlot',true);
Plot Results
plot(unpooledFit);
Close Parallel Pool
delete(gcp('nocreate'))