Settings file
Default settings code
1function [stg] = default_settings() 2% This function returns a structure "stg" containing default settings for a 3% model analysis and optimization workflow. The structure includes settings 4% related to model import, analysis, simulation, diagnostics, plotting, 5% sensitivity analysis, and optimization. Inputs and outputs for the 6% function are as follows: 7% 8% Inputs: None 9% 10% Outputs: 11% - stg: A structure containing fields for various settings, which 12% include import options, analysis options, simulation options, 13% diagnostics settings, plotting options, sensitivity analysis 14% options, and optimization settings. 15% 16% Functions called: None 17% 18% Loaded variables: None 19% 20% To understand the function better, please read the comments within the 21% code for a detailed explanation of each setting and their default values. 22 23% stg.exprun: Lists experiments to run (example experiment 1 to 3 and 24% experiment 6) 25% 26% stg.useLog: Determines the scoring method choice (check documentation) 27% (Use logarithm) 28% 29% stg.optmc: Specifies whether to use multicore wherever available 30% (Optimization Multicore) 31% 32% stg.rseed: Sets the random seed value (Random seed) 33% 34% stg.simcsl: Indicates whether to display simulation diagnostics in the 35% console (Simulation Console) 36% 37% stg.optcsl: Specifies whether to display optimization results in the 38% console (Optimization console) 39% 40% stg.save_results: Specifies whether to save results (Save results) 41% 42% stg.simdetail: Specifies whether to run detailed simulation for plots 43% 44% stg.maxt: Sets the maximum time for each individual function to run in 45% seconds (Maximum time) 46% 47% stg.eqt: Defines the equilibration time (Equilibration time) 48% 49% stg.dimenanal: Specifies whether to perform Dimensional Analysis 50% (Dimensional Analysis) 51% 52% stg.UnitConversion: Specifies whether to perform Unit conversion (Unit 53% conversion) 54% 55% stg.abstolscale: Specifies whether to apply Absolute Tolerance Scaling 56% (Absolute Tolerance Scaling) 57% 58% stg.reltol: Assigns the value of Relative tolerance (Relative tolerance) 59% 60% stg.abstol: Assigns the value of Absolute tolerance (Absolute tolerance) 61% 62% stg.simtime: Specifies the time units for simulation (Simulation time) 63% 64% stg.sbioacc: Specifies whether to run sbioaccelerate (sbioaccelerate) 65% 66% stg.abstolstepsize_eq: Provides the absolute tolerance step size for 67% equilibration (Absolute tolerance step size for equilibration) 68% 69% stg.maxstep: Max step size in the simulation (if empty, Matlab decides 70% what's best) (Maximum step) 71% 72% stg.maxstepeq: Sets the max step size in the simulation (if empty, Matlab 73% decides what's best) (Maximum step) 74% 75% stg.maxstepdetail: Sets the max step size in the detailed plots (if 76% empty, Matlab decides what's best) (Maximum step) 77% 78% stg.errorscore: Specifies the default score when there is a simulation 79% error, required to keep optimizations working (error score) 80% 81% stg.parnum: Specifies the number of parameters to optimize (Parameter 82% number) 83% 84% stg.lb: Assigns the array with the lower bound of all parameters (Lower 85% bound) 86% 87% stg.ub: Assigns the array with the upper bound of all parameters (Upper 88% bound) 89% 90% stg.partest: Choice of what parameters in the array to test, the indices 91% correspond to the parameters in the model and the numbers correspond to 92% the parameters in the optimization array (Parameters to test) 93% 94% stg.pat: Defines the parameter array to test (Parameter array to test) 95% 96% stg.pa: Contains all the parameter arrays (parameters here are in log10 97% space) (Parameter arrays) 98% 99% stg.bestpa: Provides the best parameter array found so far for the model 100% (Best parameter array) 101% 102% stg.plot: Specifies whether to plot results (Plots) 103% 104% stg.plotoln: Specifies whether to use long names in the title 105% 106% stg.sansamples: Sets the number of samples to use in Sensitivity Analysis 107% (Sensitivity analysis number of samples) 108% 109% stg.sasubmean: Specifies whether to subtract the mean before calculating 110% SI and SIT in Sensitivity Analysis (Sensitivity analysis subtract mean) 111% 112% stg.sasamplemode: Determines the sampling mode for Sensitivity Analysis 113% (Sensitivity analysis sampling mode) 114% 115% stg.sasamplesigma: Defines the sigma for creating the normal distribution 116% of parameters to perform Sensitivity Analysis (Sensitivity analysis 117% sampling sigma) 118% 119% stg.optt: Sets the time for the optimization in seconds (Optimization 120% time) 121% 122% stg.popsize: Defines the population size for the algorithms that use 123% populations (Population size) 124% 125% stg.osm: Chooses the optimization start method (Optimization start 126% method) 127% 128% stg.dbs: Specifies the distance from the best parameter array to be used 129% in stg.osm method 2 (Distance from best parameter array) 130% 131% stg.mst: Specifies whether to use Multistart (Multistart) 132% 133% stg.msts: Provides the Multistart size 134% 135% stg.optplots: Specifies whether to display Plots (Plots don't work if 136% using multistart) (Optimization plots) 137% 138% stg.fmincon: Indicates whether to run fmincon (fmincon) 139% 140% stg.fm_options: Sets options for fmincon (fmincon options) 141% 142% stg.sa: Specifies whether to run simulated annealing (Simulated 143% annealing) 144% 145% stg.sa_options: Provides options for simulated annealing (Simulated 146% annealing options) 147% 148% stg.psearch: Specifies whether to run Pattern search (Pattern search) 149% 150% stg.psearch_options: Sets options for Pattern search (Pattern search 151% options) 152% 153% stg.ga: Specifies whether to run Genetic algorithm (Genetic algorithm) 154% 155% stg.ga_options: Options for Genetic algorithm (Genetic algorithm options) 156% 157% stg.pswarm: Specifies whether to run Particle swarm (Particle swarm) 158% 159% stg.pswarm_options: Sets options for Particle swarm (Particle swarm 160% options) 161% 162% stg.sopt: Specifies whether to run Surrogate optimization (Surrogate 163% optimization) 164% 165% stg.sopt_options: Provides options for Surrogate optimization (Surrogate 166% optimization options) 167 168 169 170 171 172 173 174 175 176%% Analysis 177 178% Lists experiments to run (example experiment 1 to 3 and experimet 6) 179stg.exprun = [1:3,6]; 180 181% Determines the scoring method choice (check documentation) (Use 182% logarithm) 183stg.useLog = 4; 184 185% Specifies whether to use multicore wherever available (Optimization 186% Multicore) 187stg.optmc = true; 188 189% Sets the random seed value (Ramdom seed) 190stg.rseed = 1; 191 192% Indicates whether to display simulation diagnostics in the console 193% (Simulation Console) 194stg.simcsl = false; 195 196% Specifies whether to display optimization results in the console 197% (Optimization console) 198stg.optcsl = false; 199 200% Specifies whether to save results (Save results) 201stg.save_results = true; 202 203% Specifies whether to run detailed simulation for plots 204stg.simdetail = true; 205 206%% Simulation 207 208% Sets the maximum time for each individual function to run in seconds 209% (Maximum time) 210stg.maxt = 10; 211 212% Defines the equilibration time (Equilibration time) 213stg.eqt = 50000; 214 215% Specifies whether to perform Dimensional Analysis (Dimensional Analysis) 216stg.dimenanal = false; 217 218% Specifies whether to perform Unit conversion (Unit conversion) 219stg.UnitConversion = false; 220 221% Specifies whether to apply Absolute Tolerance Scaling (Absolute Tolerance 222% Scaling) 223stg.abstolscale = true; 224 225% Assigns the value of Relative tolerance (Relative tolerance) 226stg.reltol = 1.0E-4; 227 228% Assigns the value of Absolute tolerance (Absolute tolerance) 229stg.abstol = 1.0E-4; 230 231% Specifies the time units for simulation (Simulation time) 232stg.simtime = "second"; 233 234% Specifies whether to run sbioaccelerate (after changing this value you 235% need to run "clear functions" to see an effect) (sbioaccelerate) 236stg.sbioacc = true; 237 238% Provides the absolute tolerance step size for equilibration (Absolute 239% tolerance step size for equilibration) 240stg.abstolstepsize_eq = []; 241 242% Max step size in the simulation (if empty matlab decides whats best) 243% (Maximum step) 244stg.maxstep = 10; 245 246% Sets the max step size in the simulation (if empty, Matlab decides what's 247% best) (Maximum step) 248stg.maxstepeq = 2; 249 250% Sets the max step size in the detailed plots (if empty, Matlab decides 251% what's best) (Maximum step) 252stg.maxstepdetail = 2; 253 254% Specifies the default score when there is a simulation error, required to 255% keep optimizations working (error score) 256stg.errorscore = 10^5; 257%% Model 258 259% Specifies the number of parameters to optimize (Parameter number) 260stg.parnum = 5; 261 262% Provides the array with the lower bound of all parameters 263original_parameter_set = zeros(1,10); 264 265% Assigns the array with the lower bound of all parameters (Lower bound) 266stg.lb = original_parameter_set-5; 267 268% Assigns the array with the upper bound of all parameters (Upper bound) 269stg.ub = original_parameter_set+5; 270 271%% Diagnostics 272 273% Choice of what parameters in the array to test, the indices correspond to 274% the parameters in the model and the numbers correspond to the parameters 275% in the optimization array, usually not all parameters are optimized so 276% there needs to be a match between one and the other. (Parameters to test) 277% In this example there are ten parameters in this imaginary model and we 278% are only interested in parameter 2,4,8,9, and 10. Note that stg.parnum is 279% five because of this and not ten 280stg.partest(:,1) = [0,1,0,2,0,0,0,3,4,5]; 281 282% Defines the parameter array to test (Parameter array to test) 283stg.pat = 1:2; 284 285% Contains all the parameter arrays (parameters here are in log10 space) 286% (Parameter arrays) 287stg.pa(1,:) = [1,1,1,1,1]; 288stg.pa(1,:) = [1,0,1,2,1]; 289 290% Provides the best parameter array found so far for the model (Best 291% parameter array) 292stg.bestpa = stg.pa(1,:); 293 294%% Plots 295 296% Specifies whether to plot results (Plots) 297stg.plot = true; 298 299% Specifies whether to use long names in the title of the output plots in 300% f_plot_outputs.m (Plot outputs long names) 301stg.plotoln = true; 302 303%% Sensitivity analysis 304 305% Sets the number of samples to use in Sensitivity Analysis (Sensitivity 306% analysis number of samples) 307stg.sansamples = 100; 308 309% Specifies whether to subtract the mean before calculating SI and SIT in 310% Sensitivity Analysis (Sensitivity analysis subtract mean) 311stg.sasubmean = true; 312 313% Determines the sampling mode for Sensitivity Analysis; 0 Log uniform 314% distribution truncated at the parameter bounds 1 Log normal distribution 315% with mu as the best value for a parameter and sigma as stg.sasamplesigma 316% truncated at the parameter bounds 2 same as 1 without truncation 3 Log 317% normal distribution centered at the mean of the parameter bounds and 318% sigma as stg.sasamplesigma truncated at the parameter bounds 4 same as 3 319% without truncation. (Sensitivity analysis sampling mode) 320stg.sasamplemode = 2; 321 322% Defines the sigma for creating the normal distribution of parameters to 323% perform Sensitivity Analysis (Sensitivity analysis sampling sigma) 324stg.sasamplesigma = 0.1; 325 326%% Profile Likelihood 327 328% Parameter(optimization array) that is being worked on in a specific 329% iteration of PL (if -1 no parameter is being worked in PL) 330% (Profile Likelihood Index) 331stg.PLind = -1; 332 333% Which parameters to do PL on, it should be all parameters but can also be 334% a subset for testing purposes 335% (Profile Likelihood parameters to Test) 336stg.pltest = (1:6); 337 338% How many points to do for each parameter in the PL 339% (Profile Likelihood Resolution) 340stg.plres = 50; 341 342% True or false to decide whether to do plots after calculating PL 343% (Profile Likelihood Plots) 344stg.plplot = true; 345 346% True or false to decide whether to run simulated annealing 347% (Profile Likelihood Simulated Annealing) 348stg.plsa = false; 349 350% Options for simulated annealing 351stg.plsao = optimoptions(@simulannealbnd,'Display','off', ... 352 'InitialTemperature',... 353 ones(1,stg.parnum-1)*1,'MaxTime',7,'ReannealInterval',40); 354 355% stg.plsao = optimoptions(@patternsearch,... 356% 'MaxTime',25,'UseParallel',false,... 357% 'UseCompletePoll',true,'UseCompleteSearch',true,... 358% 'MaxMeshSize',2,'MaxFunctionEvaluations',2000); 359 360% True or false to decide whether to run fmincon 361% (Profile Likelihood FMincon) 362stg.plfm = false; 363 364% Options for fmincon 365stg.plfmo = optimoptions('fmincon','Display','off',... 366 'Algorithm','interior-point',... 367 'MaxIterations',2,'OptimalityTolerance',0,... 368 'StepTolerance',1e-6,'FiniteDifferenceType','central'); 369 370 371% True or false to decide whether to run Pattern search 372% (Pattern search) 373stg.plps = false; 374 375% Options for Pattern search 376% (Pattern search options) 377stg.plpso = optimoptions(@patternsearch,'Display','off',... 378 'MaxTime',7,... 379 'UseCompletePoll',true,'UseCompleteSearch',true,... 380 'MaxMeshSize',1,'MaxFunctionEvaluations',10000); 381 382 383 384%% Optimization 385 386% Sets the time for the optimization in seconds (fmincon does not respect 387% this time!!) (Optimization time) 388stg.optt = 60*5; 389 390% Defines the population size for the algorithms that use populations 391% (Population size) 392stg.popsize = 144; 393 394% Chooses the optimization start method: 1 for random starting point(s) 395% inside bounds, 2 for random starting point(s) near the best point 396% (Optimization start method) 397stg.osm = 1; 398 399% Specifies the distance from the best parameter array to be used in 400% stg.osm method 2 (Distance from best parameter array) 401stg.dbs = 0.1; 402 403% Specifies whether to use Multistart (Multistart) 404stg.mst = false; 405 406% Provides the Multistart size 407stg.msts = 1; 408 409% Specifies whether to display Plots (Plots don't work if using multistart) 410% (Optimization plots) 411stg.optplots = true; 412 413% Indicates whether to run fmincon (no gradient, so this doesn't work well; 414% no max time!!) (fmincon) 415stg.fmincon = false; 416 417% Sets options for fmincon (fmincon options) 418stg.fm_options = optimoptions('fmincon', 'Algorithm', 'interior-point',... 419 'MaxIterations', 10, 'OptimalityTolerance', 0, 'StepTolerance', 1e-6,... 420 'FiniteDifferenceType', 'central', 'MaxFunctionEvaluations', 10000); 421 422% Specifies whether to run simulated annealing (Simulated annealing) 423stg.sa = false; 424 425% Provides options for simulated annealing (Simulated annealing options) 426stg.sa_options = optimoptions(@simulannealbnd, 'MaxTime', stg.optt,... 427 'ReannealInterval', 40); 428 429% Specifies whether to run Pattern search (Pattern search) 430stg.psearch = false; 431 432% Sets options for Pattern search (Pattern search options) 433stg.psearch_options = optimoptions(@patternsearch, 'MaxTime', stg.optt,... 434 'UseParallel', stg.optmc, 'UseCompletePoll', true,... 435 'UseCompleteSearch', true, 'MaxMeshSize',2, ... 436 'MaxFunctionEvaluations', 2000); 437 438% Specifies whether to run Genetic algorithm (Genetic algorithm) 439stg.ga = false; 440 441% Options for Genetic algorithm (Genetic algorithm options) 442stg.ga_options = optimoptions(@ga, 'MaxGenerations', 200, ... 443 'MaxTime', stg.optt,'UseParallel', stg.optmc, ... 444 'PopulationSize', stg.popsize,'MutationFcn', 'mutationadaptfeasible'); 445 446 447% Specifies whether to run Particle swarm (Particle swarm) 448stg.pswarm = false; 449 450% Sets options for Particle swarm (Particle swarm options) 451stg.pswarm_options = optimoptions('particleswarm', 'MaxTime', stg.optt,... 452 'UseParallel', stg.optmc, 'MaxIterations', 200, ... 453 'SwarmSize', stg.popsize); 454 455% Specifies whether to run Surrogate optimization (Surrogate optimization) 456stg.sopt = false; 457 458% Provides options for Surrogate optimization (Surrogate optimization 459% options) 460stg.sopt_options = optimoptions('surrogateopt', 'MaxTime', stg.optt,... 461 'UseVectorized', stg.optmc, 'MaxFunctionEvaluations', 5000,... 462 'MinSampleDistance', 0.2, 'MinSurrogatePoints', 32*2+1); 463endExample settings code
1function [stg] = Example_model() 2 3%% Import 4 5% True or false to decide whether to run import functions 6% (Import) 7stg.import = true; 8 9% Name of the folder where everything related to the model is stored 10% (Folder Model) 11stg.folder_model = "Model_Example"; 12 13% Name of the excel file with the sbtab 14% (SBtab excel name) 15stg.sbtab_excel_name = "SBTAB_Example.xlsx"; 16 17% Name of the model 18% (Name) 19stg.name = "Example"; 20 21% Name of the default model compartment 22% (Compartment name) 23stg.cname = "Compartment"; 24 25% Name of the sbtab saved in .mat format 26% (SBtab name) 27stg.sbtab_name = "SBtab_" + stg.name; 28 29%% Analysis 30 31% Experiments to run 32stg.exprun = [1:4]; 33 34% Choice between 0,1,2 and 3 to change either and how to apply log10 to the 35% scores (check documentation) (Use logarithm) 36stg.useLog = 0; 37 38% True or false to decide whether to use multicore everywhere it is 39% available (Optimization Multicore) 40stg.optmc = false; 41 42% Choice of ramdom seed (Ramdom seed) 43stg.rseed = 1; 44 45% True or false to decide whether to use display simulation diagnostics i 46% the console (Simulation Console) 47stg.simcsl = false; 48 49% True or false to decide whether to display optimization results on 50% console (Optimization console) 51stg.optcsl = true; 52 53% True or false to decide whether to display PLA results on console (PLA 54% console) 55stg.placsl = true; 56 57% True or false to decide whether to save results (Save results) 58stg.save_results = true; 59 60% True or false to decide whether to run detailed simulation for plots 61stg.simdetail = false; 62 63%% Simulation 64 65% Maximum time for each individual function to run in seconds 66% (Maximum time) 67stg.maxt = 2; 68 69% Equilibration time 70% (Equilibration time) 71stg.eqt = 500000; 72 73% True or false to decide whether to do Dimensional Analysis 74% (Dimensional Analysis) 75stg.dimenanal = true; 76 77% True or false to decide whether to do Unit conversion 78% (Unit conversion) 79stg.UnitConversion = true; 80 81% True or false to decide whether to do Absolute Tolerance Scaling 82% (Absolute Tolerance Scaling) 83stg.abstolscale = true; 84 85% Value of Relative tolerance 86% (Relative tolerance) 87stg.reltol = 1.0E-4; 88 89% Value of Absolute tolerance 90% (Absolute tolerance) 91stg.abstol = 1.0E-7; 92 93% Time units for simulation 94% (Simulation time) 95stg.simtime = "second"; 96 97% True or false to decide whether to run sbioaccelerate (after changing this value 98% you need to run "clear functions" to see an effect) 99% (sbioaccelerate) 100stg.sbioacc = false; 101 102% Max step size in the simulation (if empty matlab decides whats best) 103% (Maximum step) 104stg.maxstep = 0.1; 105 106% Max step size in the equilibration (if empty matlab decides whats best) 107% (Maximum step) 108stg.maxstepeq = []; 109 110% Max step size in the detailed plots (if empty matlab decides whats best) 111% (Maximum step) 112stg.maxstepdetail = [2]; 113 114% Default score when there is a simulation error, this is needed to keep 115% the optimizations working. (error score) 116stg.errorscore = 10^5; 117 118%% Model 119 120% Number of parameters to optimize (Parameter number) 121stg.parnum = 12; 122 123% Index for the parameters that have thermodynamic constrains (Termodiamic 124% Constrains Index) 125stg.tci = [8]; 126 127% Parameters to multiply to the first parameter (in Stg.partest to get to 128% the correct thermodynamic constrain formula) (Termodiamic Constrains 129% multipliers) 130stg.tcm([8],1) = [4]; 131stg.tcm([8],2) = [5]; 132stg.tcm([8],3) = [7]; 133 134% Parameters to divide to the first parameter (in Stg.partest to get to the 135% correct thermodynamic constrain formula) (Termodiamic Constrains 136% divisors) 137stg.tcd([8],1) = [1]; 138stg.tcd([8],2) = [3]; 139stg.tcd([8],3) = [6]; 140 141% Array with the lower bound of all parameters (Lower bound) 142stg.lb = zeros(1,stg.parnum)-0; 143 144% Array with the upper bound of all parameters (Upper bound) 145stg.ub = zeros(1,stg.parnum)+1; 146 147%% Diagnostics 148 149% Choice of what parameters in the array to test, the indices correspond to 150% the parameters in the model and the numbers correspond to the parameters 151% in the optimization array, usually not all parameters are optimized so 152% there needs to be a match between one and the other. (Parameters to test) 153stg.partest(:,1) = [1 ,2 ,3 ,4 ,5 ,6 ,7 ,2 ,8 ,9,... 154 10 ,11 ,12]; 155 156% (Parameter array to test) 157stg.pat = 1:3; 158 159% All the parameter arrays, in this case there is only one (Parameter 160% arrays) 161stg.pa(1,:) = [3.999,0.696,1.072,3.429,-0.751,-3.741,-0.569,0.831,3.068,0.921,-2.156,-1.970]; 162stg.pa(2,:) = stg.pa(1,:)-1; 163stg.pa(3,:) = stg.pa(1,:)+1; 164 165% Best parameter array found so far for the model (Best parameter array) 166stg.bestpa = stg.pa(1,:); 167 168%% Plots 169 170% True or false to decide whether to plot results (Plots) 171stg.plot = true; 172 173% True or false to decide whether to use long names in the title of the 174% outputs plots in f_plot_outputs.m (Plot outputs long names) 175stg.plotnames = true; 176 177%% Local Sensitivity analysis 178 179stg.lsa_samples = 360; 180stg.lsa_range_from_best = 1; 181 182%% Global Sensitivity analysis 183 184 185% Number of samples to use in SA (Sensitivity analysis number of samples) 186stg.sansamples = 1000; 187 188% True or false to decide whether to subtract the mean before calculating 189% SI and SIT (Sensitivity analysis subtract mean) 190stg.sasubmean = true; 191 192% Choose the way you want to obtain the samples of the parameters for 193% performing the SA; 0 Log uniform distribution truncated at the parameter 194% bounds 1 Log normal distribution with mu as the best value for a 195% parameter and sigma as stg.sasamplesigma truncated at the parameter 196% bounds 2 same as 1 without truncation 3 Log normal distribution centered 197% at the mean of the parameter bounds and sigma as stg.sasamplesigma 198% truncated at the parameter bounds 4 same as 3 without truncation. 199% (Sensitivity analysis sampling mode) 200stg.sasamplemode = 0; 201 202% Sigma for creating the normal distribution of parameters to perform 203% sensitivity analysis (Sensitivity analysis sampling sigma) 204stg.sasamplesigma = 0.1; 205 206stg.gsabootstrapsize = ceil(sqrt(stg.sansamples)); 207%% Profile Likelihood 208 209% Parameter(optimization array) that is being worked on in a specific 210% iteration of PL (if -1 no parameter is being worked in PL) 211% (Profile Likelihood Index) 212stg.PLind = -1; 213 214% Which parameters to do PL on, it should be all parameters but can also be 215% a subset for testing purposes 216% (Profile Likelihood parameters to Test) 217stg.pltest = (1:12); 218 219% How many points to do for each parameter in the PL 220% (Profile Likelihood Resolution) 221stg.plres = 20; 222 223% True or false to decide whether to do plots after calculating PL 224% (Profile Likelihood Plots) 225stg.plplot = true; 226 227% True or false to decide whether to run simulated annealing 228% (Profile Likelihood Simulated Annealing) 229stg.plsa = true; 230 231% Options for simulated annealing 232stg.plsao = optimoptions(@simulannealbnd,'Display','off', ... 233 'InitialTemperature',... 234 ones(1,stg.parnum)*1,'MaxTime',1,'ReannealInterval',40); 235 236% 0 or 1 to decide whether to run fmincon 237% (Profile Likelihood FMincon) 238stg.plfm = false; 239 240% Options for fmincon 241stg.plfmo = optimoptions('fmincon','Display','off',... 242 'Algorithm','interior-point',... 243 'MaxIterations',5,'OptimalityTolerance',0,... 244 'StepTolerance',1e-6,'FiniteDifferenceType','central'); 245 246%% Optimization 247 248% Time for the optimization in seconds (fmincon does not respect this 249% time!!) (Optimization time) 250stg.optt = 5*1; 251 252% Population size for the algorithms that use populations (Population size) 253stg.popsize = 10; 254 255% optimization start method, choose between: 1 Random starting point or 256% group of starting points inside the bounds 2 Random starting point or 257% group of starting points near the best point (Optimization start method) 258stg.osm = 1; 259 260% Distance from best parameter array to be used in stg.osm method 2 261% (Distance from best parameter array) 262stg.dbs = 0.1; 263 264% True or false to decide whether to use Multistart (Multistart) 265stg.mst = false; 266 267% Multistart size 268stg.msts = 1; 269 270% True or false to decide whether to display Plots (Plots doesn't work if 271% using multicore) (Optimization plots) 272stg.optplots = true; 273 274% True or false to decide whether to run fmincon (no gradient so this 275% doesn't work very well, no max time!!) 276stg.fmincon = false; 277 278% Options for fmincon (fmincon options) 279stg.fm_options = optimoptions('fmincon',... 280 'UseParallel',stg.optmc,... 281 'Algorithm','interior-point',... 282 'MaxIterations',2,'OptimalityTolerance',0,... 283 'StepTolerance',1e-6,'FiniteDifferenceType','central',... 284 'MaxFunctionEvaluations',10000); 285 286% True or false to decide whether to run simulated annealing (Simulated 287% annealing) 288stg.sa = false; 289 290% Options for simulated annealing (Simulated annealing options) 291stg.sa_options = optimoptions(@simulannealbnd, ... 292 'MaxTime',stg.optt,... 293 'InitialTemperature',... 294 ones(1,stg.parnum)*2,'ReannealInterval',40); 295 296% True or false to decide whether to run Pattern search (Pattern search) 297stg.psearch = false; 298 299% Options for Pattern search (Pattern search options) 300stg.psearch_options = optimoptions(@patternsearch,... 301 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 302 'UseCompletePoll',true,'UseCompleteSearch',true,... 303 'MaxMeshSize',2,'MaxFunctionEvaluations',2000); 304 305% True or false to decide whether to run Genetic algorithm (Genetic 306% algorithm) 307stg.ga = true; 308 309% Options for Genetic algorithm (Genetic algorithm options) 310stg.ga_options = optimoptions(@ga,'MaxGenerations',200,... 311 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 312 'PopulationSize',stg.popsize,... 313 'MutationFcn','mutationadaptfeasible','Display','diagnose'); 314 315% True or false to decide whether to run Particle swarm (Particle swarm) 316stg.pswarm = false; 317 318% Options for Particle swarm (Particle swarm options) 319stg.pswarm_options = optimoptions('particleswarm',... 320 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 321 'SwarmSize',stg.popsize); 322 323% True or false to decide whether to run Surrogate optimization (Surrogate 324% optimization) 325stg.sopt = false; 326 327% Options for Surrogate optimization (Surrogate optimization options) 328stg.sopt_options = optimoptions('surrogateopt',... 329 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 330 'MaxFunctionEvaluations',5000,... 331 'MinSampleDistance',0.2,'MinSurrogatePoints',32*2+1); 332end
Import
Default settings code
Example settings code
1% True or false to decide whether to run import functions 2% (Import) 3stg.import = true; 4 5% Name of the folder where everything related to the model is stored 6% (Folder Model) 7stg.folder_model = "Model_Example"; 8 9% Name of the excel file with the sbtab 10% (SBtab excel name) 11stg.sbtab_excel_name = "SBTAB_Example.xlsx"; 12 13% Name of the model 14% (Name) 15stg.name = "Example"; 16 17% Name of the default model compartment 18% (Compartment name) 19stg.cname = "Compartment"; 20 21% Name of the sbtab saved in .mat format 22% (SBtab name) 23stg.sbtab_name = "SBtab_" + stg.name;
stg.import - (logical) Decide whether to run import functions
stg.sbtab_excel_name - (string) Name of the Excel file with the SBtab
stg.name - (string) Name of the model
stg.cname - (string) Name of the default model compartment
stg.sbtab_name - (string) Name of the SBtab saved in .mat format
Analysis
Default settings code
1% Lists experiments to run (example experiment 1 to 3 and experimet 6) 2stg.exprun = [1:3,6]; 3 4% Determines the scoring method choice (check documentation) (Use 5% logarithm) 6stg.useLog = 4; 7 8% Specifies whether to use multicore wherever available (Optimization 9% Multicore) 10stg.optmc = true; 11 12% Sets the random seed value (Ramdom seed) 13stg.rseed = 1; 14 15% Indicates whether to display simulation diagnostics in the console 16% (Simulation Console) 17stg.simcsl = false; 18 19% Specifies whether to display optimization results in the console 20% (Optimization console) 21stg.optcsl = false; 22 23% Specifies whether to save results (Save results) 24stg.save_results = true; 25 26% Specifies whether to run detailed simulation for plots 27stg.simdetail = true;Example settings code
1% Experiments to run 2stg.exprun = [1:4]; 3 4% Choice between 0,1,2 and 3 to change either and how to apply log10 to the 5% scores (check documentation) (Use logarithm) 6stg.useLog = 0; 7 8% True or false to decide whether to use multicore everywhere it is 9% available (Optimization Multicore) 10stg.optmc = false; 11 12% Choice of ramdom seed (Ramdom seed) 13stg.rseed = 1; 14 15% True or false to decide whether to use display simulation diagnostics i 16% the console (Simulation Console) 17stg.simcsl = false; 18 19% True or false to decide whether to display optimization results on 20% console (Optimization console) 21stg.optcsl = true; 22 23% True or false to decide whether to display PLA results on console (PLA 24% console) 25stg.placsl = true; 26 27% True or false to decide whether to save results (Save results) 28stg.save_results = true; 29 30% True or false to decide whether to run detailed simulation for plots 31stg.simdetail = false;
stg.exprun - (double) Experiments to run
stg.useLog - (double) Choice between 0,1,2 and 3 to change either and how to apply log10 to the scores, check results:
stg.optmc - (logical) Decide whether to use multicore everywhere it is available
stg.rseed - (double) Choice of random seed
stg.simcsl - (logical) Decide whether to display simulation diagnostics in the console
stg.optcsl - (logical) Decide whether to display optimization results on console
stg.save_results - (logical) Decide whether to save results
stg.simdetail - (logical) Decide whether to run detailed simulation for plots
Simulation
Default settings code
1% Sets the maximum time for each individual function to run in seconds 2% (Maximum time) 3stg.maxt = 10; 4 5% Defines the equilibration time (Equilibration time) 6stg.eqt = 50000; 7 8% Specifies whether to perform Dimensional Analysis (Dimensional Analysis) 9stg.dimenanal = false; 10 11% Specifies whether to perform Unit conversion (Unit conversion) 12stg.UnitConversion = false; 13 14% Specifies whether to apply Absolute Tolerance Scaling (Absolute Tolerance 15% Scaling) 16stg.abstolscale = true; 17 18% Assigns the value of Relative tolerance (Relative tolerance) 19stg.reltol = 1.0E-4; 20 21% Assigns the value of Absolute tolerance (Absolute tolerance) 22stg.abstol = 1.0E-4; 23 24% Specifies the time units for simulation (Simulation time) 25stg.simtime = "second"; 26 27% Specifies whether to run sbioaccelerate (after changing this value you 28% need to run "clear functions" to see an effect) (sbioaccelerate) 29stg.sbioacc = true; 30 31% Provides the absolute tolerance step size for equilibration (Absolute 32% tolerance step size for equilibration) 33stg.abstolstepsize_eq = []; 34 35% Max step size in the simulation (if empty matlab decides whats best) 36% (Maximum step) 37stg.maxstep = 10; 38 39% Sets the max step size in the simulation (if empty, Matlab decides what's 40% best) (Maximum step) 41stg.maxstepeq = 2; 42 43% Sets the max step size in the detailed plots (if empty, Matlab decides 44% what's best) (Maximum step) 45stg.maxstepdetail = 2; 46 47% Specifies the default score when there is a simulation error, required to 48% keep optimizations working (error score) 49stg.errorscore = 10^5;Example settings code
1% Maximum time for each individual function to run in seconds 2% (Maximum time) 3stg.maxt = 2; 4 5% Equilibration time 6% (Equilibration time) 7stg.eqt = 500000; 8 9% True or false to decide whether to do Dimensional Analysis 10% (Dimensional Analysis) 11stg.dimenanal = true; 12 13% True or false to decide whether to do Unit conversion 14% (Unit conversion) 15stg.UnitConversion = true; 16 17% True or false to decide whether to do Absolute Tolerance Scaling 18% (Absolute Tolerance Scaling) 19stg.abstolscale = true; 20 21% Value of Relative tolerance 22% (Relative tolerance) 23stg.reltol = 1.0E-4; 24 25% Value of Absolute tolerance 26% (Absolute tolerance) 27stg.abstol = 1.0E-7; 28 29% Time units for simulation 30% (Simulation time) 31stg.simtime = "second"; 32 33% True or false to decide whether to run sbioaccelerate (after changing this value 34% you need to run "clear functions" to see an effect) 35% (sbioaccelerate) 36stg.sbioacc = false; 37 38% Max step size in the simulation (if empty matlab decides whats best) 39% (Maximum step) 40stg.maxstep = 0.1; 41 42% Max step size in the equilibration (if empty matlab decides whats best) 43% (Maximum step) 44stg.maxstepeq = []; 45 46% Max step size in the detailed plots (if empty matlab decides whats best) 47% (Maximum step) 48stg.maxstepdetail = [2]; 49 50% Default score when there is a simulation error, this is needed to keep 51% the optimizations working. (error score) 52stg.errorscore = 10^5;
stg.maxt - (double) Maximum time for each individual function has to run in seconds
stg.eqt - (double) Equilibration time in seconds
stg.dimenanal - (logical) Decide whether to do Dimensional Analysis
stg.UnitConversion - (logical) Decide whether to do Unit conversion
stg.abstolscale - (logical) Decide whether to do Absolute Tolerance Scaling
stg.reltol - (double) Value of Relative tolerance
stg.abstol - (double) Value of Absolute tolerance
stg.simtime - (string) Time units for simulation
stg.sbioacc - (logical) Decide whether to run sbioaccelerate (after changing this value you need to run “clear functions” to see an effect)
stg.abstolstepsize_eq - (double) Absolute tolerance step size for equilibration (if empty MATLAB® decides whats best)
stg.maxstep - (double) Max step size in the simulation (if empty MATLAB® decides what’s best)
stg.maxstepeq - (double) Max step size in the equilibration (if empty MATLAB® decides whats best)
stg.maxstepdetail - (double) Max step size in the detailed plots (if empty MATLAB® decides whats best)
stg.errorscore - (double) Default score when there is a simulation error, this is needed to keep the optimizations working.
Model
Default settings code
1% Specifies the number of parameters to optimize (Parameter number) 2stg.parnum = 5; 3 4% Provides the array with the lower bound of all parameters 5original_parameter_set = zeros(1,10); 6 7% Assigns the array with the lower bound of all parameters (Lower bound) 8stg.lb = original_parameter_set-5; 9 10% Assigns the array with the upper bound of all parameters (Upper bound) 11stg.ub = original_parameter_set+5;Example settings code
1% Number of parameters to optimize (Parameter number) 2stg.parnum = 12; 3 4% Index for the parameters that have thermodynamic constrains (Termodiamic 5% Constrains Index) 6stg.tci = [8]; 7 8% Parameters to multiply to the first parameter (in Stg.partest to get to 9% the correct thermodynamic constrain formula) (Termodiamic Constrains 10% multipliers) 11stg.tcm([8],1) = [4]; 12stg.tcm([8],2) = [5]; 13stg.tcm([8],3) = [7]; 14 15% Parameters to divide to the first parameter (in Stg.partest to get to the 16% correct thermodynamic constrain formula) (Termodiamic Constrains 17% divisors) 18stg.tcd([8],1) = [1]; 19stg.tcd([8],2) = [3]; 20stg.tcd([8],3) = [6]; 21 22% Array with the lower bound of all parameters (Lower bound) 23stg.lb = zeros(1,stg.parnum)-0; 24 25% Array with the upper bound of all parameters (Upper bound) 26stg.ub = zeros(1,stg.parnum)+1;
stg.parnum - (double) Number of parameters to optimize
stg.tci - (double) Index for the parameters that have thermodynamic constraints
stg.tcm - (double) Parameters to multiply to the first parameter (in stg.partest to get to the correct thermodynamic constraint formula)
stg.tcd - (double) Parameters to divide to the first parameter (in stg.partest to get to the correct thermodynamic constraint formula)
stg.lb - (double) Lower bound of all parameters
\[stg.lb = \begin{bmatrix} lb_{1} & lb_{2} & ... & lb_{i} \end{bmatrix}\]\(i =\) Parameter index
stg.ub - (double) Upper bound of all parameters
\[stg.up = \begin{bmatrix} ub_{1} & ub_{2} & ... & ub_{i} \end{bmatrix}\]\(i =\) Parameter index
Diagnostics
Default settings code
1% Choice of what parameters in the array to test, the indices correspond to 2% the parameters in the model and the numbers correspond to the parameters 3% in the optimization array, usually not all parameters are optimized so 4% there needs to be a match between one and the other. (Parameters to test) 5% In this example there are ten parameters in this imaginary model and we 6% are only interested in parameter 2,4,8,9, and 10. Note that stg.parnum is 7% five because of this and not ten 8stg.partest(:,1) = [0,1,0,2,0,0,0,3,4,5]; 9 10% Defines the parameter array to test (Parameter array to test) 11stg.pat = 1:2; 12 13% Contains all the parameter arrays (parameters here are in log10 space) 14% (Parameter arrays) 15stg.pa(1,:) = [1,1,1,1,1]; 16stg.pa(1,:) = [1,0,1,2,1]; 17 18% Provides the best parameter array found so far for the model (Best 19% parameter array) 20stg.bestpa = stg.pa(1,:);Example settings code
1% Choice of what parameters in the array to test, the indices correspond to 2% the parameters in the model and the numbers correspond to the parameters 3% in the optimization array, usually not all parameters are optimized so 4% there needs to be a match between one and the other. (Parameters to test) 5stg.partest(:,1) = [1 ,2 ,3 ,4 ,5 ,6 ,7 ,2 ,8 ,9,... 6 10 ,11 ,12]; 7 8% (Parameter array to test) 9stg.pat = 1:3; 10 11% All the parameter arrays, in this case there is only one (Parameter 12% arrays) 13stg.pa(1,:) = [3.999,0.696,1.072,3.429,-0.751,-3.741,-0.569,0.831,3.068,0.921,-2.156,-1.970]; 14stg.pa(2,:) = stg.pa(1,:)-1; 15stg.pa(3,:) = stg.pa(1,:)+1; 16 17% Best parameter array found so far for the model (Best parameter array) 18stg.bestpa = stg.pa(1,:);
stg.partest - (double) Choice of which parameters to work on, since depending on the task, not all SBtab parameters are worked on. k indices correspond to the parameters in the SBtab and numbers up to i correspond to the parameters in the work set. This is the set that actually gets used for diagnostics, optimization, and sensitivity analyis.
\[stg.partest_k = \begin{bmatrix} 1_{k_1} & 2_{k_2} & ... & i_{k_{end}} \end{bmatrix}\]In our example model parameter 216 from the SBtab is parameter number 1 of the work set, parameter 217 from the SBtab is parameter number 2 of the work set, and successively.
\[stg.partest_{[216:227]} = \begin{bmatrix} 1_{216} & 2_{217} & ... & 6_{221} & 1_{222} & 2_{223} & ... & 6_{227} \end{bmatrix}\]stg.pat - (double) Index(\(j\)) of the parameter set to work on
stg.pa - (double) All the parameter sets
\[\begin{split}stg.pa = \begin{bmatrix} x_{1,1} & x_{2,1} & ... & x_{i,1} \\ x_{1,2} & x_{2,2} & ... & x_{i,2} \\ ... & ... & ... & ... \\ x_{1,j} & x_{2,j} & ... & x_{i,j} \end{bmatrix}\end{split}\]stg.bestpa - (double) Best parameter set found so far during optimization
\[stg.bestx = \begin{bmatrix} bestx_{1} & bestx_{2} & ... & bestx_{i} \end{bmatrix}\]\(x =\) Parameters being worked on
\(i =\) Index of Parameters being worked on
\(k =\) Index of the parameters in SBtab
\(j =\) Index of the Parameter set to work on
Plots
Default settings code
1% Specifies whether to plot results (Plots) 2stg.plot = true; 3 4% Specifies whether to use long names in the title of the output plots in 5% f_plot_outputs.m (Plot outputs long names) 6stg.plotoln = true;Example settings code
stg.plot - (logical) Decide whether to plot results
stg.plotoln - (logical) Decide whether to use long names in the title of the output plots in f_plot_outputs.m
Global Sensitivity Analysis (GSA)
Default settings code
1% Sets the number of samples to use in Sensitivity Analysis (Sensitivity 2% analysis number of samples) 3stg.sansamples = 100; 4 5% Specifies whether to subtract the mean before calculating SI and SIT in 6% Sensitivity Analysis (Sensitivity analysis subtract mean) 7stg.sasubmean = true; 8 9% Determines the sampling mode for Sensitivity Analysis; 0 Log uniform 10% distribution truncated at the parameter bounds 1 Log normal distribution 11% with mu as the best value for a parameter and sigma as stg.sasamplesigma 12% truncated at the parameter bounds 2 same as 1 without truncation 3 Log 13% normal distribution centered at the mean of the parameter bounds and 14% sigma as stg.sasamplesigma truncated at the parameter bounds 4 same as 3 15% without truncation. (Sensitivity analysis sampling mode) 16stg.sasamplemode = 2; 17 18% Defines the sigma for creating the normal distribution of parameters to 19% perform Sensitivity Analysis (Sensitivity analysis sampling sigma) 20stg.sasamplesigma = 0.1; 21 22%% Profile Likelihood 23 24% Parameter(optimization array) that is being worked on in a specific 25% iteration of PL (if -1 no parameter is being worked in PL) 26% (Profile Likelihood Index) 27stg.PLind = -1; 28 29% Which parameters to do PL on, it should be all parameters but can also be 30% a subset for testing purposes 31% (Profile Likelihood parameters to Test) 32stg.pltest = (1:6); 33 34% How many points to do for each parameter in the PL 35% (Profile Likelihood Resolution) 36stg.plres = 50; 37 38% True or false to decide whether to do plots after calculating PL 39% (Profile Likelihood Plots) 40stg.plplot = true; 41 42% True or false to decide whether to run simulated annealing 43% (Profile Likelihood Simulated Annealing) 44stg.plsa = false; 45 46% Options for simulated annealing 47stg.plsao = optimoptions(@simulannealbnd,'Display','off', ... 48 'InitialTemperature',... 49 ones(1,stg.parnum-1)*1,'MaxTime',7,'ReannealInterval',40); 50 51% stg.plsao = optimoptions(@patternsearch,... 52% 'MaxTime',25,'UseParallel',false,... 53% 'UseCompletePoll',true,'UseCompleteSearch',true,... 54% 'MaxMeshSize',2,'MaxFunctionEvaluations',2000); 55 56% True or false to decide whether to run fmincon 57% (Profile Likelihood FMincon) 58stg.plfm = false; 59 60% Options for fmincon 61stg.plfmo = optimoptions('fmincon','Display','off',... 62 'Algorithm','interior-point',... 63 'MaxIterations',2,'OptimalityTolerance',0,... 64 'StepTolerance',1e-6,'FiniteDifferenceType','central'); 65 66 67% True or false to decide whether to run Pattern search 68% (Pattern search) 69stg.plps = false; 70 71% Options for Pattern search 72% (Pattern search options) 73stg.plpso = optimoptions(@patternsearch,'Display','off',... 74 'MaxTime',7,... 75 'UseCompletePoll',true,'UseCompleteSearch',true,... 76 'MaxMeshSize',1,'MaxFunctionEvaluations',10000);Example settings code
stg.sansamples - (double) Number of samples to use in GSA (in total (2+npars)*sansamples simulations will be performed, where npars are the number of parameters).
stg.sasubmean - (logical) Decide whether to subtract mean before calculating SI and STI, see Halnes et al 2009.
stg.sasamplemode - (double) Choose the way you want to obtain the samples of the parameters for performing the GSA;
Reciprocal (log uniform) distribution
\(X_{i} \sim Reciprocal(a_{i},b_{i})\)
\(i =\) Parameter index
\(a_{i} = stg.lb_{i}\)
\(b_{i} = stg.ub_{i}\)
Example distribution with \(a = -1, b = 1\)
Log normal distribution with μ corresponding to the best value for a parameter, as recieved from the optimization, and σ as stg.sasamplesigma truncated at the parameter bounds
\(X_{i} \sim TruncatedLogNormal(μ_{i}, σ, a_{i}, b_{i})\)
\(i =\) Parameter index
\(μ_{i} = bestx_{i}\)
\(σ = stg.sasamplesigma\)
\(a_{i} = stg.lb_{i}\)
\(b_{i} = stg.ub_{i}\)
Example distribution with \(μ = 0.5, σ = 1, a = -1, b = 1\)
same as 1 without truncation
\(X_{i} \sim LogNormal(μ, σ)\)
\(i =\) Parameter index
\(μ_{i} = bestx_{i}\)
\(σ = stg.sasamplesigma\)
Example distribution with \(μ = 0.5, σ = 1\)
Log normal distribution with μ corresponding to the mean of the parameter bounds and σ as stg.sasamplesigma but truncated at the parameter bounds
\(X_{i} \sim TruncatedLogNormal(μ_{i}, σ, a_{i}, b_{i})\)
\(i =\) Parameter index
\(μ_{i} = \frac{stg.lb_{i} + (stg.ub_{i} - stg.lb_{i})}{2}\)
\(σ = stg.sasamplesigma\)
\(a_{i} = stg.lb_{i}\)
\(b_{i} = stg.ub_{i}\)
Example distribution with \(μ = \frac{a+(b-a)}{2}, σ = 1, a = -1, b = 1\)
same as 3 without truncation.
\(X_{i} \sim LogNormal(mu_{i}, σ)\)
\(i =\) Parameter index
\(μ_{i} = \frac{stg.lb_{i} + (stg.ub_{i} - stg.lb_{i})}{2}\)
\(σ = stg.sasamplesigma\)
Example distribution with \(μ = \frac{a+(b-a)}{2}, σ = 1, a = -1, b = 1\)
stg.sasamplesigma - (double) σ for creating the normal distribution of parameters to perform sensitivity analysis
Optimization
Default settings code
1% Sets the time for the optimization in seconds (fmincon does not respect 2% this time!!) (Optimization time) 3stg.optt = 60*5; 4 5% Defines the population size for the algorithms that use populations 6% (Population size) 7stg.popsize = 144; 8 9% Chooses the optimization start method: 1 for random starting point(s) 10% inside bounds, 2 for random starting point(s) near the best point 11% (Optimization start method) 12stg.osm = 1; 13 14% Specifies the distance from the best parameter array to be used in 15% stg.osm method 2 (Distance from best parameter array) 16stg.dbs = 0.1; 17 18% Specifies whether to use Multistart (Multistart) 19stg.mst = false; 20 21% Provides the Multistart size 22stg.msts = 1; 23 24% Specifies whether to display Plots (Plots don't work if using multistart) 25% (Optimization plots) 26stg.optplots = true; 27 28% Indicates whether to run fmincon (no gradient, so this doesn't work well; 29% no max time!!) (fmincon) 30stg.fmincon = false; 31 32% Sets options for fmincon (fmincon options) 33stg.fm_options = optimoptions('fmincon', 'Algorithm', 'interior-point',... 34 'MaxIterations', 10, 'OptimalityTolerance', 0, 'StepTolerance', 1e-6,... 35 'FiniteDifferenceType', 'central', 'MaxFunctionEvaluations', 10000); 36 37% Specifies whether to run simulated annealing (Simulated annealing) 38stg.sa = false; 39 40% Provides options for simulated annealing (Simulated annealing options) 41stg.sa_options = optimoptions(@simulannealbnd, 'MaxTime', stg.optt,... 42 'ReannealInterval', 40); 43 44% Specifies whether to run Pattern search (Pattern search) 45stg.psearch = false; 46 47% Sets options for Pattern search (Pattern search options) 48stg.psearch_options = optimoptions(@patternsearch, 'MaxTime', stg.optt,... 49 'UseParallel', stg.optmc, 'UseCompletePoll', true,... 50 'UseCompleteSearch', true, 'MaxMeshSize',2, ... 51 'MaxFunctionEvaluations', 2000); 52 53% Specifies whether to run Genetic algorithm (Genetic algorithm) 54stg.ga = false; 55 56% Options for Genetic algorithm (Genetic algorithm options) 57stg.ga_options = optimoptions(@ga, 'MaxGenerations', 200, ... 58 'MaxTime', stg.optt,'UseParallel', stg.optmc, ... 59 'PopulationSize', stg.popsize,'MutationFcn', 'mutationadaptfeasible'); 60 61 62% Specifies whether to run Particle swarm (Particle swarm) 63stg.pswarm = false; 64 65% Sets options for Particle swarm (Particle swarm options) 66stg.pswarm_options = optimoptions('particleswarm', 'MaxTime', stg.optt,... 67 'UseParallel', stg.optmc, 'MaxIterations', 200, ... 68 'SwarmSize', stg.popsize); 69 70% Specifies whether to run Surrogate optimization (Surrogate optimization) 71stg.sopt = false; 72 73% Provides options for Surrogate optimization (Surrogate optimization 74% options) 75stg.sopt_options = optimoptions('surrogateopt', 'MaxTime', stg.optt,... 76 'UseVectorized', stg.optmc, 'MaxFunctionEvaluations', 5000,... 77 'MinSampleDistance', 0.2, 'MinSurrogatePoints', 32*2+1); 78endExample settings code
1% Time for the optimization in seconds (fmincon does not respect this 2% time!!) (Optimization time) 3stg.optt = 5*1; 4 5% Population size for the algorithms that use populations (Population size) 6stg.popsize = 10; 7 8% optimization start method, choose between: 1 Random starting point or 9% group of starting points inside the bounds 2 Random starting point or 10% group of starting points near the best point (Optimization start method) 11stg.osm = 1; 12 13% Distance from best parameter array to be used in stg.osm method 2 14% (Distance from best parameter array) 15stg.dbs = 0.1; 16 17% True or false to decide whether to use Multistart (Multistart) 18stg.mst = false; 19 20% Multistart size 21stg.msts = 1; 22 23% True or false to decide whether to display Plots (Plots doesn't work if 24% using multicore) (Optimization plots) 25stg.optplots = true; 26 27% True or false to decide whether to run fmincon (no gradient so this 28% doesn't work very well, no max time!!) 29stg.fmincon = false; 30 31% Options for fmincon (fmincon options) 32stg.fm_options = optimoptions('fmincon',... 33 'UseParallel',stg.optmc,... 34 'Algorithm','interior-point',... 35 'MaxIterations',2,'OptimalityTolerance',0,... 36 'StepTolerance',1e-6,'FiniteDifferenceType','central',... 37 'MaxFunctionEvaluations',10000); 38 39% True or false to decide whether to run simulated annealing (Simulated 40% annealing) 41stg.sa = false; 42 43% Options for simulated annealing (Simulated annealing options) 44stg.sa_options = optimoptions(@simulannealbnd, ... 45 'MaxTime',stg.optt,... 46 'InitialTemperature',... 47 ones(1,stg.parnum)*2,'ReannealInterval',40); 48 49% True or false to decide whether to run Pattern search (Pattern search) 50stg.psearch = false; 51 52% Options for Pattern search (Pattern search options) 53stg.psearch_options = optimoptions(@patternsearch,... 54 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 55 'UseCompletePoll',true,'UseCompleteSearch',true,... 56 'MaxMeshSize',2,'MaxFunctionEvaluations',2000); 57 58% True or false to decide whether to run Genetic algorithm (Genetic 59% algorithm) 60stg.ga = true; 61 62% Options for Genetic algorithm (Genetic algorithm options) 63stg.ga_options = optimoptions(@ga,'MaxGenerations',200,... 64 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 65 'PopulationSize',stg.popsize,... 66 'MutationFcn','mutationadaptfeasible','Display','diagnose'); 67 68% True or false to decide whether to run Particle swarm (Particle swarm) 69stg.pswarm = false; 70 71% Options for Particle swarm (Particle swarm options) 72stg.pswarm_options = optimoptions('particleswarm',... 73 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 74 'SwarmSize',stg.popsize); 75 76% True or false to decide whether to run Surrogate optimization (Surrogate 77% optimization) 78stg.sopt = false; 79 80% Options for Surrogate optimization (Surrogate optimization options) 81stg.sopt_options = optimoptions('surrogateopt',... 82 'MaxTime',stg.optt,'UseParallel',stg.optmc,... 83 'MaxFunctionEvaluations',5000,... 84 'MinSampleDistance',0.2,'MinSurrogatePoints',32*2+1); 85end
stg.optt - (double) Time for the optimization in seconds (fmincon does not respect this time!!)
stg.popsize - (double) Population size (for the algorithms that use populations)
stg.osm - (double) optimization start method, choose between
Get a random starting parameter set or group of starting parameter sets inside the bounds
Get a random starting parameter set or group of starting parameter sets near the best parameter set
stg.dbpa - (double) Distance from best parameter set to be used in stg.osm method 2
stg.mst - (logical) Decide whether to use one or multiple starting parameter sets for the optimization
stg.msts - (double) Number of starting parameter sets for the optimizations
stg.optplots - (logical) Decide whether to display optimiazation plots (They aren’t ploted if running the code in multicore)
stg.fmincon - (logical) Decide whether to run fmincon (no gradient in our models so this doesn’t work very well, does not respect time set for the optimization!!)
stg.fm_options - (optim.options.Fmincon) Options for fmincon
stg.sa - (logical) Decide whether to run simulated annealing
stg.sa_options - (optim.options.SimulannealbndOptions) Options for simulated annealing
stg.psearch - (logical) Decide whether to run Pattern search
stg.psearch_options - (optim.options.PatternsearchOptions) Options for Pattern search
stg.ga - (logical) Decide whether to run Genetic algorithm
stg.ga_options - (optim.options.GaOptions) Options for Genetic algorithm
stg.pswarm - (logical) Decide whether to run Particle swarm
stg.pswarm_options - (optim.options.Particleswarm) Options for Particle swarm
stg.sopt - (logical) Decide whether to run Surrogate optimization
stg.sopt_options - (optim.options.Surrogateopt) Options for Surrogate optimization
Automatically generated at Import
stg.expn - (double) Total number of experiments stored in the SBtab
stg.outn - (double) Total number of experimental outputs specified in the SBtab