58 config = model.Config;
59 if ~isa(config,
" models.muscle.AExperimentModelConfig ")
60 error(
" 'config' parameter must be a AExperimentModelConfig ");
65 this.
RunParallel= exist(
" matlabpool ",
" file ") == 2;
76 key = [mu; nr; m.Geo.NumElements; m.Config.FEM.GaussPointsPerElem];
81 data = this.
cache.getData(key);
85 this.
Config.CurrentConfigNr= nr;
102 out = NaN(1,c.NumOutputs);
106 c.CurrentConfigNr= nr;
111 [
t,y,ct] = m.simulate(mu);
115 out = c.getOutputOfInterest(
t,y);
120 key = [mu; nr; m.Geo.NumElements; c.FEM.GaussPointsPerElem];
121 data =
struct(
" y ",y,
" t ",
t,
" mu ",mu,
" nr ",nr,
" ct ",ct,
" out ",out);
122 this.
cache.addData(key,data);
146 out = zeros(c.NumConfigurations,c.NumOutputs);
147 ct = zeros(c.NumConfigurations,1);
150 fprintf(
" Running %d experiment configurations in parallel...\n ",c.NumConfigurations);
151 closeafterrun =
false;
152 if matlabpool(
" size ") == 0
154 closeafterrun =
true;
156 parfor nr = 1:c.NumConfigurations
157 t = getCurrentTask();
158 fprintf(
" Worker %d: Running configuration %d\n ",
t.ID,nr);
167 if ~this.multipleexperiments
168 pi =
ProcessIndicator(
" Running experiment configurations ",c.NumConfigurations);
170 for nr = 1:c.NumConfigurations
172 if ~this.multipleexperiments
176 if ~this.multipleexperiments
193 allout = zeros(c.NumConfigurations,c.NumOutputs,nex);
194 allct = zeros(c.NumConfigurations,nex);
198 closeafterrun =
false;
199 if matlabpool(
" size ") == 0
201 closeafterrun =
true;
203 fprintf(
" Running %d experiments (%d configs each) in parallel...\n ",nex,c.NumConfigurations);
205 t = getCurrentTask();
206 fprintf(
" Worker %d: Running experiment %d\n ",t.ID,k);
215 pi =
ProcessIndicator(
" Running experiment configurations (%d each) for %d parameters ",...
216 nex,
false,c.NumConfigurations,nex);
224 allout =
permute(allout,[3 1 2]);
238 fi = fullfile(c.OutputDir,[c.getOptionStr
" .mat "]);
239 if ~(exist(fi,
" file ") == 2)
245 save(fi,
" m ",
" o ",
" c ",
" ct ",
" e ");
249 save(fi,
" m ",
" o ",
" c ",
" mus ",
" ct ",
" e ");
257 #if 0 //mtoc++: 'set.StoreExperimentData'
259 if value && isempty(this.
cache)
260 dir = fullfile(this.
Config.OutputDir," trajectories ",this.
Config.getOptionStr(false));
261 this.
cache= data.FileDataCollection(dir);
262 this.
cache.KeepFiles= true;
263 elseif ~isempty(value) && ~value
273 #if 0 //mtoc++: 'get.StoreExperimentData'
function [ out , matrix< double > y , ct ] = runExperimentConfig(nr,colvec< double > mu)
Runs a single experiment configuration. Coded here for convenience only.
The base class for any KerMor detailed model.
models.BaseFirstOrderSystem System
The actual dynamical system used in the model.
function setConfig(mu, inputidx)
Sets the dynamical system's configuration.
ExperimentRunner(models.BaseFullModel model)
Matlab's base handle class (documentation generation substitute)
integer DefaultInput
The default input to use if none is given.
permute
Rearranges the dimensions of the handle object array. See the MATLAB permute function.
colvec< double > DefaultMu
The default parameter value if none is given.
function [ out , matrix< double > y , ct ] = getCachedExperimentConfig(nr,colvec< double > mu)
function [ allout , allct ] = runExperiments(mus)
Runs the experiments in parallel for all given mu values.
function [ out , ct ] = runExperiment(colvec< double > mu)
Runs the complete set of experiments for a given parameter mu.
ProcessIndicator: A simple class that indicates process either via waitbar or text output...
Model: Model for a FEM-discretized muscle model.
function res = runExperimentsCached(mus)