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';
49options.config.nonmkv = 'bernstein'; % Method for non-Markovian distribution conversion: 'none', 'bernstein'
50options.config.nonmkvorder = 20; % Order (number of phases) for non-Markovian distribution approximation
51options.lang = 'matlab';
52%options.lang = 'java';
53options.force = false;
54options.init_sol = [];
55options.iter_max = 100;
56options.iter_tol = 1e-4; % convergence tolerance to stop iterations
57options.tol = 1e-4; % tolerance for all other uses
58options.keep = true;
59options.method = 'default';
60%options.remote = false;
61%options.remote_endpoint = '127.0.0.1';
62
63odesfun = struct();
64odesfun.fastOdeSolver = @ode23;
65odesfun.accurateOdeSolver = @ode113;
66odesfun.fastStiffOdeSolver = @ode23s;
67odesfun.accurateStiffOdeSolver = @ode15s;
68options.odesolvers = odesfun;
69
70options.samples = 1e4;
71options.seed = randi([1,1e6]);
72options.stiff = true;
73options.confint = false; % confidence interval: false, true (95%), or level (0.0-1.0)
74options.timespan = [Inf,Inf];
75options.timestep = [];
76options.verbose = VerboseLevel.STD;
77
78options.config.num_cdf_pts = 200;
79
80%% Solver-specific defaults
81switch solverName
82 case 'CTMC'
83 options.timespan = [Inf,Inf];
84 options.timestep = []; % timestep for fixed time steps in transient analysis
85 options.config.hide_immediate = true; % hide immediate transitions if possible
86 %options.config.state_space_gen = 'reachable'; % still buggy
87 options.config.state_space_gen = 'full';
88 options.rewardIterations = 1000; % number of value iterations for reward computation
89 case 'Env'
90 options.method = 'default';
91 options.init_sol = [];
92 options.iter_max = 100;
93 options.iter_tol = 1e-4;
94 options.tol = 1e-4;
95 options.verbose = VerboseLevel.SILENT;
96 options.config.da = 'courtois'; % CTMC decomposition/aggregation: 'courtois', 'kms', 'takahashi', 'multi'
97 options.config.da_iter = 10; % Number of iterations for kms/takahashi
98 case 'Fluid'
99 options = Solver.defaultOptions();
100 options.config.highvar = 'default';
101 options.config.hide_immediate = true; % eliminate immediate transitions by default
102 options.iter_max = 200;
103 options.stiff = true;
104 options.timespan = [0,Inf];
105 case 'JMT'
106 % use default
107 case 'LN'
108 options = Solver.defaultOptions();
109 options.config.interlocking = false; % do not change, true unstable as of 2.0.38
110 options.config.multiserver = 'default';
111 % Under-relaxation options for convergence improvement
112 options.config.relax = 'auto'; % 'auto' | 'fixed' | 'adaptive' | 'none'
113 options.config.relax_factor = 0.1; % Relaxation factor when enabled (0 < omega <= 1)
114 options.config.relax_min = 0.1; % Minimum relaxation factor for adaptive mode
115 options.config.relax_history = 5; % Error history window for adaptive mode
116 options.timespan = [Inf,Inf];
117 options.keep = true;
118 options.verbose = VerboseLevel.STD;
119 options.iter_max = 200; % More iterations for difficult LQN models
120 options.iter_tol = 5e-3; % Convergence tolerance (looser than default for LQN models)
121 options.tol = 1e-4;
122 % MOL (Method of Layers) options for hierarchical iteration
123 options.config.mol_task_inner_max = 50; % Max task inner iterations per host outer iteration
124 options.config.mol_task_inner_tol = 1e-4; % Task layer convergence tolerance (utilization delta)
125 options.config.mol_host_outer_tol = 1e-4; % Host layer convergence tolerance (utilization delta)
126 options.config.mol_min_steps = 2; % Minimum outer iterations before checking host convergence
127 case 'LQNS'
128 options = Solver.defaultOptions();
129 options.timespan = [Inf,Inf];
130 options.keep = true;
131 options.verbose = false;
132 options.config.multiserver = 'default';
133 options.config.remote = false; % Enable remote execution via REST API
134 options.config.remote_url = 'http://localhost:8080'; % URL of lqns-rest server
135 case 'MAM'
136 options.iter_max = 100;
137 options.timespan = [Inf,Inf];
138 % FJ-specific options (used when Fork-Join topology detected)
139 options.config.fj_accuracy = 100; % C parameter for FJ_codes (higher = more accurate)
140 options.config.fj_tmode = 'NARE'; % T matrix computation: 'NARE' or 'Sylves'
141 % num_cdf_pts uses global default of 200
142 case 'MVA'
143 options.iter_max = 1000;
144 options.iter_tol = 1e-6;
145 case 'NC'
146 options.samples = 1e5;
147 options.timespan = [Inf,Inf];
148 options.config.highvar = 'interp';
149 case 'NN'
150 options.iter_max = 1000;
151 options.iter_tol = 1e-6;
152 case 'QNS'
153 options.config.multiserver = 'default';
154 case 'SSA'
155 options.timespan = [0,Inf];
156 options.verbose = true;
157 options.config.state_space_gen = 'none';
158 switch options.lang
159 case 'java'
160 options.config.eventcache = true;
161 otherwise
162 options.config.eventcache = false;
163 end
164 case 'DES'
165 options.samples = 1e5;
166 options.lang = 'java';
167 % Transient detection options
168 options.config.tranfilter = 'mser5'; % 'mser5', 'fixed', or 'none'
169 options.config.mserbatch = 5; % MSER batch size (default: 5)
170 options.config.warmupfrac = 0.2; % Warmup fraction for fixed filter (0.0 to 1.0)
171 % Confidence interval options
172 options.config.cimethod = 'obm'; % overlapping batch means: 'obm', batch mean: 'bm', or 'none'
173 options.config.obmoverlap = 0.5; % OBM overlap fraction (0.0 to 1.0)
174 options.config.ciminbatch = 10; % Minimum batch size for CI
175 options.config.ciminobs = 100; % Minimum observations for CI
176 % Convergence options
177 options.config.cnvgon = false; % Enable convergence-based stopping
178 options.config.cnvgtol = 0.05; % Convergence tolerance (5% relative precision)
179 options.config.cnvgbatch = 20; % Min batches before checking convergence
180 options.config.cnvgchk = 0; % Events between checks (0 = auto)
181end
182end