Environments
EnvParams
Dataclass to hold environment parameters. Parameters are immutable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_requests
|
Scalar
|
Maximum number of requests in an episode |
required |
incremental_loading
|
Scalar
|
Incremental increase in traffic load (non-expiring requests) |
required |
end_first_blocking
|
Scalar
|
End episode on first blocking event |
required |
continuous_operation
|
Scalar
|
If True, do not reset the environment at the end of an episode |
required |
edges
|
Array
|
Two column array defining source-dest node-pair edges of the graph |
required |
slot_size
|
Scalar
|
Spectral width of frequency slot in GHz |
required |
consider_modulation_format
|
Scalar
|
If True, consider modulation format to determine required slots |
required |
link_length_array
|
Array
|
Array of link lengths |
required |
aggregate_slots
|
Scalar
|
Number of slots to aggregate into a single action (First-Fit with aggregation) |
required |
guardband
|
Scalar
|
Guard band in slots |
required |
directed_graph
|
bool
|
Whether graph is directed (one fibre per link per transmission direction) |
required |
temperature
|
Scalar
|
Temp. used for softmax differentiable approximation |
required |
window_size
|
Scalar
|
Window size for weighted average of neighbouring cells in differentiable indexing |
required |
Source code in xlron/environments/dataclasses.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
EnvState
Dataclass to hold environment state. State is mutable and arrays are traced on JIT compilation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_time
|
Scalar
|
Current time in environment |
required |
holding_time
|
Scalar
|
Holding time of current request |
required |
total_timesteps
|
Scalar
|
Total timesteps in environment |
required |
total_requests
|
Scalar
|
Total requests in environment |
required |
graph
|
GraphsTuple
|
Graph tuple representing network state |
required |
full_link_slot_mask
|
Array
|
Action mask for link slot action (including if slot actions are aggregated) |
required |
accepted_services
|
Array
|
Number of accepted services |
required |
accepted_bitrate
|
Array
|
Accepted bitrate |
required |
Source code in xlron/environments/dataclasses.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
RSAMultibandEnvParams
Bases: RSAEnvParams
Dataclass to hold environment parameters for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
401 402 403 404 405 406 | |
RSAMultibandEnvState
Bases: RSAEnvState
Dataclass to hold environment state for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
394 395 396 397 398 | |
Dataclasses
DeepRMSAEnvState
Bases: RSAEnvState
Dataclass to hold environment state for DeepRMSA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_stats
|
Array
|
Path stats array containing |
required |
Source code in xlron/environments/dataclasses.py
218 219 220 221 222 223 224 225 226 227 228 229 230 | |
EnvParams
Dataclass to hold environment parameters. Parameters are immutable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_requests
|
Scalar
|
Maximum number of requests in an episode |
required |
incremental_loading
|
Scalar
|
Incremental increase in traffic load (non-expiring requests) |
required |
end_first_blocking
|
Scalar
|
End episode on first blocking event |
required |
continuous_operation
|
Scalar
|
If True, do not reset the environment at the end of an episode |
required |
edges
|
Array
|
Two column array defining source-dest node-pair edges of the graph |
required |
slot_size
|
Scalar
|
Spectral width of frequency slot in GHz |
required |
consider_modulation_format
|
Scalar
|
If True, consider modulation format to determine required slots |
required |
link_length_array
|
Array
|
Array of link lengths |
required |
aggregate_slots
|
Scalar
|
Number of slots to aggregate into a single action (First-Fit with aggregation) |
required |
guardband
|
Scalar
|
Guard band in slots |
required |
directed_graph
|
bool
|
Whether graph is directed (one fibre per link per transmission direction) |
required |
temperature
|
Scalar
|
Temp. used for softmax differentiable approximation |
required |
window_size
|
Scalar
|
Window size for weighted average of neighbouring cells in differentiable indexing |
required |
Source code in xlron/environments/dataclasses.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
EnvState
Dataclass to hold environment state. State is mutable and arrays are traced on JIT compilation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_time
|
Scalar
|
Current time in environment |
required |
holding_time
|
Scalar
|
Holding time of current request |
required |
total_timesteps
|
Scalar
|
Total timesteps in environment |
required |
total_requests
|
Scalar
|
Total requests in environment |
required |
graph
|
GraphsTuple
|
Graph tuple representing network state |
required |
full_link_slot_mask
|
Array
|
Action mask for link slot action (including if slot actions are aggregated) |
required |
accepted_services
|
Array
|
Number of accepted services |
required |
accepted_bitrate
|
Array
|
Accepted bitrate |
required |
Source code in xlron/environments/dataclasses.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
GNModelEnvParams
Bases: RSAEnvParams
Dataclass to hold environment state for GN model environments.
Source code in xlron/environments/dataclasses.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
GNModelEnvState
Bases: RSAEnvState
Dataclass to hold environment state for RSA with GN model.
Source code in xlron/environments/dataclasses.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
HashableArrayWrapper
Bases: Generic[T]
Wrapper for making arrays hashable. In order to access pre-computed data, such as shortest paths between node-pairs or the constituent links of a path, within a jitted function, we need to make the arrays containing this data hashable. By defining this wrapper, we can define a hash method that returns a hash of the array's bytes, thus making the array hashable. From: https://github.com/google/jax/issues/4572#issuecomment-709677518
Source code in xlron/environments/dataclasses.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
LogEnvState
Dataclass to hold environment state for logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_state
|
EnvState
|
Environment state |
required |
lengths
|
Scalar
|
Lengths |
required |
returns
|
Scalar
|
Returns |
required |
cum_returns
|
Scalar
|
Cumulative returns |
required |
accepted_services
|
Scalar
|
Accepted services |
required |
accepted_bitrate
|
Scalar
|
Accepted bitrate |
required |
total_bitrate
|
Scalar
|
Total bitrate requested |
required |
utilisation
|
Scalar
|
Network utilisation |
required |
terminal
|
Scalar
|
Terminal flag (true termination condition met) |
required |
truncated
|
Scalar
|
Truncated flag (max steps reached) |
required |
Source code in xlron/environments/dataclasses.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
MultiBandRSAEnvParams
Bases: RSAEnvParams
Dataclass to hold environment parameters for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
266 267 268 269 270 271 | |
MultiBandRSAEnvState
Bases: RSAEnvState
Dataclass to hold environment state for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
259 260 261 262 263 | |
RMSAGNModelEnvParams
Bases: GNModelEnvParams
Dataclass to hold environment params for RMSA with GN model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_snr_array
|
Array
|
Link SNR array |
required |
Source code in xlron/environments/dataclasses.py
367 368 369 370 371 372 373 374 375 376 | |
RMSAGNModelEnvState
Bases: GNModelEnvState
Dataclass to hold environment state for RMSA with GN model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_snr_array
|
Array
|
Link SNR array |
required |
Source code in xlron/environments/dataclasses.py
379 380 381 382 383 384 385 386 387 388 389 390 391 | |
RSAEnvParams
Bases: EnvParams
Dataclass to hold environment parameters for RSA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_nodes
|
Scalar
|
Number of nodes |
required |
num_links
|
Scalar
|
Number of links |
required |
link_resources
|
Scalar
|
Number of link resources |
required |
k_paths
|
Scalar
|
Number of paths |
required |
mean_service_holding_time
|
Scalar
|
Mean service holding time |
required |
load
|
Scalar
|
Load |
required |
arrival_rate
|
Scalar
|
Arrival rate |
required |
path_link_array
|
Array
|
Path link array |
required |
random_traffic
|
bool
|
Random traffic matrix for RSA on each reset (else uniform or custom) |
required |
max_slots
|
Scalar
|
Maximum number of slots |
required |
path_se_array
|
Array
|
Path spectral efficiency array |
required |
deterministic_requests
|
bool
|
If True, use deterministic requests |
required |
multiple_topologies
|
bool
|
If True, use multiple topologies |
required |
Source code in xlron/environments/dataclasses.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
RSAEnvState
Bases: EnvState
Dataclass to hold environment state for RSA.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_slot_array
|
Array
|
Link slot array |
required |
request_array
|
Array
|
Request array |
required |
link_slot_departure_array
|
Array
|
Link slot departure array |
required |
link_slot_mask
|
Array
|
Link slot mask |
required |
traffic_matrix
|
Array
|
Traffic matrix |
required |
Source code in xlron/environments/dataclasses.py
176 177 178 179 180 181 182 183 184 185 186 187 188 | |
RSAGNModelEnvParams
Bases: GNModelEnvParams
Dataclass to hold environment params for RSA with GN model.
Source code in xlron/environments/dataclasses.py
351 352 353 354 355 | |
RSAGNModelEnvState
Bases: GNModelEnvState
Dataclass to hold environment state for RSA with GN model.
Source code in xlron/environments/dataclasses.py
358 359 360 361 362 363 364 | |
RSAMultibandEnvParams
Bases: RSAEnvParams
Dataclass to hold environment parameters for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
401 402 403 404 405 406 | |
RSAMultibandEnvState
Bases: RSAEnvState
Dataclass to hold environment state for MultiBandRSA (RBSA).
Source code in xlron/environments/dataclasses.py
394 395 396 397 398 | |
RWALightpathReuseEnvState
Bases: RSAEnvState
Dataclass to hold environment state for RWA with lightpath reuse.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_index_array
|
Array
|
Contains indices of lightpaths in use on slots |
required |
path_capacity_array
|
Array
|
Contains remaining capacity of each lightpath |
required |
link_capacity_array
|
Array
|
Contains remaining capacity of lightpath on each link-slot |
required |
Source code in xlron/environments/dataclasses.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
VONEEnvParams
Bases: RSAEnvParams
Dataclass to hold environment parameters for VONE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_resources
|
Scalar
|
Number of node resources |
required |
max_edges
|
Scalar
|
Maximum number of edges |
required |
min_node_resources
|
Scalar
|
Minimum number of node resources |
required |
max_node_resources
|
Scalar
|
Maximum number of node resources |
required |
Source code in xlron/environments/dataclasses.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
VONEEnvState
Bases: RSAEnvState
Dataclass to hold environment state for VONE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_capacity_array
|
Array
|
Node capacity array |
required |
node_resource_array
|
Array
|
Node resource array |
required |
node_departure_array
|
Array
|
Node departure array |
required |
action_counter
|
Array
|
Action counter |
required |
action_history
|
Array
|
Action history |
required |
node_mask_s
|
Array
|
Node mask for source node |
required |
node_mask_d
|
Array
|
Node mask for destination node |
required |
virtual_topology_patterns
|
Array
|
Virtual topology patterns |
required |
values_nodes
|
Array
|
Values for nodes |
required |
Source code in xlron/environments/dataclasses.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
Environment wrappers
JitProfiler
Wall-clock profiler for JAX JIT-compiled code.
On CPU
• Uses host callbacks for fine-grained section timing.
On GPU
• Automatically switches to first-call-only timing. • Measures compilation + first execution latency. • Fine-grained per-call timings are intentionally disabled to avoid misleading synchronization artifacts.
This profiler records host-side timestamps using jax.debug.callback,
allowing coarse wall-clock profiling of sections inside JIT-compiled code.
Profiling is designed to be gated by a static Python boolean (e.g.
params.profile) so that all profiling logic is resolved at trace time and
introduces zero runtime overhead when disabled.
Features
• Manual markers via mark(), start(), and end()
• Function-level profiling via call()
• Automatic jax.named_scope integration for clearer JAX traces
• Safety checks to ensure the profiling flag is static at trace time
• Aggregation across repeated calls with a readable summary table
Basic usage inside JIT (manual markers):
if params.profile:
jit_profiler.mark("process_action:start")
with jax.named_scope("process_action"):
...
if params.profile:
jit_profiler.mark("process_action:end")
Function-wrapping usage inside JIT (recommended):
action_mask = jit_profiler.call(
params.profile,
mask_slots,
state,
params,
name="mask_actions", # optional, defaults to fn.__name__
)
Block-style usage inside JIT:
jit_profiler.start(params.profile, "action_logic")
...
jit_profiler.end(params.profile, "action_logic")
Notes
• The enabled flag must be a Python bool known at trace time
(e.g. params.profile with pytree_node=False).
• Passing a traced or JAX boolean will raise a TypeError.
• All timing is wall-clock time measured on the host, not device time.
After execution (outside JIT):
jit_profiler.summary()
Source code in xlron/environments/wrappers.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
call(enabled, fn, *args, name=None, **kwargs)
Profile a function call inside JIT-compiled code.
CPU
Fine-grained section timing via callbacks.
GPU
Records only first-call (compile + first execution) latency.
Source code in xlron/environments/wrappers.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
end(enabled, name)
Insert an end marker for a block.
Source code in xlron/environments/wrappers.py
359 360 361 362 363 | |
mark(label)
Insert a timing marker. Safe to call inside JIT.
Source code in xlron/environments/wrappers.py
344 345 346 | |
reset()
Clear all recorded timestamps and first-call tracking.
Source code in xlron/environments/wrappers.py
348 349 350 351 | |
start(enabled, name)
Insert a start marker for a block.
Source code in xlron/environments/wrappers.py
353 354 355 356 357 | |
summary()
Print timing breakdown from collected start/end marker pairs.
Expects markers in the format "name:start" and "name:end". Aggregates across repeated calls (e.g. many step_env invocations).
Also reports GPU :first entries if present.
Source code in xlron/environments/wrappers.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
LogWrapper
Bases: GymnaxWrapper
Log the episode returns and lengths. Modified from: https://github.com/RobertTLange/gymnax/blob/master/gymnax/wrappers/purerl.py
Source code in xlron/environments/wrappers.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
Profiler
Simple wall-clock profiler that tracks named sections.
Usage
profiler = Profiler()
with profiler.section("compilation"): ...
for i in range(10): with profiler.section("training_step", frames=1000): ...
profiler.summary()
Source code in xlron/environments/wrappers.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
section(tag, frames=None)
Return a context manager that times the enclosed block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Name for this section. Repeated uses accumulate. |
required |
frames
|
int | None
|
Optional work-unit count (e.g. timesteps) for throughput. |
None
|
Source code in xlron/environments/wrappers.py
186 187 188 189 190 191 192 193 | |
summary()
Print a table summarising all recorded sections.
Source code in xlron/environments/wrappers.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
TimeIt
Context manager for timing execution of code blocks.
Source code in xlron/environments/wrappers.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
Environment functions
aggregate_slots(full_mask, params)
Aggregate slot mask via max-pooling.
Source code in xlron/environments/env_funcs.py
2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 | |
check_action_rmsa_gn_model(state, action_info, params)
Check if action is valid for RSA GN model Args: state (EnvState): Environment state params (EnvParams): Environment parameters action (chex.Array): Action array Returns: bool: True if action is invalid, False if action is valid
Source code in xlron/environments/env_funcs.py
3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 | |
check_action_rsa(state, action_info, params)
Differentiable version of check_action_rsa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Current environment state |
required | |
temperature
|
Controls sharpness of sigmoid |
required |
Returns:
| Type | Description |
|---|---|
|
Continuous value that behaves like the original boolean check |
Source code in xlron/environments/env_funcs.py
1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 | |
check_no_op(state, action_info, params)
Check for the "NO OP" action. This will be the maximum valid action idex + 1, resulting in a path index exceeding K paths.
Source code in xlron/environments/env_funcs.py
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 | |
check_no_spectrum_reuse(state, action_info, params)
slot-=1 when used, should be zero when unoccupied, so check if any < -1 in slot array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_slot_array
|
Link slot array (L x S) where L is number of links and S is number of slots |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if check failed, False if check passed |
Source code in xlron/environments/env_funcs.py
1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 | |
check_real_path(state, action_info, params)
Check if path is a dummy (all-zeros). A valid path always uses at least one link.
Source code in xlron/environments/env_funcs.py
1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 | |
check_slot_overflow(state, action_info, params)
If the action selects slot near the end, then the required slots can overflow and start filling from the start of the array, which might be free! To prevent this, we check the action index + required slots
Source code in xlron/environments/env_funcs.py
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 | |
check_snr_sufficient(state, params)
Check if SNR is sufficient for all active connections. Args: state (EnvState): Environment state params (EnvParams): Environment parameters Returns: jnp.array: 1 if any active connection has insufficient SNR, else 0
Source code in xlron/environments/env_funcs.py
3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 | |
complete_step_rmsa_gn_model(state, action_info, check, params)
Complete step for RMSA GN-model environments.
Same as RSA GN-model, plus modulation_format_index_array restoration.
Source code in xlron/environments/env_funcs.py
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 | |
complete_step_rsa(state, action_info, check, params)
If the request is unsuccessful i.e. checks fail, then remove the partial (unfinalised) resource allocation. Partial resource allocation is indicated by negative time in link slot departure array. Check for values in link_slot_departure_array that are less than zero. If found, increase link_slot_array by +1 and link_slot_departure_array by current_time + holding_time of current request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
Returns:
| Type | Description |
|---|---|
EnvState
|
Updated environment state |
Source code in xlron/environments/env_funcs.py
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 | |
complete_step_rsa_gn_model(state, action_info, check, params)
Complete step for RSA GN-model environments.
On failure (check==1), undo partial slot allocation and restore GN-model auxiliary arrays from their *_prev snapshots.
Source code in xlron/environments/env_funcs.py
1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 | |
complete_step_rwalr(state, action_info, check, params)
Complete step for RWA-LR environments. Unlike complete_step_rsa, this does not modify link_slot_array on failure, because implement_action_rwalr already handles the undo via blending and link_slot_array stores a capacity mask (not an occupancy counter).
Source code in xlron/environments/env_funcs.py
1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 | |
compute_band_gaps_from_csv(link_resources, ref_lambda, slot_size, band_data_filepath=None)
Compute band gap slot positions from band definition CSV data.
Reads the band data CSV which defines frequency ranges for each optical band. Any slot whose centre frequency falls between bands is marked as a gap slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_resources
|
int
|
Number of frequency slots per link. |
required |
ref_lambda
|
float
|
Reference wavelength (m). |
required |
slot_size
|
float
|
Slot width in GHz. |
required |
band_data_filepath
|
str | None
|
Optional path to band data CSV file. Defaults to
built-in |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[list, list]
|
Tuple of (gap_start_slots, gap_width_slots) as Python lists of ints. |
Source code in xlron/environments/env_funcs.py
2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 | |
compute_band_layout(slot_size, band_preference, inter_band_gap_ghz=25.0, band_data_filepath=None)
Compute band layout: link_resources, ref_lambda, slot centre frequencies, gaps, and orderings.
Given a slot size and selected bands, this function:
1. Determines how many slots fit in each band
2. Inserts 1 gap slot per inter-band boundary (representing inter_band_gap_ghz)
3. Computes absolute centre frequencies for every slot
4. Returns all derived quantities needed by make_env
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot_size
|
float
|
Spectral width of a frequency slot in GHz. |
required |
band_preference
|
str
|
Comma-separated band names in preference order (e.g. "C,L,S"). |
required |
inter_band_gap_ghz
|
float
|
Physical spectral width of inter-band gap in GHz (~0.2 nm). |
25.0
|
band_data_filepath
|
str | None
|
Optional path to band data CSV. Defaults to built-in. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dict with keys: link_resources, ref_lambda, slot_centre_freq_array (relative GHz), |
dict
|
gap_start_slots, gap_width_slots, band_slot_order_ff, band_slot_order_lf. |
Source code in xlron/environments/env_funcs.py
3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 | |
compute_band_slot_order(link_resources, ref_lambda, slot_size, band_preference, band_data_filepath=None)
Compute band-preference-ordered slot index arrays for first-fit and last-fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_resources
|
int
|
Number of frequency slots per link. |
required |
ref_lambda
|
float
|
Reference wavelength (m). |
required |
slot_size
|
float
|
Slot width in GHz. |
required |
band_preference
|
str
|
Comma-separated band names in preference order (e.g. "C,L,S"). |
required |
band_data_filepath
|
str | None
|
Optional path to band data CSV. Defaults to built-in. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Tuple of (band_slot_order_ff, band_slot_order_lf) as numpy int32 arrays |
ndarray
|
of shape (link_resources,). |
Tuple[ndarray, ndarray]
|
band_slot_order_ff has slots ascending within each band, bands in preference order. |
Tuple[ndarray, ndarray]
|
band_slot_order_lf has slots descending within each band, bands in preference order. |
Source code in xlron/environments/env_funcs.py
2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 | |
compute_total_power_per_link(channel_power_array, path_index_array)
Compute total optical power per link by summing one power value per channel.
Each channel spans multiple contiguous slots with the same power value and the same path_index. We identify channel starts (where path_index differs from previous slot and is >= 0) and sum their power values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_power_array
|
(num_links, link_resources) per-channel power in linear Watts |
required | |
path_index_array
|
(num_links, link_resources) lightpath index (-1 for empty) |
required |
Returns: (num_links,) total optical power per link in linear Watts
Source code in xlron/environments/env_funcs.py
3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 | |
convert_node_probs_to_traffic_matrix(node_probs)
Convert list of node probabilities to symmetric traffic matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_probs
|
list
|
node probabilities |
required |
Returns:
| Name | Type | Description |
|---|---|---|
traffic_matrix |
Array
|
traffic matrix |
Source code in xlron/environments/env_funcs.py
1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 | |
count_until_next_one(array, position, temperature, differentiable=True)
Counts positions until the next 1 in the array. Made differentiable using straight-through gradient trick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Array
|
Input array |
required |
position
|
int
|
Starting position for counting |
required |
temperature
|
float
|
Temperature for differentiable approximation |
required |
differentiable
|
bool
|
If False, use non-differentiable operations |
True
|
Returns:
| Type | Description |
|---|---|
Array
|
Number of positions until the next 1 |
Source code in xlron/environments/env_funcs.py
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 | |
count_until_previous_one(array, position, temperature, differentiable=True)
Counts positions until the previous 1 in the array. Made differentiable using straight-through gradient trick.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
Array
|
Input array |
required |
position
|
int
|
Starting position for counting backwards |
required |
temperature
|
float
|
Temperature for differentiable approximation |
required |
differentiable
|
bool
|
If False, use non-differentiable operations |
True
|
Returns:
| Type | Description |
|---|---|
int
|
Number of positions until the previous 1 |
Source code in xlron/environments/env_funcs.py
2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 | |
create_run_name(config)
Create name for run based on config flags
Source code in xlron/environments/env_funcs.py
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 | |
differentiable_check_no_spectrum_reuse(state, action_info, params)
Differentiable version of check_no_spectrum_reuse with improved gradient properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_slot_array
|
Link slot array (L x S) where L is number of links and S is number of slots |
required | |
temperature
|
Controls the sharpness of the gradient response |
required | |
differentiable
|
If False, return hard result directly without gradient approximation |
required |
Returns:
| Type | Description |
|---|---|
|
A value that behaves like the original boolean check in forward pass |
|
|
but has zero gradient when there are no violations and otherwise |
|
|
has gradient pointing toward reducing violations |
Source code in xlron/environments/env_funcs.py
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 | |
find_block_ends(path_slots)
Finds the end positions of blocks in the path slots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_slots
|
Array
|
Array of path slots |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Array with 1s at the end positions of blocks |
Source code in xlron/environments/env_funcs.py
2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 | |
find_block_starts(path_slots)
Finds the starting positions of blocks in the path slots. Args: path_slots: Array of path slots
Returns:
| Type | Description |
|---|---|
Array
|
Array with 1s at the starting positions of blocks |
Source code in xlron/environments/env_funcs.py
2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 | |
generate_arrival_holding_times(key, params)
Generate arrival and holding times based on Poisson distributed events. To understand how sampling from e^-x can be transformed to sample from lambdae^-(x/lambda) see: https://en.wikipedia.org/wiki/Inverse_transform_sampling#Examples Basically, inverse transform sampling is used to sample from a distribution with CDF F(x). The CDF of the exponential distribution (lambdae^-{lambdax}) is F(x) = 1 - e^-{lambdax}. Therefore, the inverse CDF is x = -ln(1-u)/lambda, where u is sample from uniform distribution. Therefore, we need to divide jax.random.exponential() by lambda in order to scale the standard exponential CDF. Experimental histograms of this method compared to random.expovariate() in Python's random library show that the two methods are equivalent. Also see: https://numpy.org/doc/stable/reference/random/generated/numpy.random.exponential.html https://jax.readthedocs.io/en/latest/_autosummary/jax.random.exponential.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNG key |
required | |
params
|
Environment parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
arrival_time |
Arrival time |
|
holding_time |
Holding time |
Source code in xlron/environments/env_funcs.py
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | |
get_best_modulation_format_simple(state, path, initial_slot_index, params)
Get modulation format for lightpath. Assume worst case (least Gaussian) modulation format when calculating SNR. Args: state (EnvState): Environment state path (chex.Array): Path array initial_slot_index (int): Initial slot index params (EnvParams): Environment parameters Returns: jnp.array: Acceptable modulation format indices
Source code in xlron/environments/env_funcs.py
3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 | |
get_centre_frequency(initial_slot_index, num_slots, params)
Get centre frequency for new lightpath.
Looks up pre-computed per-slot centre frequencies from
params.slot_centre_freq_array and returns the midpoint of the first
and last slot in the channel. This correctly handles non-uniform slot
spacing (e.g. inter-band gap slots).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_slot_index
|
Array
|
Index of the first slot of the channel. |
required |
num_slots
|
float
|
Number of slots occupied by the channel. |
required |
params
|
RSAGNModelEnvParams
|
Environment parameters. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Centre frequency for new lightpath (relative GHz offset |
Array
|
from ref_lambda). |
Source code in xlron/environments/env_funcs.py
3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 | |
get_edge_disjoint_paths(graph)
Get edge disjoint paths between all nodes in graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
graph |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[int, Dict[int, List[Tuple[int, int]]]]
|
edge disjoint paths (path is list of edges) |
Source code in xlron/environments/env_funcs.py
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 | |
get_launch_power(state, path_action, power_action, params)
Get launch power for new lightpath. N.B. launch power is specified in dBm but is converted to linear units when stored in channel_power_array. This func returns linear units (mW). Path action is used to determine the launch power in the case of tabular launch power type. Power action is used to determine the launch power in the case of RL launch power type. During masking, power action is set as state.launch_power_array[0], which is set by the RL agent. Args: state (EnvState): Environment state path_action (chex.Array): Action specifying path index (0 to k_paths-1) power_action (chex.Array): Action specifying launch power in dBm params (EnvParams): Environment parameters Returns: chex.Array: Launch power for new lightpath
Source code in xlron/environments/env_funcs.py
4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 | |
get_lightpath_snr(state, params)
Get SNR for each link on path. N.B. that in most cases it is more efficient to calculate the SNR for every possible path, rather than a slot-by-slot basis. But in some cases slot-by-slot is better i.e. when kN(N-1)/2 > LS Args: state (RSAGNModelEnvState): Environment state params (RSAGNModelEnvParams): Environment parameters
Returns:
| Type | Description |
|---|---|
Array
|
chex.array: SNR for each link on path |
Source code in xlron/environments/env_funcs.py
3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 | |
get_line_graph_laplacian(graph)
Compute the Laplacian matrix of the line graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
NetworkX graph (original topology) |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Laplacian matrix of the line graph as a JAX array |
Source code in xlron/environments/env_funcs.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_line_graph_spectral_features(graph, num_features)
Compute spectral features for edges using the line graph Laplacian.
These features are used as positional encodings for transformer architectures with WiRE (Wavelet-Induced Rotary Encodings).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
NetworkX graph (original topology) |
required |
num_features
|
int
|
Number of spectral features to compute |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Array of shape (num_edges, num_features) containing eigenvectors of the |
Array
|
line graph Laplacian, ordered by ascending eigenvalue magnitude. |
Array
|
These serve as positional encodings for edge/link tokens. |
Source code in xlron/environments/env_funcs.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_link_relevance_array(paths, paths_se, requested_datarate, params)
Compute 4 link relevance features for the current request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Array
|
(k, E) binary path-link indicators |
required |
paths_se
|
Array
|
(k, 1) spectral efficiency per path |
required |
requested_datarate
|
Array
|
(1,) |
required |
params
|
RSAEnvParams
|
environment parameters |
required |
Returns:
| Type | Description |
|---|---|
|
(E, 4) array with columns: 0: weighted_relevance - combined rank/SE weighted sum across paths 1: path_count - fraction of k paths using each link 2: best_rank - 1 - min_rank/k for links on any path, 0 otherwise 3: best_se - max SE among paths through link, normalized |
Source code in xlron/environments/env_funcs.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
get_minimum_snr_of_channels_on_path(state, path, slot_index, req_slots, params)
Get the minimum value of the SNR on newly assigned channels. N.B. this requires the link_snr_array to have already been calculated and present in state.
Source code in xlron/environments/env_funcs.py
3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 | |
get_obs_transformer(state, params)
Retrieves observation for transformer model.
Creates tokens for each link/edge. Column order: [wire_features | edge_features | traffic_marginals | request-specific...] where request-specific features are at the end so the critic can strip them.
Request-specific columns (stripped for critic): - holding_time (1 col, departure mode only) - request_size (1 col) - link_relevance (4 cols)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
RSAEnvState
|
Environment state |
required |
params
|
RSAEnvParams
|
Environment parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tokens |
Array
|
Array of shape (num_links, input_size) |
Source code in xlron/environments/env_funcs.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
get_path(params, nodes, k_path_index)
Get k paths between source and destination
Source code in xlron/environments/env_funcs.py
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | |
get_path_and_se(params, nodes, k_path_index)
Get k paths and their spectral efficiencies between source and destination
Source code in xlron/environments/env_funcs.py
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | |
get_path_from_path_index_array(path_index_array, path_link_array)
Get path from path index array. Args: path_index_array (chex.Array): Path index array path_link_array (chex.Array): Path link array
Returns:
| Type | Description |
|---|---|
Array
|
jnp.array: path index values replaced with binary path-link arrays |
Source code in xlron/environments/env_funcs.py
3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 | |
get_path_index(params, nodes, k_path_index)
Get k paths between source and destination
Source code in xlron/environments/env_funcs.py
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 | |
get_path_index_array(params, nodes)
Indices of paths between source and destination from path array
Source code in xlron/environments/env_funcs.py
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | |
get_path_se(params, nodes, k_path_index)
Get k paths between source and destination
Source code in xlron/environments/env_funcs.py
1113 1114 1115 1116 1117 1118 1119 | |
get_path_slots(link_slot_array, params, nodes_sd, i, agg_func='max')
Get slots on each constitutent link of path from link_slot_array (L x S), then aggregate to get (S x 1) representation of slots on path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_slot_array
|
Array
|
link-slot array |
required |
params
|
EnvParams
|
environment parameters |
required |
nodes_sd
|
Array
|
source-destination nodes |
required |
i
|
int
|
path index |
required |
agg_func
|
str
|
aggregation function (max or sum). If max, result will be available slots on path. If sum, result will contain information on edge features. if mean, will be mean. |
'max'
|
Returns:
| Name | Type | Description |
|---|---|---|
slots |
Array
|
slots on path |
Source code in xlron/environments/env_funcs.py
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 | |
get_paths(params, nodes)
Get k paths between source and destination
Source code in xlron/environments/env_funcs.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 | |
get_paths_obs_gn_model(state, params)
Get observation space for launch power optimization (with numerical stability).
Source code in xlron/environments/env_funcs.py
4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 | |
get_paths_se(params, nodes)
Get max. spectral efficiency of modulation format on k paths between source and destination
Source code in xlron/environments/env_funcs.py
1122 1123 1124 1125 1126 1127 1128 1129 | |
get_required_snr_se_kurtosis_array(modulation_format_index_array, col_index, params)
Convert modulation format index to required SNR or spectral efficiency. Modulation format index array contains the index of the modulation format used by the channel. The modulation index references a row in the modulations array, which contains SNR and SE values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modulation_format_index_array
|
Array
|
Modulation format index array |
required |
col_index
|
int
|
Column index for required SNR or spectral efficiency |
required |
params
|
RSAGNModelEnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
jnp.array: Required SNR for each channel (min. SNR for empty channel (mod. index 0)) |
Source code in xlron/environments/env_funcs.py
3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 | |
get_snr_link_array(state, params)
Get SNR per link Args: state (EnvState): Environment state params (EnvParams): Environment parameters Returns: jnp.array: SNR per link
Source code in xlron/environments/env_funcs.py
3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 | |
get_snr_link_array_fused(state, params)
Get SNR per link using fused computation (uniform spans, no mod_format_correction).
Drop-in replacement for get_snr_link_array that uses get_snr_fused to reduce XLA op count and kernel launch overhead on GPU.
Source code in xlron/environments/env_funcs.py
3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 | |
get_spectral_features(laplacian, num_features)
Compute spectral node features from symmetric normalized graph Laplacian.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adj
|
Adjacency matrix of the graph |
required | |
num_features
|
int
|
Number of eigenvector features to extract |
required |
Returns:
| Type | Description |
|---|---|
Array
|
Array of shape (n_nodes, num_features) containing eigenvectors corresponding |
Array
|
to the smallest non-zero eigenvalues of the graph Laplacian. If the graph has |
Array
|
fewer nodes than num_features, the result is zero-padded to have num_features columns. |
Notes
- Skips trivial eigenvectors (those with near-zero eigenvalues)
- Eigenvectors are ordered by ascending eigenvalue magnitude
- Runtime is O(n^3) - use only for small/medium graphs
- Eigenvector signs are arbitrary (may vary between runs)
Source code in xlron/environments/env_funcs.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
implement_action_rmsa_gn_model(state, action_info, params)
Implement action for RSA GN model. Update following arrays: - link_slot_array - link_slot_departure_array - link_snr_array - modulation_format_index_array - channel_power_array - active_path_array Args: state (EnvState): Environment state action (chex.Array): Action tuple (first is path action, second is launch_power) params (EnvParams): Environment parameters Returns: EnvState: Updated environment state
Source code in xlron/environments/env_funcs.py
3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 | |
implement_action_rsa(state, action_info, params)
Implement action to assign slots on links.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
RSAEnvState
|
current state |
required |
action
|
action to implement |
required | |
params
|
RSAEnvParams
|
environment parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
EnvState
|
updated state |
Source code in xlron/environments/env_funcs.py
1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 | |
implement_action_rsa_gn_model(state, action_info, params)
Implement action for RSA GN model. Update following arrays: - link_slot_array - link_slot_departure_array - link_snr_array - modulation_format_index_array - channel_power_array - active_path_array Args: state (EnvState): Environment state action (chex.Array): Action tuple (first is path action, second is launch_power) params (EnvParams): Environment parameters Returns: EnvState: Updated environment state
Source code in xlron/environments/env_funcs.py
3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 | |
init_active_lightpaths_array(params)
Initialise active lightpath array. Stores path indices of all active paths on the network in a 1 x M array. M is MIN(max_requests, num_links * link_resources / min_slots). min_slots is the minimum number of slots required for a lightpath i.e. max(values_bw)/ slot_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
RSAGNModelEnvParams
|
Environment parameters |
required |
Returns: jnp.array: Active path array (default value -1, empty path)
Source code in xlron/environments/env_funcs.py
3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 | |
init_active_lightpaths_array_departure(params)
Initialise active lightpath array. Stores path indices of all active paths on the network in a 1 x M array. M is MIN(max_requests, num_links * link_resources / min_slots). min_slots is the minimum number of slots required for a lightpath i.e. max(values_bw)/ slot_size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
RSAGNModelEnvParams
|
Environment parameters |
required |
Returns: jnp.array: Active path array (default value -1, empty path)
Source code in xlron/environments/env_funcs.py
3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 | |
init_active_path_array(params)
Initialise active path array. Stores details of full path utilised by lightpath on each frequency slot. Args: params (EnvParams): Environment parameters Returns: jnp.array: Active path array
Source code in xlron/environments/env_funcs.py
2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 | |
init_channel_centre_bw_array(params)
Initialise channel centre array. Args: params (EnvParams): Environment parameters Returns: jnp.array: Channel centre array
Source code in xlron/environments/env_funcs.py
2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 | |
init_channel_centre_freq_array(params)
Initialise channel centre frequency array. Args: params (EnvParams): Environment parameters Returns: jnp.array: Channel centre frequency array (GHz)
Source code in xlron/environments/env_funcs.py
2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 | |
init_channel_power_array(params)
Initialise channel power array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
EnvParams
|
Environment parameters |
required |
Returns: jnp.array: Channel power array
Source code in xlron/environments/env_funcs.py
2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 | |
init_graph_tuple(state, params, adj, exclude_source_dest=False)
Initialise graph tuple for use with Jraph GNNs. Args: state (EnvState): Environment state params (EnvParams): Environment parameters adj (jnp.array): Adjacency matrix of the graph Returns: jraph.GraphsTuple: Graph tuple
Source code in xlron/environments/env_funcs.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
init_link_capacity_array(params)
Initialise link capacity array. Represents available data rate for lightpath on each link. Default is high value (1e6) for unoccupied slots. Once lightpath established, capacity is determined by corresponding entry in path capacity array.
Source code in xlron/environments/env_funcs.py
2386 2387 2388 2389 2390 | |
init_link_length_array(graph)
Initialise link length array. Args: graph (nx.Graph): NetworkX graph Returns:
Source code in xlron/environments/env_funcs.py
332 333 334 335 336 337 338 339 340 341 342 | |
init_link_length_array_gn_model(graph, max_span_length, max_spans)
Initialise link length array for environements that use GN model of physical layer. We assume each link has spans of equal length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
NetworkX graph |
required |
max_span_length
|
int
|
Maximum span length in metres |
required |
max_spans
|
int
|
Maximum number of spans per link |
required |
Returns: jnp.array: Link length array (L x max_spans) in metres
Source code in xlron/environments/env_funcs.py
2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 | |
init_link_slot_array(params)
Initialize empty (all zeroes) link-slot array. 0 means slot is free, -1 means occupied. Args: params (EnvParams): Environment parameters Returns: jnp.array: Link slot array (E x S) where E is number of edges and S is number of slots
Source code in xlron/environments/env_funcs.py
815 816 817 818 819 820 821 822 823 824 | |
init_link_slot_mask(params, include_no_op=False, agg=1.0)
Initialize link mask
Source code in xlron/environments/env_funcs.py
832 833 834 835 836 837 838 | |
init_link_snr_array(params)
Initialise signal-to-noise ratio (SNR) array. Args: params (EnvParams): Environment parameters Returns: jnp.array: SNR array
Source code in xlron/environments/env_funcs.py
2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 | |
init_mod_format_mask(params)
Initialize link mask
Source code in xlron/environments/env_funcs.py
841 842 843 844 845 846 | |
init_modulation_format_index_array(params)
Initialise modulation format index array. Args: params (EnvParams): Environment parameters Returns: jnp.array: Modulation format index array
Source code in xlron/environments/env_funcs.py
2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 | |
init_modulations_array(modulations_filepath=None)
Initialise array of maximum spectral efficiency for modulation format on path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modulations_filepath
|
str
|
Path to CSV file containing modulation formats. Defaults to None. |
None
|
Returns: jnp.array: Array of maximum spectral efficiency for modulation format on path. First two columns are maximum path length and spectral efficiency.
Source code in xlron/environments/env_funcs.py
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
init_path_capacity_array(link_length_array, path_link_array, min_request=1, scale_factor=1.0, alpha=0.0002, NF=4.5, B=10000000000000.0, R_s=100000000000.0, beta_2=-2.17e-26, gamma=0.0012, L_s=100000.0, lambda0=1.55e-06)
Calculated from Nevin paper: https://api.repository.cam.ac.uk/server/api/core/bitstreams/b80e7a9c-a86b-4b30-a6d6-05017c60b0c8/content
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_length_array
|
Array
|
Array of link lengths |
required |
path_link_array
|
Array
|
Array of links on paths |
required |
min_request
|
int
|
Minimum data rate request size. Defaults to 100 GBps. |
1
|
scale_factor
|
float
|
Scale factor for link capacity. Defaults to 1.0. |
1.0
|
alpha
|
float
|
Fibre attenuation coefficient. Defaults to 0.2e-3 /m |
0.0002
|
NF
|
float
|
Amplifier noise figure. Defaults to 4.5 dB. |
4.5
|
B
|
float
|
Total modulated bandwidth. Defaults to 10e12 Hz. |
10000000000000.0
|
R_s
|
float
|
Symbol rate. Defaults to 100e9 Baud. |
100000000000.0
|
beta_2
|
float
|
Dispersion parameter. Defaults to -21.7e-27 s^2/m. |
-2.17e-26
|
gamma
|
float
|
Nonlinear coefficient. Defaults to 1.2e-3 /W/m. |
0.0012
|
L_s
|
float
|
Span length. Defaults to 100e3 m. |
100000.0
|
lambda0
|
float
|
Wavelength. Defaults to 1550e-9 m. |
1.55e-06
|
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Array of link capacities in Gbps |
Source code in xlron/environments/env_funcs.py
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 | |
init_path_index_array(params)
Initialise path index array. Represents index of lightpath occupying each slot.
Source code in xlron/environments/env_funcs.py
2393 2394 2395 | |
init_path_length_array(path_link_array, graph)
Initialise path length array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_link_array
|
Array
|
Path-link array |
required |
graph
|
Graph
|
NetworkX graph |
required |
Returns: chex.Array: Path length array
Source code in xlron/environments/env_funcs.py
676 677 678 679 680 681 682 683 684 685 686 687 | |
init_path_link_array(graph, k, disjoint=False, path_sort_criteria='', directed=False, modulations_array=None, rwa_lr=False, scale_factor=1.0, path_snr=False)
Initialise path-link array. Each path is defined by a link utilisation array (one row in the path-link array). 1 indicates link corresponding to index is used, 0 indicates not used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
NetworkX graph |
required |
k
|
int
|
Number of paths |
required |
disjoint
|
bool
|
Whether to use edge-disjoint paths. Defaults to False. |
False
|
weight
|
str
|
Sort paths by edge attribute. Defaults to "". |
required |
directed
|
bool
|
Whether graph is directed. Defaults to False. |
False
|
modulations_array
|
Array
|
Array of maximum spectral efficiency for modulation format on path. Defaults to None. |
None
|
rwa_lr
|
bool
|
Whether the environment is RWA with lightpath reuse (affects path ordering). |
False
|
path_snr
|
bool
|
If GN model is used, include extra row of zeroes for unutilised paths |
False
|
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Path-link array (N(N-1)*k x E) where N is number of nodes, E is number of edges, k is number of shortest paths |
Source code in xlron/environments/env_funcs.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
init_path_se_array(path_length_array, modulations_array)
Initialise array of maximum spectral efficiency for highest-order modulation format on path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_length_array
|
array
|
Array of path lengths |
required |
modulations_array
|
array
|
Array of maximum spectral efficiency for modulation format on path |
required |
Returns:
| Type | Description |
|---|---|
Array
|
jnp.array: Array of maximum spectral efficiency for on path |
Source code in xlron/environments/env_funcs.py
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | |
init_rsa_request_array()
Initialize request array
Source code in xlron/environments/env_funcs.py
827 828 829 | |
init_traffic_matrix(key, params)
Initialize traffic matrix. Allows for random traffic matrix or uniform traffic matrix. Source-dest traffic requests are sampled probabilistically from the resulting traffic matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
PRNGKey
|
PRNG key |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
jnp.array: Traffic matrix |
Source code in xlron/environments/env_funcs.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | |
init_transceiver_amplifier_noise_arrays(link_resources, ref_lambda, slot_size, noise_data_filepath=None, slot_frequencies_ghz=None)
Initialise transceiver, amplifier, and ROADM noise arrays from per-band CSV data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link_resources
|
int
|
Number of link resources. |
required |
ref_lambda
|
float
|
Reference wavelength. |
required |
slot_size
|
float
|
Slot size in GHz. |
required |
noise_data_filepath
|
str
|
Path to CSV file. Defaults to None. |
None
|
slot_frequencies_ghz
|
ndarray
|
Pre-computed absolute slot centre frequencies in GHz. When provided, these are used directly instead of computing from the uniform formula. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[Array, Array, Array, Array, Array]
|
Tuple of per-slot arrays: (transceiver_snr, amplifier_noise_figure, roadm_express_loss, roadm_add_drop_loss, roadm_noise_figure) |
Source code in xlron/environments/env_funcs.py
2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 | |
make_graph(topology_name='conus', topology_directory=None)
Create graph from topology definition. Topologies must be defined in JSON format in the topologies directory and named as the topology name with .json extension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topology_name
|
str
|
topology name |
'conus'
|
topology_directory
|
str | None
|
topology directory |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
graph |
graph |
Source code in xlron/environments/env_funcs.py
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 | |
make_line_graph(graph)
Create the line graph of a NetworkX graph.
The line graph L(G) has: - One node for each edge in the original graph G - An edge between two nodes in L(G) if the corresponding edges in G share a node
This is used for transformer architectures where we treat edges (links) as tokens and need positional encodings based on edge relationships.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
NetworkX graph (original topology) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
line_graph |
Graph
|
NetworkX line graph where nodes correspond to edges in the original |
Source code in xlron/environments/env_funcs.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
mask_slots_rmsa_gn_model(state, params, request)
Compute action mask for RMSA with GN model physical layer.
For each (path, modulation_format) pair, finds first-fit and last-fit candidate slot positions, evaluates them via the ISRS GN model, and builds a mask indicating which slots are valid (with the modulation format index stored in mod_format_mask).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
RSAGNModelEnvState
|
Environment state |
required |
params
|
RSAGNModelEnvParams
|
Environment parameters |
required |
request
|
Array
|
Request array in format [source_node, data-rate, destination_node] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
EnvState
|
Updated environment state with link_slot_mask and mod_format_mask |
Source code in xlron/environments/env_funcs.py
3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 | |
mask_slots_rwalr(state, params, request)
For use in RWALightpathReuseEnv. Each lightpath has a maximum capacity defined in path_capacity_array. This is updated when a lightpath is assigned. If remaining path capacity is less than current request, corresponding link-slots are masked out. If link-slot is in use by another lightpath for a different source and destination node (even if not full) it is masked out. Step 1: - Mask out slots that are not valid based on path capacity (check link_capacity_array) Step 2: - Mask out slots that are not valid based on lightpath reuse (check path_index_array)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
request
|
Array
|
Request array in format [source_node, data-rate, destination_node] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
EnvState
|
Updated environment state |
Source code in xlron/environments/env_funcs.py
2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 | |
normalise_traffic_matrix(traffic_matrix)
Normalise traffic matrix to sum to 1
Source code in xlron/environments/env_funcs.py
863 864 865 866 | |
pad_array(array, fill_value)
Pad a ragged multidimensional array to rectangular shape. Used for training on multiple topologies. Source: https://codereview.stackexchange.com/questions/222623/pad-a-ragged-multidimensional-array-to-rectangular-shape
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
array to pad |
required | |
fill_value
|
value to fill with |
required |
Returns:
| Name | Type | Description |
|---|---|---|
result |
padded array |
Source code in xlron/environments/env_funcs.py
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 | |
poisson(key, lam, shape=(), dtype=dtypes.float_)
Sample Exponential random values with given shape and float dtype.
The values are distributed according to the probability density function:
.. math:: f(x) = \lambda e^{-\lambda x}
on the domain :math:0 \le x < \infty.
Args:
key: a PRNG key used as the random key.
lam: a positive float32 or float64 Tensor indicating the rate parameter
shape: optional, a tuple of nonnegative integers representing the result
shape. Default ().
dtype: optional, a float dtype for the returned values (default float64 if
jax_enable_x64 is true, otherwise float32).
Returns: A random array with the specified shape and dtype.
Source code in xlron/environments/env_funcs.py
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | |
process_path_action(state, params, path_action)
Process path action to get path index and initial slot index. Args: state (State): current state params (Params): environment parameters path_action (int): path action Returns: int: path index int: initial slot index
Source code in xlron/environments/env_funcs.py
1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | |
read_rsa_request(request_array)
Read RSA request from request array. Return source-destination nodes and bandwidth request. Args: request_array: request array Returns: Tuple[chex.Array, chex.Array]: source-destination nodes and bandwidth request
Source code in xlron/environments/env_funcs.py
1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 | |
remove_expired_services_rwalr(state, params)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
Optional[EnvParams]
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
EnvState
|
Updated environment state |
Source code in xlron/environments/env_funcs.py
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | |
required_slots(bitrate, se, channel_width, guardband=1, temperature=1.0, differentiable=True)
Calculate required slots for a given bitrate and spectral efficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bit_rate
|
float
|
Bit rate in Gbps |
required |
se
|
float
|
Spectral efficiency in bps/Hz |
required |
channel_width
|
float
|
Channel width in GHz |
required |
guardband
|
int
|
Guard band. Defaults to 1. |
1
|
temperature
|
float
|
Temperature for differentiable approximation. Defaults to 1.0. |
1.0
|
differentiable
|
bool
|
If False, use non-differentiable operations. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Required slots |
Source code in xlron/environments/env_funcs.py
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
set_band_gaps(link_slot_array, params, val)
Set band gaps in link slot array Args: link_slot_array (chex.Array): Link slot array params (RSAGNModelEnvParams): Environment parameters val (int): Value to set Returns: chex.Array: Link slot array with band gaps
Source code in xlron/environments/env_funcs.py
3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 | |
update_active_lightpaths_array(state, path_index, initial_slot_index, num_slots)
Update active lightpaths array with new path index. Find the first index of the array with value -1 and replace with path index. Args: state (RSAGNModelEnvState): Environment state path_index (int): Path index to add to active lightpaths array Returns: jnp.array: Updated active lightpaths array
Source code in xlron/environments/env_funcs.py
3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 | |
update_active_lightpaths_array_departure(state, time)
Update active lightpaths array with new path index. Find the first index of the array with value -1 and replace with path index. Args: state (RSAGNModelEnvState): Environment state time (float): Departure time Returns: jnp.array: Updated active lightpaths array
Source code in xlron/environments/env_funcs.py
3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 | |
update_graph_tuple(state, params)
Update graph tuple for use with Jraph GNNs.
Edge and node features are updated from link_slot_array and node_capacity_array respectively. Global features are updated as request_array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
EnvState
|
Environment state with updated graph tuple |
Source code in xlron/environments/env_funcs.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
Training Utilities
TrainState
Bases: Module
Train state for Equinox models.
The model is stored but marked as non-pytree so JAX doesn't try to trace it.
Source code in xlron/train/train_utils.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
apply_gradients(grads)
Updates model parameters and opt_state.
Source code in xlron/train/train_utils.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
create(model, tx, lr_schedule=lambda x: jnp.array(0.0), ent_schedule=lambda x: jnp.array(0.0), vml_schedule=lambda x: jnp.array(0.0), prio_alpha=0.0, prio_beta0=1.0, prio_beta=1.0, reward_stepsize_init=0.001, initial_avg_reward=0.0)
staticmethod
Creates a new instance with step=0 and initialized opt_state.
Source code in xlron/train/train_utils.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
update_step_size()
Updates the step size used for reward centering.
Source code in xlron/train/train_utils.py
172 173 174 175 176 177 178 179 180 181 182 | |
count_parameters(params)
Counts the number of parameters in a parameter tree.
Source code in xlron/train/train_utils.py
224 225 226 | |
get_warmup_fn(warmup_state, env, params, train_state, config)
Warmup period for DeepRMSA.
Source code in xlron/train/train_utils.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | |
log_metrics(config, out, total_run_time, increment_run_time, merge_func, episode_count=0, update_count=0, step_count=0)
Log metrics to wandb and/or save episode end metrics to CSV.
Source code in xlron/train/train_utils.py
1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 | |
make_ent_schedule(config)
Create an entropy coefficient schedule based on the configuration.
Source code in xlron/train/train_utils.py
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | |
make_lr_schedule(config)
Create a learning rate schedule based on the configuration.
Source code in xlron/train/train_utils.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 | |
make_vf_lr_schedule(config)
Create a learning rate schedule for the value function optimizer.
Source code in xlron/train/train_utils.py
1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
make_vml_schedule(config)
Create a valid mass loss coefficient schedule based on the configuration.
Source code in xlron/train/train_utils.py
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 | |
merge_leading_dims(x, num_dims)
Merge leading dimensions.
Note
This implementation is a generic function for merging leading dimensions extracted from Haiku. For the original implementation, please refer to the following link: (https://github.com/deepmind/dm-haiku/blob/main/haiku/_src/basic.py#L207)
Source code in xlron/train/train_utils.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
ndim_at_least(x, num_dims)
Check if the number of dimensions of x is at least num_dims.
Source code in xlron/train/train_utils.py
404 405 406 407 408 | |
print_experiment_summary(config, env_params=None)
Print a formatted summary of the experiment configuration.
Source code in xlron/train/train_utils.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
process_metrics(config, out, merge_func)
Calculate statistics from training or evaluation run.
Source code in xlron/train/train_utils.py
1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 | |
run_eval_during_training(config, run_eval, eval_input, out, best_eval_metric, step_count, first_save=True)
Run evaluation during training and save model if it improves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Box
|
Training configuration. |
required |
run_eval
|
Callable
|
Compiled eval function. |
required |
eval_input
|
Tuple
|
Initial eval runner state (train_state, env_state, obsv, rng_step, rng_epoch). |
required |
out
|
Dict
|
Output from the current training increment. |
required |
best_eval_metric
|
float
|
Best eval metric seen so far. |
required |
step_count
|
int
|
Current training env step count (for wandb logging). |
required |
first_save
|
bool
|
Whether this is the first save of the training run. |
True
|
Returns:
| Type | Description |
|---|---|
Tuple
|
Tuple of (updated best_eval_metric, updated first_save). |
Source code in xlron/train/train_utils.py
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 | |
scale_gradient(g, scale=1)
Scales the gradient of g by scale but keeps the original value unchanged.
Source code in xlron/train/train_utils.py
219 220 221 | |
select_action(select_action_state, env, env_params, train_state, config)
Select an action from the policy. If using VONE, the action is a tuple of (source, path, destination). Otherwise, the action is a single lightpath. Args: select_action_state: Tuple of (rng_key, env_state, last_obs) env: Environment env_params: Environment parameters train_state: TrainState config: Configuration Returns: env_state: Environment state action: Action log_prob: Log probability of action value: Value of state
Source code in xlron/train/train_utils.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 | |
unreplicate_batch_dim(x)
Unreplicated just the update batch dimension. (The dimension that is vmapped over when acting and learning)
In stoix's case it is always the second dimension, after the device dimension. We simply take element 0 as the params are identical across this dimension.
Source code in xlron/train/train_utils.py
438 439 440 441 442 443 444 445 | |
unreplicate_n_dims(x, unreplicate_depth=2)
Unreplicates a pytree by removing the first unreplicate_depth axes.
This function takes a pytree and removes some number of axes, associated with parameter
duplication for running multiple updates across devices and in parallel with vmap.
This is typically one axis for device replication, and one for the update batch size.
Source code in xlron/train/train_utils.py
428 429 430 431 432 433 434 435 | |
Models
ActorCriticMLP
Bases: Module
Actor-Critic MLP using Equinox.
Source code in xlron/models/mlp.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
sample_action(seed, dist, log_prob=False, deterministic=False)
Sample an action from the distribution
Source code in xlron/models/mlp.py
229 230 231 232 233 234 235 236 237 238 239 240 | |
LaunchPowerActorCriticMLP
Bases: Module
Actor-Critic MLP for launch power optimization.
Takes an observation of the current request + statistics on each of the K candidate paths. Makes K forward passes, one for each path, and outputs a distribution over power levels for each path.
Source code in xlron/models/mlp.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
num_power_levels
property
Calculate number of power levels dynamically
power_levels
property
Calculate power levels dynamically
get_action_probs(dist)
Get probabilities for discrete case or pdf for continuous case
Source code in xlron/models/mlp.py
428 429 430 431 432 433 434 | |
sample_action(seed, dist, log_prob=False, deterministic=False)
Sample an action and convert to power level
Source code in xlron/models/mlp.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
MLP
Bases: Module
Simple MLP module using Equinox.
Source code in xlron/models/mlp.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
bfloat16_safe_orthogonal(scale=1.0)
Returns an orthogonal initializer that is safe for bfloat16.
Source code in xlron/models/mlp.py
82 83 84 85 86 87 88 | |
constant(value)
Returns a constant initializer.
Source code in xlron/models/mlp.py
91 92 93 94 95 96 97 | |
crelu(x)
Computes the Concatenated ReLU (CReLU) activation function.
Source code in xlron/models/mlp.py
66 67 68 69 | |
make_linear_with_orthogonal_init(in_features, out_features, key, scale=1.0, dtype=None)
Create a Linear layer with orthogonal initialization.
Source code in xlron/models/mlp.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
orthogonal_init(key, shape, scale=1.0, dtype=jnp.float32)
Orthogonal initializer that is safe for bfloat16 and other dtypes. Based on JAX/Flax orthogonal initializer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Array
|
PRNGKey for initialization |
required |
shape
|
Tuple[int, ...]
|
Shape of the weight matrix |
required |
scale
|
float
|
Scaling factor for the orthogonal matrix |
1.0
|
dtype
|
dtype
|
Target dtype (will init in float32 then cast) |
float32
|
Returns:
| Type | Description |
|---|---|
Array
|
Orthogonally initialized weight matrix |
Source code in xlron/models/mlp.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
select_activation(activation)
Selects the activation function based on the provided string.
Source code in xlron/models/mlp.py
72 73 74 75 76 77 78 79 | |
ActorCriticGNN
Bases: Module
Combined Actor-Critic GNN model.
Source code in xlron/models/gnn.py
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | |
sample_action(seed, dist, log_prob=False, deterministic=False)
Sample an action from the distributions.
Source code in xlron/models/gnn.py
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 | |
sample_action_path(seed, dist, log_prob=False, deterministic=False)
Sample an action from the distribution.
Source code in xlron/models/gnn.py
1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | |
sample_action_path_power(seed, dist, log_prob=False, deterministic=False)
Sample an action from the distributions.
Source code in xlron/models/gnn.py
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 | |
sample_action_power(seed, dist, log_prob=False, deterministic=False)
Sample an action and convert to power level
Source code in xlron/models/gnn.py
1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 | |
ActorGNN
Bases: Module
Actor network using GNN for processing graph state.
Source code in xlron/models/gnn.py
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | |
CriticGNN
Bases: Module
Critic network using GNN for processing graph state.
Source code in xlron/models/gnn.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
GraphNet
Bases: Module
A complete Graph Network model defined with Jraph and Equinox.
Source code in xlron/models/gnn.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 | |
GAT(attention_query_fn, attention_logit_fn, node_update_fn=None)
Returns a method that applies a Graph Attention Network layer.
Graph Attention message passing as described in https://arxiv.org/abs/1710.10903. This model expects node features as a jnp.array, may use edge features for computing attention weights, and ignore global features. It does not support nests.
NOTE: this implementation assumes that the input graph has self edges. To recover the behavior of the referenced paper, please add self edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attention_query_fn
|
GATAttentionQueryFn
|
function that generates attention queries from sender node features. |
required |
attention_logit_fn
|
GATAttentionLogitFn
|
function that converts attention queries into logits for softmax attention. |
required |
node_update_fn
|
Optional[GATNodeUpdateFn]
|
function that updates the aggregated messages. If None, will apply leaky relu and concatenate (if using multi-head attention). |
None
|
Returns:
| Type | Description |
|---|---|
|
A function that applies a Graph Attention layer. |
Source code in xlron/models/gnn.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
GraphNetGAT(update_edge_fn, update_node_fn, attention_logit_fn, attention_reduce_fn, update_global_fn=None, aggregate_edges_for_nodes_fn=utils.segment_sum, aggregate_nodes_for_globals_fn=utils.segment_sum, aggregate_edges_for_globals_fn=utils.segment_sum)
Returns a method that applies a GraphNet with attention on edge features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_edge_fn
|
GNUpdateEdgeFn
|
function used to update the edges. |
required |
update_node_fn
|
GNUpdateNodeFn
|
function used to update the nodes. |
required |
attention_logit_fn
|
AttentionLogitFn
|
function used to calculate the attention weights. |
required |
attention_reduce_fn
|
AttentionReduceFn
|
function used to apply attention weights to the edge features. |
required |
update_global_fn
|
Optional[GNUpdateGlobalFn]
|
function used to update the globals or None to deactivate globals updates. |
None
|
aggregate_edges_for_nodes_fn
|
AggregateEdgesToNodesFn
|
function used to aggregate attention-weighted messages to each node. |
segment_sum
|
aggregate_nodes_for_globals_fn
|
AggregateNodesToGlobalsFn
|
function used to aggregate the nodes for the globals. |
segment_sum
|
aggregate_edges_for_globals_fn
|
AggregateEdgesToGlobalsFn
|
function used to aggregate attention-weighted edges for the globals. |
segment_sum
|
Returns:
| Type | Description |
|---|---|
|
A function that applies a GraphNet Graph Attention layer. |
Source code in xlron/models/gnn.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
GraphNetwork(update_edge_fn, update_node_fn, update_global_fn=None, aggregate_edges_for_nodes_fn=utils.segment_sum, aggregate_nodes_for_globals_fn=utils.segment_sum, aggregate_edges_for_globals_fn=utils.segment_sum, attention_logit_fn=None, attention_normalize_fn=utils.segment_softmax, attention_reduce_fn=None)
Returns a method that applies a configured GraphNetwork.
This implementation follows Algorithm 1 in https://arxiv.org/abs/1806.01261
There is one difference. For the nodes update the class aggregates over the sender edges and receiver edges separately. This is a bit more general than the algorithm described in the paper. The original behaviour can be recovered by using only the receiver edge aggregations for the update.
In addition this implementation supports softmax attention over incoming edge features.
Example usage::
gn = GraphNetwork(update_edge_function, update_node_function, **kwargs) # Conduct multiple rounds of message passing with the same parameters: for _ in range(num_message_passing_steps): graph = gn(graph)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update_edge_fn
|
Optional[GNUpdateEdgeFn]
|
function used to update the edges or None to deactivate edge updates. |
required |
update_node_fn
|
Optional[GNUpdateNodeFn]
|
function used to update the nodes or None to deactivate node updates. |
required |
update_global_fn
|
Optional[GNUpdateGlobalFn]
|
function used to update the globals or None to deactivate globals updates. |
None
|
aggregate_edges_for_nodes_fn
|
AggregateEdgesToNodesFn
|
function used to aggregate messages to each node. |
segment_sum
|
aggregate_nodes_for_globals_fn
|
AggregateNodesToGlobalsFn
|
function used to aggregate the nodes for the globals. |
segment_sum
|
aggregate_edges_for_globals_fn
|
AggregateEdgesToGlobalsFn
|
function used to aggregate the edges for the globals. |
segment_sum
|
attention_logit_fn
|
Optional[AttentionLogitFn]
|
function used to calculate the attention weights or None to deactivate attention mechanism. |
None
|
attention_normalize_fn
|
Optional[AttentionNormalizeFn]
|
function used to normalize raw attention logits or None if attention mechanism is not active. |
segment_softmax
|
attention_reduce_fn
|
Optional[AttentionReduceFn]
|
function used to apply weights to the edge features or None if attention mechanism is not active. |
None
|
Returns:
| Type | Description |
|---|---|
|
A method that applies the configured GraphNetwork. |
Source code in xlron/models/gnn.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
add_graphs_tuples(graphs, other_graphs)
Adds the nodes, edges and global features from other_graphs to graphs.
Source code in xlron/models/gnn.py
380 381 382 383 384 385 386 387 388 | |
add_self_edges_fn(receivers, senders, total_num_nodes)
Adds self edges. Assumes self edges are not in the graph yet.
Source code in xlron/models/gnn.py
84 85 86 87 88 89 90 91 | |
ActorCriticTransformer
Bases: Module
Source code in xlron/models/transformer.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
__call__(state, params, *, enable_dropout=False, key=None)
Forward pass through the actor-critic transformer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
enable_dropout
|
bool
|
Whether to enable dropout |
False
|
key
|
PRNGKey | None
|
PRNG key for dropout |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[Categorical, Array]
|
Tuple of (action_distribution, value) |
Source code in xlron/models/transformer.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
sample_action(seed, dist, log_prob=False, deterministic=False)
Sample an action from the distribution
Source code in xlron/models/transformer.py
555 556 557 558 559 560 561 562 563 564 565 566 | |
AttentionBlock
Bases: Module
A single transformer attention block.
Source code in xlron/models/transformer.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
FeedForwardBlock
Bases: Module
A single transformer feed forward block.
Source code in xlron/models/transformer.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
TransformerLayer
Bases: Module
A single transformer layer.
Source code in xlron/models/transformer.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
WIRE
Bases: Module
Wavelet-Induced Rotary Encodings for graphs. https://openreview.net/pdf?id=f7BvsdILYx
Projects m-dimensional node features (e.g., RWSE, spectral coords) to rotation angles for RoPE-style positional encoding.
Source code in xlron/models/transformer.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
__call__(queries, keys, positions)
Apply WIRE to queries and keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
queries
|
Float[Array, 'num_nodes embedding_size']
|
Query vectors (num_nodes, embedding_size) |
required |
keys
|
Float[Array, 'num_nodes embedding_size']
|
Key vectors (num_nodes, embedding_size) |
required |
positions
|
Float[Array, 'num_nodes num_features']
|
Node position features, e.g., RWSE (num_nodes, num_features) |
required |
Returns:
| Type | Description |
|---|---|
tuple[Float[Array, 'num_nodes embedding_size'], Float[Array, 'num_nodes embedding_size']]
|
Rotated (queries, keys) |
Source code in xlron/models/transformer.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
__init__(num_features, embedding_size, key, freq_scale=0.01)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_features
|
int
|
Dimension of input position features (m) |
required |
embedding_size
|
int
|
Dimension of queries/keys to rotate (must be even) |
required |
key
|
PRNGKeyArray
|
PRNG key |
required |
freq_scale
|
float
|
Scale for frequency initialisation |
0.01
|
Source code in xlron/models/transformer.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_angles(positions)
Compute rotation angles from position features.
Source code in xlron/models/transformer.py
78 79 80 81 82 | |
rotate(x, angles)
Apply rotary encoding to queries or keys.
For each 2D block [x_{2i}, x_{2i+1}], rotate by angle theta_i: x_{2i}' = x_{2i} * cos(theta) - x_{2i+1} * sin(theta) x_{2i+1}' = x_{2i} * sin(theta) + x_{2i+1} * cos(theta)
Source code in xlron/models/transformer.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
Heuristics
best_fit(state, params)
Best-Fit Spectrum Allocation. Returns the best fit slot for each path.
Source code in xlron/heuristics/heuristics.py
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
bf_ksp(state, params)
Get the first available slot from the first k-shortest paths Method: Go through action mask and find the first available slot on all paths
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
ff_ksp(state, params)
Get the first available slot from all paths Method: Go through action mask and find the first available slot on all paths
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
first_fit(state, params)
First-Fit Spectrum Allocation. Returns the first fit slot for each path.
When band_slot_order_ff is set (GN model envs with --band_preference), slots are searched in band preference order rather than raw index order.
Source code in xlron/heuristics/heuristics.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
get_link_weights(state, params)
Get link weights based on occupancy for use in congestion-aware routing heuristics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
|
chex.Array: Link weights |
Source code in xlron/heuristics/heuristics.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
kca_ff(state, params)
Congestion-aware First Fit. Only suitable for RSA/RMSA. Method:
Source code in xlron/heuristics/heuristics.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |
kmc_ff(state, params)
K-Minimum Cut. Only suitable for RSA/RMSA. Method: 1. Go through action mask and find the first available slot on all paths. 2. For each path, allocate the first available slot. 3. Sum number of new consecutive zero regions (cuts) created by assignment (on each link) 4. Choose path that creates the fewest cuts.
Source code in xlron/heuristics/heuristics.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
kme_ff(state, params)
K-Minimum Entropy. Only suitable for RSA/RMSA. Method: 1. Go through action mask and find the first available slot on all paths. 2. For each path, allocate the first available slot. 3. Sum number of new consecutive zero regions (cuts) created by assignment (on each link) 4. Choose path that creates the fewest cuts.
Source code in xlron/heuristics/heuristics.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
kmf_ff(state, params)
K-Minimum Frag-size. Only suitable for RSA/RMSA. Method: 1. Go through action mask and find the first available slot on all paths. 2. For each path, allocate the first available slot. 3. Sum number of new consecutive zero regions (cuts) created by assignment (on each link) 4. Choose path that creates the fewest cuts.
Source code in xlron/heuristics/heuristics.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
ksp_bf(state, params)
Get the first available slot from all k-shortest paths Method: Go through action mask and find the first available slot, starting from shortest path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
ksp_ff(state, params)
Get the first available slot from the shortest available path Method: Go through action mask and find the first available slot, starting from shortest path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
ksp_ff_multiband(state, params)
Get the first available slot from all k-shortest paths in multiband scenario Method: Go through action mask and find the first available slot, starting from shortest path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
MultiBandRSAEnvState
|
Environment state specific to multiband operations |
required |
params
|
MultiBandRSAEnvParams
|
Environment parameters including multiband details |
required |
Returns: chex.Array: Action
Source code in xlron/heuristics/heuristics.py
56 57 58 59 60 61 62 63 64 65 66 | |
ksp_lf(state, params)
Get the last available slot on the shortest available path Method: Go through action mask and find the last available slot, starting from shortest path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
ksp_mu(state, params, unique_lightpaths, relative)
Get the most-used slot on the shortest available path. Method: Go through action mask and find the utilisation of available slots on each path. Find the shortest available path and choose the most utilised slot on that path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
unique_lightpaths
|
bool
|
Whether to consider unique lightpaths |
required |
relative
|
bool
|
Whether to return relative utilisation |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
last_fit(state, params)
Last-Fit Spectrum Allocation. Returns the last fit slot for each path.
When band_slot_order_lf is set (GN model envs with --band_preference), slots are searched in band preference order (descending within each band).
Source code in xlron/heuristics/heuristics.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
lf_ksp(state, params)
Get the last available slot from all paths Method: Go through action mask and find the last available slot on all paths
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
most_used(state, params, unique_lightpaths, relative)
Get the amount of utilised bandwidth on each lightpath. If RWA-LR environment, the utilisation of a slot is defined by either the count of unique active lightpahts on the slot (if unique_lightpaths is True) or the count of active lightpaths on the slot (if unique_lightpaths is False). If RSA-type environment, utilisation is the count of active lightpaths on that slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
unique_lightpaths
|
bool
|
Whether to consider unique lightpaths |
required |
relative
|
bool
|
Whether to return relative utilisation |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Most used slots (array length = link_resources) |
Source code in xlron/heuristics/heuristics.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
mu_ksp(state, params, unique_lightpaths, relative)
Use the most-used available slot on any path. The most-used slot is that which has the most unique lightpaths (if unique_lightpaths=True) or active lightpaths. Method: Go through action mask and find the usage of available slots, choose available slot that is most utilised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
EnvState
|
Environment state |
required |
params
|
EnvParams
|
Environment parameters |
required |
unique_lightpaths
|
bool
|
Whether to consider unique lightpaths |
required |
relative
|
bool
|
Whether to return relative utilisation |
required |
Returns:
| Type | Description |
|---|---|
Array
|
chex.Array: Action |
Source code in xlron/heuristics/heuristics.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |