LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_set_population.m
1%{ @file sn_set_population.m
2 % @brief Sets the number of jobs for a closed class
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Sets the number of jobs for a closed class
9 %
10 % @details
11 % Directly modifies the job population in NetworkStruct and recalculates
12 % nclosedjobs.
13 %
14 % @par Syntax:
15 % @code
16 % sn = sn_set_population(sn, classIdx, nJobs)
17 % sn = sn_set_population(sn, classIdx, nJobs, autoRefresh)
18 % @endcode
19 %
20 % @par Parameters:
21 % <table>
22 % <tr><th>Name<th>Description
23 % <tr><td>sn<td>Network structure
24 % <tr><td>classIdx<td>Class index (1-based)
25 % <tr><td>nJobs<td>Number of jobs (non-negative)
26 % <tr><td>autoRefresh<td>If true, refresh visit ratios (default false)
27 % </table>
28 %
29 % @par Returns:
30 % <table>
31 % <tr><th>Name<th>Description
32 % <tr><td>sn<td>Modified network structure
33 % </table>
34%}
35function sn = sn_set_population(sn, classIdx, nJobs, autoRefresh)
36
37if nargin < 4 || isempty(autoRefresh)
38 autoRefresh = false;
39end
40
41% Update njobs
42sn.njobs(classIdx) = nJobs;
43
44% Recalculate nclosedjobs
45sn.nclosedjobs = sum(sn.njobs(isfinite(sn.njobs)));
46
47% Auto-refresh visit ratios if requested
48if autoRefresh
49 [~, ~, sn] = sn_refresh_visits(sn, sn.chains, sn.rt, sn.rtnodes);
50end
51
52end