Observation Functions¶
Protocol¶
ObservationFunction
¶
Return Types¶
BipartiteGraph¶
BipartiteGraph
dataclass
¶
EdgeFeatures¶
EdgeFeatures
dataclass
¶
NodeBipartite (alias)¶
gyozas.NodeBipartite is an alias for NodeBipartiteEcole. Prefer using it for code that does not need to distinguish between implementations.
NodeBipartiteEcole¶
NodeBipartiteEcole
¶
Pure-Python bipartite graph observation with configurable feature extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache
|
bool
|
When |
False
|
suppress_warnings
|
bool
|
Suppress shape-change warnings when passing |
False
|
static_col_features
|
tuple[str, ...]
|
Column features to extract. |
_DEFAULT_STATIC_COL
|
dynamic_col_features
|
tuple[str, ...]
|
Column features to extract. |
_DEFAULT_STATIC_COL
|
static_row_features
|
tuple[str, ...]
|
Row features to extract. |
_DEFAULT_STATIC_ROW
|
dynamic_row_features
|
tuple[str, ...]
|
Row features to extract. |
_DEFAULT_STATIC_ROW
|
Source code in gyozas/observations/node_bipartite_ecole.py
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 | |
extract(model, done, prev_var_features=None, prev_row_features=None, prev_edge_features=None)
¶
Extract the bipartite graph observation.
Returns:
| Type | Description |
|---|---|
BipartiteGraph or None
|
A :class: |
Source code in gyozas/observations/node_bipartite_ecole.py
getBipartiteGraphRepresentation(model, static_only=False, static_col_features=None, dynamic_col_features=None, static_row_features=None, dynamic_row_features=None, prev_col_features=None, prev_row_features=None, prev_edge_features=None, suppress_warnings=False)
classmethod
¶
Stateless extraction returning a 4-tuple.
Raises RuntimeError when the model is not in SOLVING stage.
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in gyozas/observations/node_bipartite_ecole.py
NodeBipartiteSCIP¶
NodeBipartiteSCIP
¶
Bipartite graph observation using PySCIPOpt's built-in C implementation.
Returns the LP relaxation as a bipartite graph between constraint rows and variable columns, following Gasse et al. (NeurIPS 2019).
Source code in gyozas/observations/node_bipartite_scip.py
Pseudocosts¶
Pseudocosts
¶
Pseudocost scores for LP branching candidates.
Mirrors ecole.observation.Pseudocosts, implemented in pure pyscipopt.
Pseudocosts are estimated incrementally from the branching history observed
during solving. For each branching decision recorded via
node.getParentBranchings(), the per-variable up/down pseudocosts are
updated as::
pseudocost[dir] = Σ obj_delta_k / Σ |frac_delta_k|
where obj_delta is the LP bound improvement at the child node and frac_delta is the LP fractionality consumed by the branching.
Returns a 1-D array of shape (n_vars,) with the branch score for each
LP candidate (NaN for non-candidates), or None outside the solving
stage.
Note
Only branchings observed while extract is called are tracked. Branchings
that SCIP performs between two calls (e.g. at nodes not visited by the agent)
are missed; those variables fall back to the _INIT_PSEUDOCOST prior.
Source code in gyozas/observations/pseudo_cost.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 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 | |
StrongBranchingScores¶
StrongBranchingScores
¶
Full strong branching scores for LP branching candidates.
Mirrors ecole.observation.StrongBranchingScores, implemented in pure pyscipopt.
For each LP branching candidate the observation temporarily enters probing
mode, solves the down-branch LP (var <= floor(lp_val)) and the up-branch
LP (var >= ceil(lp_val)), then combines the bound improvements into a
branch score via model.getBranchScoreMultiple.
The probing LPs are solved idempotently (no side-effects on SCIP state).
Returns a 1-D array of shape (n_vars,) with the score for each LP
candidate (NaN for non-candidates), or None outside the solving stage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pseudo_candidates
|
bool
|
If |
False
|
itlim
|
int
|
LP iteration limit for each strong-branching solve. -1 = no limit. |
-1
|
Source code in gyozas/observations/strong_branching_scores.py
10 11 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 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 | |
MetaObservation¶
MetaObservation
¶
Combines multiple observation functions into a single composite observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observations
|
list | dict | tuple
|
A list, tuple, or dict of observation functions. If a dict is provided,
|
required |