LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_set_service.m
1%{ @file sn_set_service.m
2 % @brief Sets service rate at a specific station and class
3 %
4 % @author LINE Development Team
5%}
6
7%{
8 % @brief Sets service rate at a specific station and class
9 %
10 % @details
11 % Directly modifies the service rate in NetworkStruct without rebuilding
12 % the full Network object. Useful for fast parameter updates in optimization.
13 %
14 % @par Syntax:
15 % @code
16 % sn = sn_set_service(sn, stationIdx, classIdx, rate)
17 % sn = sn_set_service(sn, stationIdx, classIdx, rate, scv)
18 % sn = sn_set_service(sn, stationIdx, classIdx, rate, scv, autoRefresh)
19 % @endcode
20 %
21 % @par Parameters:
22 % <table>
23 % <tr><th>Name<th>Description
24 % <tr><td>sn<td>Network structure
25 % <tr><td>stationIdx<td>Station index (1-based)
26 % <tr><td>classIdx<td>Class index (1-based)
27 % <tr><td>rate<td>New service rate (must be positive)
28 % <tr><td>scv<td>Squared coefficient of variation (default 1.0)
29 % <tr><td>autoRefresh<td>If true, refresh process fields (default false)
30 % </table>
31 %
32 % @par Returns:
33 % <table>
34 % <tr><th>Name<th>Description
35 % <tr><td>sn<td>Modified network structure
36 % </table>
37%}
38function sn = sn_set_service(sn, stationIdx, classIdx, rate, scv, autoRefresh)
39
40if nargin < 5 || isempty(scv)
41 scv = 1.0;
42end
43
44if nargin < 6 || isempty(autoRefresh)
45 autoRefresh = false;
46end
47
48% Update rates matrix
49sn.rates(stationIdx, classIdx) = rate;
50
51% Update scv matrix
52sn.scv(stationIdx, classIdx) = scv;
53
54% Auto-refresh process fields if requested
55if autoRefresh
56 sn = sn_refresh_process_fields(sn, stationIdx, classIdx);
57end
58
59end