LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
SolverOptions.m
1function options = SolverOptions(solverName)
2% SOLVEROPTIONS Create solver configuration options structure
3%
4% @brief Creates a configuration structure with solver-specific default options
5% @param solverName Optional solver name for specific configurations (default: 'Solver')
6% @return options Struct containing solver configuration parameters
7%
8% SolverOptions generates a standardized options structure for configuring
9% LINE solvers. It provides default values for common parameters like
10% convergence tolerances, iteration limits, ODE solvers, and solver-specific
11% settings. The function customizes defaults based on the solver type.
12%
13% Common options include:
14% - Convergence parameters (tol, iter_tol, iter_max)
15% - Analysis parameters (samples, seed, cutoff)
16% - Language selection (MATLAB vs Java)
17% - ODE solver configuration for fluid methods
18% - Verbosity and caching controls
19% - Solver-specific configuration overrides
20%
21% Solver-specific customizations are available for:
22% - CTMC: State space generation and transient analysis
23% - Fluid: ODE solver selection and timespan
24% - JMT: Simulation parameters and confidence intervals
25% - MVA: Method selection and approximation settings
26% - SSA: Sampling and parallel execution options
27%
28% Example:
29% @code
30% opts = SolverOptions('MVA'); % MVA-specific defaults
31% opts.method = 'exact'; % Override method
32% opts.iter_tol = 1e-6; % Tighter tolerance
33% solver = SolverMVA(model, opts); % Use custom options
34% @endcode
35
36if nargin < 1
37 solverName = 'Solver'; % global options unless overridden by a solver
38end
39
40%% Solver default options
41options = struct();
42options.cache = true;
43options.cutoff = Inf;
44options.config = struct(); % solver specific options
45options.config.highvar = 'default';
46options.config.multiserver = 'default';
47options.config.np_priority = 'default';
48options.config.fork_join = 'default';
49% see _kb/05-solvers-overview.md for rationale
50options.config.fj_warmstart = true;
51options.config.nonmkv = 'bernstein'; % Method for non-Markovian distribution conversion: 'none', 'bernstein'
52options.config.nonmkvorder = 20; % Order (number of phases) for non-Markovian distribution approximation
53% see _kb/05-solvers-overview.md for rationale
54options.config.symbolic = 'auto';
55options.config.symbolic_timeout = 300; % seconds per symbolic request
56global LINEDefaultLang
57if ~isempty(LINEDefaultLang)
58 options.lang = LINEDefaultLang;
59else
60 options.lang = 'matlab';
61end
62options.force = false;
63options.init_sol = [];
64options.iter_max = 1000;
65options.iter_tol = 1e-4; % convergence tolerance to stop iterations
66options.tol = 1e-4; % tolerance for all other uses
67options.keep = true;
68options.method = 'default';
69%options.remote = false;
70%options.remote_endpoint = '127.0.0.1';
71
72odesfun = struct();
73odesfun.fastOdeSolver = @ode23;
74%odesfun.fastOdeSolver = @lsoda_fast;
75odesfun.accurateOdeSolver = @ode113;
76%odesfun.accurateOdeSolver = @lsoda_accurate;
77odesfun.fastStiffOdeSolver = @ode23s;
78%odesfun.fastStiffOdeSolver = @lsoda_fast_stiff;
79odesfun.accurateStiffOdeSolver = @ode15s;
80%odesfun.accurateStiffOdeSolver = @lsoda_accurate_stiff;
81options.odesolvers = odesfun;
82
83% see _kb/05-solvers-overview.md for rationale (samples vs events semantics)
84options.samples = 1e4;
85% see _kb/05-solvers-overview.md for rationale (samples vs events semantics)
86options.events = NaN;
87options.seed = randi([1,1e6]);
88options.stiff = true;
89options.confint = false; % confidence interval: false, true (95%), or level (0.0-1.0)
90options.timespan = [Inf,Inf];
91options.timestep = [];
92% see _kb/05-solvers-overview.md for rationale (wall-clock, not simulated time)
93options.timeout = Inf;
94options.verbose = VerboseLevel.STD;
95
96options.config.num_cdf_pts = 200;
97
98%% Solver-specific defaults
99switch solverName
100 case 'CTMC'
101 options.cutoff = 10; % finite per-class state-space cutoff for open/mixed models (matches native/JAR)
102 options.timespan = [Inf,Inf];
103 options.timestep = []; % timestep for fixed time steps in transient analysis
104 options.config.hide_immediate = true; % hide immediate transitions if possible
105 %options.config.state_space_gen = 'reachable'; % still buggy
106 options.config.state_space_gen = 'full';
107 options.rewardIterations = 1000; % number of value iterations for reward computation
108 options.config.qrf_params = []; % blocking config struct (f, MR, BB, F, MM, MM1, ZZ, ZM)
109 options.config.qrf_alpha = []; % load-dependent rates M x N matrix
110 case {'ENV','Env'}
111 options.method = 'default';
112 options.init_sol = [];
113 options.iter_max = 100;
114 options.iter_tol = 1e-4;
115 options.tol = 1e-4;
116 options.verbose = VerboseLevel.SILENT;
117 options.config.da = 'courtois'; % CTMC decomposition/aggregation: 'courtois', 'kms', 'takahashi', 'multi'
118 options.config.da_iter = 10; % Number of iterations for kms/takahashi
119 case {'FLD','Fluid'}
120 options = Solver.defaultOptions();
121 options.config.highvar = 'default';
122 options.config.hide_immediate = false; % stiff ODE solver handles immediate rates accurately
123 options.iter_max = 200;
124 options.stiff = true;
125 options.timespan = [0,Inf];
126 case 'JMT'
127 % use default
128 case 'LN'
129 options = Solver.defaultOptions();
130 options.config.interlocking = true;
131 options.config.multiserver = 'default';
132 % Under-relaxation options for convergence improvement
133 options.config.relax = 'fixed'; % 'auto' | 'fixed' | 'adaptive' | 'none'
134 options.config.relax_factor = 0.5; % Relaxation factor (0 < omega <= 1)
135 options.config.relax_min = 0.1; % Minimum relaxation factor for adaptive mode
136 options.config.relax_history = 5; % Error history window for adaptive mode
137 % Stochastic iteration options, used when layer solvers are
138 % simulation-based (JMT, SSA, LDES) and thus return noisy estimates
139 options.config.stochiter = 'auto'; % 'auto' | 'rm' | 'crn' | 'off'
140 options.config.stochiter_alpha = 0.6; % Robbins-Monro step decay exponent, in (0.5,1]
141 options.config.stochiter_a0 = 1.0; % Robbins-Monro initial step after burn-in
142 options.config.stochiter_burnin = 5; % Picard burn-in iterations before step decay starts
143 options.config.stochiter_conseq = 3; % consecutive sub-tolerance iterations required to stop
144 options.timespan = [Inf,Inf];
145 options.keep = true;
146 options.verbose = VerboseLevel.STD;
147 options.iter_max = 200; % More iterations for difficult LQN models
148 options.iter_tol = 5e-3; % Convergence tolerance (looser than default for LQN models)
149 options.tol = 1e-4;
150 % MOL (Method of Layers) options for hierarchical iteration
151 case 'LQNS'
152 options = Solver.defaultOptions();
153 options.timespan = [Inf,Inf];
154 options.keep = true;
155 options.verbose = false;
156 options.config.multiserver = 'default';
157 options.config.remote = false; % Enable remote execution via REST API
158 options.config.remote_url = 'http://localhost:8080'; % URL of lqns-rest server
159 options.config.container = ''; % Run lqns/lqsim inside Docker: '' = native (docker only as fallback if native missing), 'auto'/true = prefer docker if available, or an explicit image name (e.g. 'imperialqore/line-lqns-rest:latest')
160 case 'MAM'
161 options.iter_max = 100;
162 options.timespan = [Inf,Inf];
163 % FJ-specific options (used when Fork-Join topology detected)
164 options.config.fj_accuracy = 100; % C parameter for FJ_codes (higher = more accurate)
165 options.config.fj_tmode = 'NARE'; % T matrix computation: 'NARE' or 'Sylves'
166 % num_cdf_pts uses global default of 200
167 case 'MVA'
168 options.iter_max = 1000;
169 options.iter_tol = 1e-6;
170 case 'NC'
171 options.samples = 1e5;
172 options.timespan = [Inf,Inf];
173 options.config.highvar = 'interp';
174 case 'NN'
175 options.iter_max = 1000;
176 options.iter_tol = 1e-6;
177 case 'QNS'
178 options.config.multiserver = 'default';
179 case 'SSA'
180 options.timespan = [0,Inf];
181 options.verbose = true;
182 options.config.state_space_gen = 'none';
183 % see _kb/05-solvers-overview.md for rationale (SSA warmup discard)
184 options.config.warmupfrac = 0.0;
185 % see _kb/05-solvers-overview.md for rationale (worker-count-invariant replications)
186 options.config.nreplicas = 8;
187 switch options.lang
188 case 'java'
189 options.config.eventcache = true;
190 otherwise
191 options.config.eventcache = false;
192 end
193 case 'LDES'
194 options.samples = 2e5;
195 options.lang = 'java';
196 % Transient detection options
197 options.config.tranfilter = 'mser5'; % 'mser5', 'fixed', or 'none'
198 options.config.mserbatch = 5; % MSER batch size (default: 5)
199 options.config.warmupfrac = 0.2; % Warmup fraction for fixed filter (0.0 to 1.0)
200 % Confidence interval options
201 options.config.cimethod = 'obm'; % 'obm', 'bm', 'spectral', or 'none'
202 options.config.obmoverlap = 0.5; % OBM overlap fraction (0.0 to 1.0)
203 options.config.ciminbatch = 10; % Minimum batch size for CI
204 options.config.ciminobs = 100; % Minimum observations for CI
205 options.config.spectrallowfreqfrac = 0.25; % Low-frequency fraction, cimethod='spectral'
206 % Parallel replication options. Above 1, each replication runs with its
207 % own RNG stream and the confidence intervals use the cross-replication
208 % variance instead of batch means.
209 options.config.replications = 1; % Number of independent replications
210 options.config.numthreads = []; % Worker threads (empty = engine default)
211 % Convergence options
212 options.config.cnvgon = false; % Enable convergence-based stopping
213 options.config.cnvgtol = 0.05; % Convergence tolerance (5% relative precision)
214 options.config.cnvgbatch = 20; % Min batches before checking convergence
215 options.config.cnvgchk = 0; % Events between checks (0 = auto)
216 % see _kb/05-solvers-overview.md for rationale (discrete-time/slotted)
217 options.config.slotted = false; % Run on a discrete time scale
218 options.config.slotlength = 1; % Slot length in model time units
219 % see _kb/05-solvers-overview.md for rationale (LDES REST endpoint)
220 options.rest_url = '';
221end
222end