API reference¶
Auto-generated from the docstrings of the public API (everything exported from
the top-level repyability package).
System models¶
RBD ¶
RBD(edges, nodes=None, k=None, input_node=None, output_node=None, on_infeasible_rbd='raise')
Creates and returns a Reliability Block Diagram object.
The positional order mirrors the subclasses
(:class:~repyability.NonRepairableRBD,
:class:~repyability.RepairableRBD): the structure -- edges then
nodes -- comes first, and k (k-out-of-n) is an optional
modifier after it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
Iterable[tuple[Hashable, Hashable]]
|
The collection of node edges, e.g. [(1, 2), (2, 3)] would correspond to the edges 1-2 and 2-3 |
required |
nodes
|
Iterable
|
Extra node names to include beyond those implied by |
None
|
k
|
dict[Any, int]
|
A dictionary mapping nodes to k-out-of-n (koon) values; by default every node's koon value is 1. |
None
|
on_infeasible_rbd
|
{'raise', warn, ignore}
|
Specifies what to do upon encountering a bad line (a line with too many fields). Allowed values are : - 'raise', raise an Exception when an infeasible RBD is detected. - 'warn', raise a warning when an infeasible RBD is detected, but return RBD anyway. - 'ignore', return the RBD without raising any warnings. |
{'raise'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
A node is not in the node list or edge list |
Source code in repyability/rbd/rbd.py
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 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 | |
get_all_path_sets ¶
get_all_path_sets()
Gets all path sets from input_node to output_node
Really just wraps networkx.all_simple_paths(). This is an expensive operation, so be careful using for very large RBDs.
Returns:
| Type | Description |
|---|---|
Iterator[list[Hashable]]
|
The iterator of paths |
Source code in repyability/rbd/rbd.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
get_min_path_sets ¶
get_min_path_sets(include_in_out_nodes=True)
Gets the minimal path-sets of the RBD
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_in_out_nodes
|
bool
|
If false, excludes the input and output nodes in the return, by default True |
True
|
Returns:
| Type | Description |
|---|---|
set[frozenset[Hashable]]
|
The set of minimal path-sets |
Source code in repyability/rbd/rbd.py
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 | |
is_system_working ¶
is_system_working(component_status, method)
Returns a boolean as to whether the system is working given the status of the components
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_status
|
dict[Any, bool]
|
Dictionary with all components where component_status[component] = True only if the component is working, and = False if not working. |
required |
method
|
str
|
Either "p" (path-set) or "c" (cut-set). Both return the same result; "p" is typically faster as it avoids deriving the cut sets. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the system is working, otherwise False. |
Source code in repyability/rbd/rbd.py
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 | |
get_min_cut_sets ¶
get_min_cut_sets(include_in_out_nodes=False)
Returns the set of frozensets of minimal cut sets of the RBD. The outer set contains the frozenset of nodes. frozensets were used so the inner set elements could be hashable.
The minimal cut sets are the minimal transversals (hitting sets) of the minimal path sets, computed with Berge's algorithm. See minimal_cut_sets_from_path_sets() for details.
Source code in repyability/rbd/rbd.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
system_probability ¶
system_probability(node_probabilities, method='p')
Returns the system probability/ies given the probability of each node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_probabilities
|
Dict
|
Dictionary containing the probabilities of the event for every node in the RBDGraph. Probability is to be either the reliability or the availability (or some other probability that I can't conceive). |
required |
method
|
str
|
Input either "c" or "p" for the function to use the cut set or path set methods respectively, by default "p". Both methods return the same (exact) result; the path set method is the default as it avoids deriving the cut sets. |
'p'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Probability values for all events in nodes_probabilities |
Raises:
| Type | Description |
|---|---|
ValueError
|
Probability arrays of differing lengths |
Source code in repyability/rbd/rbd.py
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 | |
node_names ¶
node_names()
Returns the list of (intermediate) node names of the RBD.
Source code in repyability/rbd/rbd.py
644 645 646 | |
structural_importance ¶
structural_importance(working_nodes=None, broken_nodes=None)
Structural (probability-free) importance of every node.
The fraction of the states of the other nodes in which the node is
pivotal -- the system works when the node works and fails when it
fails, holding the others fixed. Equivalently it is the Birnbaum
importance with every node reliability at 1/2, so it depends only on
the RBD's structure and not on any failure model -- useful at design
time, before any life data exists. It is a structural property, so it
is the same for a NonRepairableRBD and a RepairableRBD with the
same diagram.
working_nodes/broken_nodes condition on those nodes being
forced up/down (validated as elsewhere).
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Node name -> structural importance, in |
Examples:
In a two-component parallel system each node is pivotal in half of the other node's states, independent of any failure model:
>>> from surpyval import FixedEventProbability
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "a"), ("s", "b"), ("a", "t"), ("b", "t")],
... {
... "a": FixedEventProbability.from_params(0.1),
... "b": FixedEventProbability.from_params(0.4),
... },
... )
>>> si = rbd.structural_importance()
>>> {k: round(v, 4) for k, v in sorted(si.items())}
{'a': 0.5, 'b': 0.5}
Source code in repyability/rbd/rbd.py
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 | |
to_dict ¶
to_dict()
Serialise the RBD to a JSON-friendly dict (round-trips via
:meth:from_dict). Node models are serialised structurally; fitted
non-parametric models are not supported.
Source code in repyability/rbd/rbd.py
704 705 706 707 708 709 710 | |
to_json ¶
to_json(**json_kwargs)
Serialise the RBD to a JSON string (kwargs pass through to
json.dumps).
Source code in repyability/rbd/rbd.py
712 713 714 715 716 717 | |
from_dict
classmethod
¶
from_dict(d)
Reconstruct an RBD from :meth:to_dict output.
Called on a specific subclass, the document's type must match;
called on RBD it dispatches to whichever type the document names.
Examples:
The structure round-trips through a plain dict, so reliability is preserved:
>>> import surpyval as surv
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "c"), ("c", "t")],
... {"c": surv.Weibull.from_params([100, 2])},
... )
>>> restored = NonRepairableRBD.from_dict(rbd.to_dict())
>>> round(restored.sf(50), 4) == round(rbd.sf(50), 4)
True
Source code in repyability/rbd/rbd.py
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 | |
from_json
classmethod
¶
from_json(s)
Reconstruct an RBD from a JSON string (see :meth:from_dict).
Source code in repyability/rbd/rbd.py
750 751 752 753 754 755 | |
NonRepairableRBD ¶
NonRepairableRBD(edges, reliabilities, k=None, input_node=None, output_node=None, on_infeasible_rbd='raise', ccf_groups=None)
Bases: RBD
Source code in repyability/rbd/non_repairable_rbd.py
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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
is_fixed
property
¶
is_fixed
True if every node's reliability is a fixed (time-invariant) probability, so the system reliability does not vary with time.
is_time_varying
property
¶
is_time_varying
True if any node's reliability varies with time (the complement of
:attr:is_fixed).
sf ¶
sf(x=None, working_nodes=None, broken_nodes=None, method='p')
Returns the system reliability for time/s x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Marks these nodes as perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Marks these nodes as perfectly unreliable, by default None |
None
|
method
|
str
|
Input either "c" or "p" for the function to use the cut set or path set methods respectively. Both methods return the same (exact) result. By default the path set method ("p") is used, as it avoids deriving the cut sets. |
'p'
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
The system reliability: a float for scalar |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a working/broken node is unknown, is the input/output node, is in both sets, or is a repeat of another node. |
Examples:
Two components in parallel, each 90% reliable, so the system is
1 - 0.1 * 0.1 = 0.99 reliable:
>>> from surpyval import FixedEventProbability
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "a"), ("s", "b"), ("a", "t"), ("b", "t")],
... {
... "a": FixedEventProbability.from_params(0.1),
... "b": FixedEventProbability.from_params(0.1),
... },
... )
>>> round(rbd.sf(), 4)
0.99
Conditioning on node "a" having failed leaves only "b":
>>> round(rbd.sf(broken_nodes=["a"]), 4)
0.9
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
ff ¶
ff(x=None, *args, **kwargs)
Returns the system unreliability for time/s x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
*args
|
Any sf() arguments |
()
|
|
**kwargs
|
Any sf() arguments |
()
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
The system unreliability: a float for scalar |
Examples:
>>> from surpyval import FixedEventProbability
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "a"), ("s", "b"), ("a", "t"), ("b", "t")],
... {
... "a": FixedEventProbability.from_params(0.1),
... "b": FixedEventProbability.from_params(0.1),
... },
... )
>>> round(rbd.ff(), 4)
0.01
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
unreliability ¶
unreliability(x=None, *args, **kwargs)
Returns the system unreliability for time/s x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
*args
|
Any sf() arguments |
()
|
|
**kwargs
|
Any sf() arguments |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Unreliability values for all nodes at all times x |
Source code in repyability/rbd/non_repairable_rbd.py
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |
reliability ¶
reliability(x=None, *args, **kwargs)
Returns the system reliability for time/s x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
*args
|
Any sf() arguments |
()
|
|
**kwargs
|
Any sf() arguments |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Reliability values for all nodes at all times x |
Source code in repyability/rbd/non_repairable_rbd.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | |
cs ¶
cs(x, X, *args, **kwargs)
Returns the conditional survival of the system.
That is, the probability the system survives a further x given it
has already survived to X: R(x | X) = sf(X + x) / sf(X).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
The further duration/s at which conditional survival is evaluated. |
required |
X
|
ArrayLike
|
The age/s the system is known to have survived to. |
required |
*args
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
()
|
|
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
()
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The conditional survival probability/ies. |
Source code in repyability/rbd/non_repairable_rbd.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
Hf ¶
Hf(x=None, **kwargs)
Returns the system cumulative hazard function H(x) = -ln R(x).
This is exact given the (exact) system reliability R(x); it is +inf wherever the system reliability has reached zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable. |
None
|
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
{}
|
Source code in repyability/rbd/non_repairable_rbd.py
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
df ¶
df(x=None, dx=1e-06, **kwargs)
Returns the system failure density f(x) = -dR/dx.
Computed by central finite differences of the system reliability
(which is composed of the nodes' reliabilities, so it is smooth in x);
dx sets the relative step size. The step never crosses into
negative time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable. |
None
|
dx
|
float
|
Relative finite-difference step, by default 1e-6. |
1e-06
|
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
{}
|
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
hf ¶
hf(x=None, dx=1e-06, **kwargs)
Returns the system hazard rate h(x) = f(x) / R(x).
Uses the (numerical) failure density df() over the (exact) system reliability. It is +inf wherever the system reliability has reached zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable. |
None
|
dx
|
float
|
Relative finite-difference step passed to df(), by default 1e-6. |
1e-06
|
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
{}
|
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
node_sf ¶
node_sf(x=None, *args, **kwargs)
Returns each node's reliability at time/s x (a dict keyed by node
name). Floats for scalar x, arrays for array x.
Source code in repyability/rbd/non_repairable_rbd.py
695 696 697 698 699 700 701 702 703 704 | |
node_ff ¶
node_ff(x=None, *args, **kwargs)
Returns each node's unreliability at time/s x (a dict keyed by node
name). Floats for scalar x, arrays for array x.
Source code in repyability/rbd/non_repairable_rbd.py
706 707 708 709 710 711 712 713 714 715 716 | |
get_non_analytic_nodes ¶
get_non_analytic_nodes()
Returns the nodes that prevent an analytic / BDD solution.
Returns:
| Type | Description |
|---|---|
dict[Any, str]
|
A mapping of node name -> the offending model's type name for every node whose reliability requires Monte-Carlo simulation (e.g. a StandbyModel). Empty if the RBD is analytically solvable. |
Source code in repyability/rbd/non_repairable_rbd.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 | |
is_analytically_solvable ¶
is_analytically_solvable()
Returns whether the system reliability can be solved analytically.
The analytic methods (the inclusion-exclusion in system_probability(), and equivalently a BDD evaluation) require every node to expose a reliability sf(t) that does not itself depend on Monte-Carlo simulation. This holds for parametric and non-parametric distributions, fixed-probability nodes, repeated nodes of such models, and nested RBDs that are themselves analytically solvable.
It does NOT hold when any node is a standby arrangement (StandbyModel or RepeatedStandbyNode): a standby node is sequence-dependent and its sf(t) is estimated by simulation, so while sf()/system_probability() will still return a value, that value is only as good as the underlying Monte-Carlo + Kaplan-Meier fit (a step function bounded by the sampled support) rather than a closed-form result. Such systems are better evaluated by simulation (e.g. random()/mean()).
Returns:
| Type | Description |
|---|---|
bool
|
True if the RBD can be solved analytically / with a BDD, False if it requires simulation. Use get_non_analytic_nodes() to see which nodes are responsible. |
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
random ¶
random(size, seed=None)
Monte-Carlo simulate size system failure times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
Number of system-lifetime samples to draw. |
required |
seed
|
int or None
|
If given, seeds numpy's global RNG for the duration of the draw so
the result is reproducible (surpyval's |
None
|
Source code in repyability/rbd/non_repairable_rbd.py
810 811 812 813 814 815 816 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 | |
mean ¶
mean(mc_samples=100000, seed=None)
Returns the Mean Time To Failure of the RBD
This is necessary for recursive calls which will only use the mean
Source code in repyability/rbd/non_repairable_rbd.py
849 850 851 852 853 | |
mean_time_to_failure ¶
mean_time_to_failure(mc_samples=100000, seed=None)
User friendly way to get MTTF
Source code in repyability/rbd/non_repairable_rbd.py
855 856 857 858 859 | |
mean_time_to_failure_interval ¶
mean_time_to_failure_interval(mc_samples=100000, confidence=0.95, seed=None)
Returns the Monte-Carlo MTTF estimate with its sampling uncertainty.
The MTTF is the mean of mc_samples simulated system lifetimes; by
the central limit theorem its sampling error is normal with standard
error sample std / sqrt(mc_samples), from which the confidence
interval is built.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mc_samples
|
int
|
Number of Monte-Carlo samples, by default 100_000. |
100000
|
confidence
|
float
|
The confidence level, by default 0.95. |
0.95
|
seed
|
int or None
|
Seed for reproducibility (see :meth: |
None
|
Returns:
| Type | Description |
|---|---|
ConfidenceInterval
|
The estimate, bounds, standard error and sample count. |
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
time_to_reliability ¶
time_to_reliability(target, upper_bound=None, **kwargs)
Returns the time at which system reliability equals target.
Solves R(t) = target for t (the inverse of :meth:sf). System
reliability is monotonically non-increasing in time, so the solution
is unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
float
|
The reliability level to solve for, in (0, 1). |
required |
upper_bound
|
float
|
An upper bound for the search; found automatically (by doubling) if None. |
None
|
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
{}
|
Returns:
| Type | Description |
|---|---|
float
|
The time at which |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import surpyval as surv
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "c"), ("c", "t")],
... {"c": surv.Weibull.from_params([100, 2])},
... )
>>> round(rbd.time_to_reliability(0.9), 2)
32.46
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
bx_life ¶
bx_life(x, **kwargs)
Returns the B\ :sub:X life: the time by which x percent of
systems have failed, i.e. the time at which R(t) = 1 - x/100.
For example bx_life(10) is the B10 life (10% failed / 90%
reliability).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The percentage failed, in (0, 100). |
required |
**kwargs
|
Any sf() arguments (e.g. working_nodes, broken_nodes, method). |
{}
|
Examples:
The B10 life (10% failed) of a single Weibull component:
>>> import surpyval as surv
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "c"), ("c", "t")],
... {"c": surv.Weibull.from_params([100, 2])},
... )
>>> round(rbd.bx_life(10), 2)
32.46
Source code in repyability/rbd/non_repairable_rbd.py
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 1025 1026 1027 | |
sf_given_state ¶
sf_given_state(x=None, state=None, method='p')
System reliability a further x into the future, given each
node's current state.
The condition-based ("digital twin") generalisation of :meth:sf:
instead of assuming every component is new, each component conditions
on its own current life X_i (streamed from sensors) and the
conditioned per-node reliabilities are propagated exactly through the
system::
R_i(x | X_i) = R_i(X_i + x) / R_i(X_i)
R_sys(x | {X_i}) = system_probability({ R_i(x | X_i) })
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
The further duration/s at which reliability is evaluated (measured
from now, so |
None
|
state
|
dict[Hashable, NodeState]
|
The current state of each component. A node omitted from the
mapping is treated as new (age 0), so an empty state reproduces
:meth: |
None
|
method
|
str
|
"p" (path-set, default) or "c" (cut-set); both are exact. |
'p'
|
Returns:
| Type | Description |
|---|---|
float or ndarray
|
System reliability given the state: a float for scalar |
Notes
Only lifetime (time-varying) distributions age; a fixed-probability component conditioned on being alive contributes reliability 1 going forward (its per-demand uncertainty is resolved by observing it alive). Composite / dynamic nodes (standby, repeated, nested RBD) are not supported here in this release and raise if given a state.
Examples:
A component 40 hours into life is less reliable over the next 50 than a new one would be:
>>> import surpyval as surv
>>> from repyability import NonRepairableRBD, NodeState
>>> rbd = NonRepairableRBD(
... [("s", "c"), ("c", "t")],
... {"c": surv.Weibull.from_params([100, 2])},
... )
>>> round(rbd.sf_given_state(50, {"c": NodeState(age=40)}), 4)
0.522
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
remaining_life ¶
remaining_life(target, state=None, upper_bound=None)
Remaining useful life (RUL): the further time until system
reliability falls to target, given each node's current state.
The condition-based analogue of :meth:time_to_reliability: it solves
sf_given_state(t, state) == target for t. Because
sf_given_state is measured from now, the result is the time
remaining from the current state. remaining_life(1 - x/100,
state) is the conditional B\ :sub:X life.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
float
|
The system reliability level to solve for, in (0, 1). |
required |
state
|
dict[Hashable, NodeState]
|
The current state of each component (see :meth: |
None
|
upper_bound
|
float
|
An upper bound for the search; found automatically if None. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
The remaining time until |
Examples:
>>> import surpyval as surv
>>> from repyability import NonRepairableRBD, NodeState
>>> rbd = NonRepairableRBD(
... [("s", "c"), ("c", "t")],
... {"c": surv.Weibull.from_params([100, 2])},
... )
>>> round(rbd.remaining_life(0.9, {"c": NodeState(age=40)}), 2)
11.51
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
importances_given_state ¶
importances_given_state(x=None, state=None)
Live, state-dependent node importance over a forward horizon x
-- how each component's importance shifts once the current wear on
every component is accounted for.
Evaluates the Birnbaum and criticality importance measures at the
conditioned per-node reliabilities R_i(x | X_i) (see
:meth:sf_given_state) rather than at the as-new reliabilities, so the
rankings reflect the current state. Both use the same conventions as
:meth:birnbaum_importance and :meth:criticality_importance: they
measure how much the system reliability depends on each node now, not
which node is most likely to have failed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
The forward horizon/s over which importance is evaluated (from now). |
None
|
state
|
dict[Hashable, NodeState]
|
The current state of each component (see :meth: |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, dict[Any, float | ndarray]]
|
|
Source code in repyability/rbd/non_repairable_rbd.py
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 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 | |
node_mttf ¶
node_mttf(mc_samples=100000, seed=None)
Returns each node's mean time to failure (a dict keyed by node
name). Simulation-based node models use mc_samples Monte-Carlo
draws; fixed-probability nodes have no time dimension and return 0.
Source code in repyability/rbd/non_repairable_rbd.py
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |
birnbaum_importance ¶
birnbaum_importance(x=None, working_nodes=None, broken_nodes=None)
Returns the Birnbaum measure of importance for all nodes.
Note: Birnbaum's measure of importance assumes all nodes are independent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and Birnbaum importances as
values (floats for scalar |
Examples:
In a two-component parallel system each node's Birnbaum importance is the probability the other node has failed:
>>> from surpyval import FixedEventProbability
>>> from repyability import NonRepairableRBD
>>> rbd = NonRepairableRBD(
... [("s", "a"), ("s", "b"), ("a", "t"), ("b", "t")],
... {
... "a": FixedEventProbability.from_params(0.1),
... "b": FixedEventProbability.from_params(0.1),
... },
... )
>>> bi = rbd.birnbaum_importance()
>>> {k: round(v, 4) for k, v in sorted(bi.items())}
{'a': 0.1, 'b': 0.1}
Source code in repyability/rbd/non_repairable_rbd.py
1318 1319 1320 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 | |
improvement_potential ¶
improvement_potential(x=None, working_nodes=None, broken_nodes=None)
Returns the improvement potential of all nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and improvement potentials as
values (floats for scalar |
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
risk_achievement_worth ¶
risk_achievement_worth(x=None, working_nodes=None, broken_nodes=None)
Returns the RAW importance per Modarres & Kaminskiy. That is RAW_i = (unreliability of system given i failed) / (nominal system unreliability).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and RAW importances as values
(floats for scalar |
Source code in repyability/rbd/non_repairable_rbd.py
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 | |
risk_reduction_worth ¶
risk_reduction_worth(x=None, working_nodes=None, broken_nodes=None)
Returns the RRW importance per Modarres & Kaminskiy. That is RRW_i = (nominal unreliability of system) / (unreliability of system given i is working).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and RRW importances as values
(floats for scalar |
Source code in repyability/rbd/non_repairable_rbd.py
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 | |
criticality_importance ¶
criticality_importance(x=None, working_nodes=None, broken_nodes=None)
Returns the criticality importance of all nodes at time/s x.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and criticality importances as
values (floats for scalar |
Source code in repyability/rbd/non_repairable_rbd.py
1475 1476 1477 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 | |
fussell_vesely ¶
fussell_vesely(x=None, fv_type='c', working_nodes=None, broken_nodes=None)
Calculate Fussell-Vesely importance of all nodes at time/s x.
Briefly, the Fussell-Vesely importance measure for node i = (sum of probabilities of cut-sets including node i occuring/failing) / (the probability of the system failing).
Typically this measure is implemented using cut-sets as mentioned above, although the measure can be implemented using path-sets. Both are implemented here.
fv_type dictates the method: "c" - cut-set "p" - path-set
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable |
None
|
fv_type
|
str
|
Dictates the method of calculation, 'c' = cut-set and 'p' = path-set, by default "c" |
'c'
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float | ndarray]
|
Dictionary with node names as keys and Fussell-Vesely importances
as values (floats for scalar |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in repyability/rbd/non_repairable_rbd.py
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 1561 1562 1563 | |
fussel_vesely ¶
fussel_vesely(x=None, fv_type='c')
Deprecated alias for :meth:fussell_vesely (corrected spelling).
Source code in repyability/rbd/non_repairable_rbd.py
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 | |
parameter_sensitivity ¶
parameter_sensitivity(x=None, working_nodes=None, broken_nodes=None, rel_step=1e-05)
Sensitivity of the system reliability to each node's distribution
parameters at time/s x.
For node i with parameter theta, the sensitivity is
d R_sys / d theta = B_i(x) * d sf_i(x; theta) / d theta
where B_i is the Birnbaum importance of node i (how much the
system reliability moves per unit change in that node's reliability)
and d sf_i / d theta is how much the node's reliability moves per
unit change in the parameter. The parameter derivative is taken
numerically (a central finite difference, rebuilding the distribution
with from_params), so it applies to any parametric surpyval model
without per-distribution formulae. It answers "which fitted parameter,
if it were a little different, would move system reliability the most"
-- e.g. to target data collection or to gauge the impact of estimation
uncertainty.
Only nodes with reconstructable distribution parameters are included;
composite nodes (a nested RBD, a standby arrangement, a repeated node)
and fitted non-parametric models have no parameters to perturb and are
omitted. A node forced via working_nodes/broken_nodes is pinned
independently of its parameters, so its sensitivities are reported as
zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ArrayLike
|
Time/s as a number or iterable. |
None
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being perfectly reliable, by default None. |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes having failed, by default None. |
None
|
rel_step
|
float
|
Relative step used for the finite difference, by default |
1e-05
|
Returns:
| Type | Description |
|---|---|
dict[Any, dict[str, float | ndarray]]
|
|
Source code in repyability/rbd/non_repairable_rbd.py
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 1616 1617 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 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 | |
RepairableRBD ¶
RepairableRBD(edges, components, k=None, input_node=None, output_node=None, on_infeasible_rbd='raise')
Bases: RBD
Source code in repyability/rbd/repairable_rbd.py
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 | |
mean_unavailability ¶
mean_unavailability(*args, **kwargs)
Returns the system long run UNavailability
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any mean_availability() arguments |
()
|
|
**kwargs
|
Any mean_availability() arguments |
()
|
Returns:
| Type | Description |
|---|---|
float
|
Long run unavailability of the system |
Source code in repyability/rbd/repairable_rbd.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
mean_availability ¶
mean_availability(working_nodes=None, broken_nodes=None, method='p')
Returns the system long run availability
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
working_nodes
|
Collection[Hashable]
|
Marks these nodes as always available, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Marks these nodes as failed, by default None |
None
|
method
|
str
|
Input either "c" or "p" for the function to use cut sets or path sets respectively. Defaults to path sets. |
'p'
|
Returns:
| Type | Description |
|---|---|
float
|
Long run availability of the system |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a working/broken node is unknown, is the input/output node, or is in both sets. |
Examples:
A single component with mean time to failure 10 and mean time to
repair 1 has long-run availability 10 / (10 + 1):
>>> import surpyval as surv
>>> from repyability import RepairableRBD
>>> rbd = RepairableRBD(
... [("s", "c"), ("c", "t")],
... {
... "c": {
... "reliability": surv.Exponential.from_params([0.1]),
... "repairability": surv.Exponential.from_params([1.0]),
... }
... },
... )
>>> round(rbd.mean_availability(), 4)
0.9091
Source code in repyability/rbd/repairable_rbd.py
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 | |
availability ¶
availability(t_simulation, working_nodes=None, broken_nodes=None, method='p', N=10000, verbose=False, seed=None)
Returns the times, and availability for those times, as numpy arrays
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t_simulation
|
float
|
Units of time to run each simulation for |
required |
N
|
int
|
Number of simulations, by default 10_000 |
10000
|
verbose
|
bool
|
If True, displays progress bar of simulations, by default False |
False
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
times, availabilities |
Source code in repyability/rbd/repairable_rbd.py
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 | |
node_availability ¶
node_availability()
Returns each node's long-run availability (a dict keyed by node name); the input/output nodes are 1.0.
Source code in repyability/rbd/repairable_rbd.py
679 680 681 682 683 684 685 686 687 688 689 690 691 | |
system_failure_frequency ¶
system_failure_frequency(working_nodes=None, broken_nodes=None)
Returns the system's long-run failure frequency (failures per unit time), by the Birnbaum/Vesely formula.
In steady state the system failure frequency is
.. math:: \omega = \sum_i I_B^i \cdot \omega_i
where :math:I_B^i is node i's Birnbaum importance evaluated at the
nodes' availabilities and :math:\omega_i = 1/(MTTF_i + MTTR_i) is
node i's failure frequency. Exact for independent repairable nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes always working (they contribute no failures), by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes being failed (they contribute no failures), by default None |
None
|
Source code in repyability/rbd/repairable_rbd.py
701 702 703 704 705 706 707 708 709 710 711 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 | |
mean_time_between_failures ¶
mean_time_between_failures(working_nodes=None, broken_nodes=None)
Returns the system's long-run Mean Time Between Failures,
MTBF = 1 / failure frequency — the mean length of one full
up-down cycle, i.e. MTBF = MUT + MDT. Infinite if the system
never fails.
Source code in repyability/rbd/repairable_rbd.py
745 746 747 748 749 750 751 752 753 754 755 | |
mean_up_time ¶
mean_up_time(working_nodes=None, broken_nodes=None)
Returns the system's long-run Mean Up Time (mean duration of an
uninterrupted working period; sometimes called the repairable-system
MTTF), MUT = availability / failure frequency.
Source code in repyability/rbd/repairable_rbd.py
757 758 759 760 761 762 763 764 765 766 767 768 769 | |
mean_down_time ¶
mean_down_time(working_nodes=None, broken_nodes=None)
Returns the system's long-run Mean Down Time (mean duration of an
outage; the repairable-system MTTR),
MDT = unavailability / failure frequency.
Source code in repyability/rbd/repairable_rbd.py
771 772 773 774 775 776 777 778 779 780 781 782 783 | |
birnbaum_importance ¶
birnbaum_importance(working_nodes=None, broken_nodes=None)
Returns the Birnbaum measure of importance for all nodes, evaluated at the nodes' long-run availabilities.
Note: Birnbaum's measure of importance assumes all nodes are independent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being always available, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes being failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and Birnbaum importances as values |
Source code in repyability/rbd/repairable_rbd.py
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 | |
improvement_potential ¶
improvement_potential(working_nodes=None, broken_nodes=None)
Returns the improvement potential of all nodes, evaluated at the nodes' long-run availabilities.
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and improvement potentials as values |
Source code in repyability/rbd/repairable_rbd.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 | |
risk_achievement_worth ¶
risk_achievement_worth(working_nodes=None, broken_nodes=None)
Returns the RAW importance per Modarres & Kaminskiy, evaluated at the nodes' long-run availabilities. That is RAW_i = (unavailability of system given i failed) / (nominal system unavailability).
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and RAW importances as values |
Source code in repyability/rbd/repairable_rbd.py
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 | |
risk_reduction_worth ¶
risk_reduction_worth(working_nodes=None, broken_nodes=None)
Returns the RRW importance per Modarres & Kaminskiy, evaluated at the nodes' long-run availabilities. That is RRW_i = (nominal unavailability of system) / (unavailability of system given i is working).
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and RRW importances as values |
Source code in repyability/rbd/repairable_rbd.py
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | |
criticality_importance ¶
criticality_importance(working_nodes=None, broken_nodes=None)
Returns the criticality importance of all nodes, evaluated at the nodes' long-run availabilities.
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and criticality importances as values |
Source code in repyability/rbd/repairable_rbd.py
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | |
fussell_vesely ¶
fussell_vesely(fv_type='c', working_nodes=None, broken_nodes=None)
Calculate Fussell-Vesely importance of all nodes, evaluated at the nodes' long-run availabilities.
Briefly, the Fussell-Vesely importance measure for node i = (sum of probabilities of cut-sets including node i occuring/failing) / (the probability of the system failing).
Typically this measure is implemented using cut-sets as mentioned above, although the measure can be implemented using path-sets. Both are implemented here.
fv_type dictates the method: "c" - cut-set "p" - path-set
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fv_type
|
str
|
Dictates the method of calculation, 'c' = cut-set and 'p' = path-set, by default "c" |
'c'
|
working_nodes
|
Collection[Hashable]
|
Condition on these nodes being always available, by default None |
None
|
broken_nodes
|
Collection[Hashable]
|
Condition on these nodes being failed, by default None |
None
|
Returns:
| Type | Description |
|---|---|
dict[Any, float]
|
Dictionary with node names as keys and Fussell-Vesely importances as values |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in repyability/rbd/repairable_rbd.py
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 | |
fussel_vesely ¶
fussel_vesely(fv_type='c')
Deprecated alias for :meth:fussell_vesely (corrected spelling).
Source code in repyability/rbd/repairable_rbd.py
951 952 953 954 955 956 957 958 959 960 | |
Component models¶
NonRepairable ¶
NonRepairable(reliability, time_to_replace=ExactEventTime.from_params(0))
A component renewed by replacement ("as good as new").
Pairs a lifetime (reliability) model with a time-to-replace model for a unit that cannot be repaired in place: every failure or planned replacement fits a new unit, so each cycle is a statistical renewal.
It plays two roles:
- Standalone, it prices the classic age-replacement policy — replace
preventively at age
t(planned, costcp) or on failure (unplanned, costcu > cp) — viafind_optimal_replacement()andoptimal_replacement_policy(). - Inside
RepairableRBD, it is the per-component representation used by the availability engine (components are "repaired" by as-new replacement, which is exactly the renewal this class models).
Contrast with Repairable, which models minimal repair ("as bad
as old") and the overhaul-interval policy.
Source code in repyability/non_repairable.py
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 | |
mean_availability ¶
mean_availability()
Long-run availability, MTTF / (MTTF + MTTR).
Source code in repyability/non_repairable.py
110 111 112 113 114 115 116 117 118 | |
failure_frequency ¶
failure_frequency()
Long-run failure frequency (failures per unit time).
For an alternating renewal process (fail, repair, fail, ...) this is
1 / (MTTF + MTTR) — one failure per mean up-down cycle.
Source code in repyability/non_repairable.py
120 121 122 123 124 125 126 127 128 129 130 131 132 | |
optimal_replacement_policy ¶
optimal_replacement_policy()
The optimal age-replacement policy as a typed result.
Returns a MaintenancePolicy whose interval is the
cost-optimal replacement age and whose cost_rate is the
long-run cost per unit time under it. When preventive replacement
never pays (no aging — e.g. an exponential lifetime, or a Weibull
with shape <= 1) the interval is inf and the cost rate is the
run-to-failure rate cu / MTTF.
Source code in repyability/non_repairable.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
StandbyModel ¶
StandbyModel(reliabilities, k=1, n_sims=10000, lower=-np.inf, switching_probability=1.0, seed=None)
Source code in repyability/rbd/standby_node.py
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 | |
cs ¶
cs(x, X)
Conditional survival R(x | X) = sf(X + x) / sf(X).
Source code in repyability/rbd/standby_node.py
187 188 189 190 191 | |
LoadSharingModel ¶
LoadSharingModel(models, load, k=1, n_sims=10000, lower=-np.inf, seed=None)
A load-sharing arrangement of coupled AFT units as one RBD node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
models
|
sequence of fitted surpyval AFT models
|
The units. Each must be an accelerated-failure-time model fitted with
the (scalar) load as its covariate, exposing |
required |
load
|
float
|
The total load |
required |
k
|
int
|
The minimum number of surviving units for the group to work, by default
1. The group fails at the |
1
|
n_sims
|
int
|
Monte-Carlo replicates for the Kaplan-Meier fit when no closed form applies, by default 10_000. |
10000
|
lower
|
float
|
|
-inf
|
seed
|
int or None
|
Seed for the Monte-Carlo fit (reproducible), by default None. |
None
|
Notes
phi with no load effect (phi == 1) reproduces the ordinary
k-out-of-n parallel result exactly, since the units then neither share
stress nor age faster as siblings fail.
Source code in repyability/rbd/load_sharing_node.py
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 | |
is_simulated
property
¶
is_simulated
True if the survival function is a Monte-Carlo (Kaplan-Meier) fit rather than the exact hypoexponential closed form.
random ¶
random(size, seed=None)
Monte-Carlo simulate size group lifetimes via the cumulative-
exposure event loop.
Source code in repyability/rbd/load_sharing_node.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 231 232 233 234 | |
cs ¶
cs(x, X)
Conditional survival R(x | X) = sf(X + x) / sf(X).
Source code in repyability/rbd/load_sharing_node.py
251 252 253 | |
RepeatedNode ¶
RepeatedNode(model, repeats, kind)
Source code in repyability/rbd/repeated_node.py
9 10 11 12 13 14 15 16 17 18 | |
cs ¶
cs(x, X)
Conditional survival R(x | X) = sf(X + x) / sf(X).
Source code in repyability/rbd/repeated_node.py
51 52 53 54 55 | |
RepeatedStandbyNode ¶
RepeatedStandbyNode(model, repeats, N=10000, lower=-np.inf, switching_probability=1.0)
Source code in repyability/rbd/repeated_standby_node.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
cs ¶
cs(x, X)
Conditional survival R(x | X) = sf(X + x) / sf(X).
Source code in repyability/rbd/repeated_standby_node.py
67 68 69 70 71 | |
Repairable ¶
Repairable(model)
Repairable component with an optimal overhaul/replacement policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
object
|
A recurrent-event model exposing the expected number of failures by
age
If both are present |
required |
Source code in repyability/repairable.py
99 100 101 102 103 104 105 106 107 108 | |
is_simulated
property
¶
is_simulated
True if E[N(t)] is estimated by simulation (imperfect repair),
so the policy methods honour seed/n_simulations.
set_repair_and_overhaul_costs ¶
set_repair_and_overhaul_costs(cr, co)
Set the repair cost cr and overhaul/replacement cost co.
Requires 0 < cr < co: an overhaul/replacement (a full renewal) must
cost more than a repair, otherwise one would simply renew at every
failure.
Source code in repyability/repairable.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
cost ¶
cost(t, seed=None, n_simulations=_DEFAULT_N_SIMULATIONS)
Expected cost of one overhaul/replacement cycle of length t:
cr * E[N(t)] + co.
Scalar t returns a float; array t returns an array.
seed/n_simulations apply only to a simulation-backed
(imperfect-repair) model.
Source code in repyability/repairable.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
cost_rate ¶
cost_rate(t, seed=None, n_simulations=_DEFAULT_N_SIMULATIONS)
Long-run cost per unit time when renewing every t:
(cr * E[N(t)] + co) / t.
Scalar t returns a float; array t returns an array.
seed/n_simulations apply only to a simulation-backed
(imperfect-repair) model.
Source code in repyability/repairable.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
find_optimal_overhaul_interval ¶
find_optimal_overhaul_interval(seed=None, n_simulations=_DEFAULT_N_SIMULATIONS, max_interval=None)
The overhaul/replacement interval minimising the long-run cost rate.
For an analytic (minimal-repair) model, returns inf when renewal
never pays: the unit does not wear out (E[N(t)] grows at most
linearly — e.g. HPP, or Crow-AMSAA with beta <= 1), so the cost
rate keeps falling as the interval grows.
For a simulation-backed (imperfect-repair) model, pass a seed for a
reproducible result; n_simulations sets the Monte-Carlo sample size
and max_interval the search horizon (default ~15x the baseline
mean-time-to-first-failure).
Source code in repyability/repairable.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | |
optimal_overhaul_policy ¶
optimal_overhaul_policy(seed=None, n_simulations=_DEFAULT_N_SIMULATIONS, max_interval=None)
The optimal overhaul/replacement policy as a typed result.
Returns a MaintenancePolicy carrying the optimal interval and the
long-run cost rate under it. For an analytic model an inf interval
(never renew) reports the limiting rate of repairs alone.
For a simulation-backed (imperfect-repair) model, pass a seed for a
reproducible result; n_simulations sets the Monte-Carlo sample size
and max_interval the search horizon.
Source code in repyability/repairable.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
expected_time_to_nth_failure ¶
expected_time_to_nth_failure(n, seed=None, n_simulations=_DEFAULT_N_SIMULATIONS)
Expected time to the n-th failure, E[T_n].
Estimated by a seeded simulation for an imperfect-repair model. For a
minimal-repair (power-law) process the closed form
:func:minimal_repair_time_to_nth_failure is exact and cheaper.
Source code in repyability/repairable.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
find_optimal_replacement_failure_count ¶
find_optimal_replacement_failure_count(seed=None, n_simulations=_DEFAULT_N_SIMULATIONS, max_failures=_DEFAULT_MAX_FAILURES)
The number of failures per cycle minimising the long-run cost rate of a replace-at-N-th-failure policy.
Simulation-based; pass a seed for a reproducible result.
max_failures bounds the search (raise it if the optimum sits at the
bound).
Source code in repyability/repairable.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
optimal_failure_limit_policy ¶
optimal_failure_limit_policy(seed=None, n_simulations=_DEFAULT_N_SIMULATIONS, max_failures=_DEFAULT_MAX_FAILURES)
The optimal replace-at-N-th-failure policy as a typed result.
Repair on each failure (cost cr) and replace on the
failure_count-th (cost co); the long-run cost rate is
(cr*(n-1) + co) / E[T_n] minimised over n.
Source code in repyability/repairable.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
RegressionNode ¶
RegressionNode(model, covariates)
An RBD node backed by a fitted surpyval regression model at fixed covariates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
surpyval regression model
|
A fitted regression model whose |
required |
covariates
|
array_like
|
The component's covariate vector |
required |
Examples:
>>> import numpy as np
>>> import surpyval as surv
>>> from repyability.rbd.regression_node import RegressionNode
>>> rng = np.random.default_rng(0)
>>> Z = rng.normal(size=(300, 1))
>>> x = rng.weibull(2.0, size=300) * 100 + 1e-3
>>> model = surv.WeibullAFT.fit(x, Z=Z)
>>> node = RegressionNode(model, covariates=[0.5])
>>> bool(0.0 < node.sf(np.array([50.0]))[0] < 1.0)
True
Source code in repyability/rbd/regression_node.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
sf ¶
sf(x)
Reliability at the stored covariates: model.sf(x, Z).
Source code in repyability/rbd/regression_node.py
85 86 87 | |
ff ¶
ff(x)
Unreliability at the stored covariates: 1 - sf(x).
Source code in repyability/rbd/regression_node.py
89 90 91 | |
mean ¶
mean()
Mean time to failure at the stored covariates.
For a non-negative lifetime E[T] = integral of R(t), integrated
numerically over the survival curve.
Source code in repyability/rbd/regression_node.py
126 127 128 129 130 131 132 133 | |
random ¶
random(size)
Draw size failure times at the stored covariates.
Inverse-transform sampling on the survival curve. Uses numpy's global
RNG, so wrap the call in
:func:~repyability.utils.wrappers.numpy_seed to reproduce.
Source code in repyability/rbd/regression_node.py
135 136 137 138 139 140 141 142 143 144 145 | |
to_dict ¶
to_dict()
Serialise to a JSON-friendly dict (the fitted model + covariates).
See :meth:from_dict.
Source code in repyability/rbd/regression_node.py
149 150 151 152 153 154 155 | |
from_dict
classmethod
¶
from_dict(d)
Reconstruct from :meth:to_dict (the fitted model round-trips
through surpyval.from_dict).
Source code in repyability/rbd/regression_node.py
157 158 159 160 161 162 163 | |
Helpers¶
NodeState
dataclass
¶
NodeState(age=0.0, alive=True)
The current condition of a single RBD node.
A component's forward reliability is conditioned on the life it has already
survived: R_i(x | age) = R_i(age + x) / R_i(age). A failed component
(alive=False) contributes zero reliability regardless of its age.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
age
|
float
|
The component's current age / accumulated operating time ( |
0.0
|
alive
|
bool
|
Whether the component is currently working, by default |
True
|
Notes
Only lifetime (time-varying) distributions age; a fixed-probability
component's reliability does not depend on age. Covariate/load
dependence is a property of the component, not its transient state: a
:class:~repyability.rbd.regression_node.RegressionNode stores the
covariates, so age keeps a single meaning (operating time) for every
node type.
CCFGroup ¶
CCFGroup(members, model)
A common-cause group: member nodes coupled by a shared failure cause.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
collection of node names
|
The RBD nodes that share the common cause (at least two, distinct). Standard CCF theory is for symmetric groups, so the members should carry identical component models. |
required |
model
|
BetaFactor or MGL
|
The common-cause model coupling the members. An :class: |
required |
Source code in repyability/rbd/ccf.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
BetaFactor ¶
BetaFactor(beta)
The beta-factor common-cause model (all-or-nothing).
A fraction beta of each component's total failure probability is
attributed to a cause shared across the whole group (which fails every
member simultaneously); the remaining 1 - beta is independent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beta
|
float
|
The common-cause fraction, in |
required |
Source code in repyability/rbd/ccf.py
54 55 56 57 | |
MGL ¶
MGL(*letters)
The Multiple Greek Letter common-cause model.
The parameters are the conditional probabilities of a common-cause failure
escalating to the next level: beta = P(shared by >= 2 | failed),
gamma = P(>= 3 | >= 2), delta = P(>= 4 | >= 3), and so on. The
number of parameters fixes the group size: n letters describe a group
of n + 1 members. MGL(beta) is exactly :class:BetaFactor on a
two-member group.
The probability that a common cause fails a specific set of k of the
m members is the standard MGL basic-event probability
Q_k = [1 / C(m-1, k-1)] * (rho_1 * ... * rho_k) * (1 - rho_{k+1}) * Q
with rho_1 = 1, rho_2 = beta, rho_3 = gamma, ..., and
rho_{m+1} = 0. These partition each component's total failure
probability Q exactly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*letters
|
float
|
|
()
|
Source code in repyability/rbd/ccf.py
104 105 106 107 108 109 110 111 112 | |
PerfectReliability ¶
PerfectUnreliability ¶
Result types¶
AvailabilityResult
dataclass
¶
AvailabilityResult(timeline, availability, system_uptime, time_simulated_to, criticalities, node_uptime, node_downtime, system_downtime, system_failures, system_restorations, n_simulations)
Bases: _ResultMapping
The result of RepairableRBD.availability().
The properties mean_up_time, mean_down_time and
failure_frequency are simulation estimates derived from the fields
below; their exact steady-state counterparts are the
RepairableRBD.mean_up_time(), mean_down_time() and
system_failure_frequency() methods.
Attributes:
| Name | Type | Description |
|---|---|---|
timeline |
ndarray
|
Event times at which the (mean) system availability changes. |
availability |
ndarray
|
Mean system availability at each time in |
system_uptime |
float
|
Total system uptime summed over all simulations. |
time_simulated_to |
float
|
The |
criticalities |
Criticalities
|
The importance/criticality measures (see |
node_uptime |
dict
|
Total uptime per node summed over all simulations. |
node_downtime |
dict
|
Total downtime per node summed over all simulations; a node's uptime
plus downtime equals |
system_downtime |
float
|
Total system downtime summed over all simulations. |
system_failures |
int
|
Number of system failures observed across all simulations. |
system_restorations |
int
|
Number of system restorations observed across all simulations. |
n_simulations |
int
|
The number of simulations run ( |
availability_se
property
¶
availability_se
Pointwise standard error of the availability estimate.
At each time in timeline the availability is the proportion of
the n_simulations systems that were up, so its sampling standard
error is the binomial sqrt(A (1 - A) / n).
mean_up_time
property
¶
mean_up_time
Simulation estimate of the Mean Up Time,
system uptime / system failures. Infinite if no failure was
observed.
Note: estimated from a finite window, so each simulation's final
(unfinished) up period is censored; for windows that are short
relative to the up-down cycle this biases the estimate. Prefer the
exact RepairableRBD.mean_up_time() for steady-state values.
mean_down_time
property
¶
mean_down_time
Simulation estimate of the Mean Down Time,
system downtime / system restorations. Infinite if downtime was
observed but never restored.
Note: estimated from a finite window (final unfinished down periods
are censored), so short windows bias the estimate. Prefer the exact
RepairableRBD.mean_down_time() for steady-state values.
failure_frequency
property
¶
failure_frequency
Simulation estimate of the system failure frequency (failures per
unit time), system failures / total simulated time.
availability_interval ¶
availability_interval(confidence=0.95)
Pointwise confidence band for the availability curve.
Uses the Wilson score interval for a binomial proportion, which remains well-behaved when the estimated availability is at or near 0 or 1 (where the plain normal interval collapses to zero width).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
confidence
|
float
|
The confidence level, by default 0.95. |
0.95
|
Returns:
| Type | Description |
|---|---|
(ndarray, ndarray)
|
The lower and upper bounds at each time in |
Source code in repyability/rbd/results.py
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 | |
ConfidenceInterval
dataclass
¶
ConfidenceInterval(estimate, lower, upper, confidence, standard_error, n_samples)
Bases: _ResultMapping
A Monte-Carlo estimate with its sampling uncertainty.
Attributes:
| Name | Type | Description |
|---|---|---|
estimate |
float
|
The point estimate (the sample mean). |
lower |
float
|
Lower bound of the confidence interval. |
upper |
float
|
Upper bound of the confidence interval. |
confidence |
float
|
The confidence level the bounds correspond to (e.g. 0.95). |
standard_error |
float
|
The standard error of the estimate. |
n_samples |
int
|
The number of Monte-Carlo samples the estimate was computed from. |
Criticalities
dataclass
¶
Criticalities(operational_criticality_index, iou, failure_criticality_index, restoration_criticality_index)
Bases: _ResultMapping
The importance/criticality measures from an availability simulation.
Attributes:
| Name | Type | Description |
|---|---|---|
operational_criticality_index |
UpDownImportance
|
Time the system and a node were jointly up/down, over the system's up/down time. |
iou |
UpDownImportance
|
Intersection-over-union of a node's and the system's up/down intervals. |
failure_criticality_index |
FailureCriticalityIndex
|
How much each node drives system failures. |
restoration_criticality_index |
RestorationCriticalityIndex
|
How much each node drives system restorations. |
UpDownImportance
dataclass
¶
UpDownImportance(up, down)
Bases: _ResultMapping
An importance measure split by system state.
Attributes:
| Name | Type | Description |
|---|---|---|
up |
dict
|
Per-node measure while the system is up. |
down |
dict
|
Per-node measure while the system is down. |
FailureCriticalityIndex
dataclass
¶
FailureCriticalityIndex(per_system_failure, per_component_failure)
Bases: _ResultMapping
Fractions relating a node's failures to system failures.
Attributes:
| Name | Type | Description |
|---|---|---|
per_system_failure |
dict
|
For each node, the fraction of system failures that the node caused. |
per_component_failure |
dict
|
For each node, the fraction of the node's own failures that caused a system failure. |
RestorationCriticalityIndex
dataclass
¶
RestorationCriticalityIndex(by_system, by_component)
Bases: _ResultMapping
Fractions relating a node's restorations to system restorations.
Attributes:
| Name | Type | Description |
|---|---|---|
by_system |
dict
|
For each node, the fraction of system restorations that the node caused. |
by_component |
dict
|
For each node, the fraction of the node's own restorations that restored the system. |
MaintenancePolicy
dataclass
¶
MaintenancePolicy(interval, cost_rate)
An optimal preventive-maintenance policy for a single component.
Returned by NonRepairable.optimal_replacement_policy() (age
replacement) and Repairable.optimal_overhaul_policy() (overhaul
under minimal repair).
Attributes:
| Name | Type | Description |
|---|---|---|
interval |
float
|
The optimal preventive interval: the replacement age for an
age-replacement policy, or the overhaul interval for a
minimal-repair component. |
cost_rate |
float
|
The long-run cost per unit time under the policy. When
|