1
2
3
4
5
6
7
8
9
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
//! Python wrapper for the solver operation in [`crate::ops::solver`].
//!
//! Free function solving a linear system into a [`PyNodeField`]. Kept here —
//! mirroring `src/ops/solver/` — per the `py/ops/` convention (its identity
//! is the *operation*, not its `NodeField` result).
use crate;
use cratePyMatrix;
use cratePyNodeField;
use cratePySignals;
use *;
use py_op;
/// Solve the linear system `A·x = b` for `x` (sparse direct, faer).
///
/// `matrix` is the assembled system `A`; `rhs` is the right-hand side `b` as a
/// `NodeField`, read at every row DOF of the matrix (a DOF no zone defines
/// reads zero). The imposed value of a constraint relation lives at its
/// multiplier node, component `imposed`. The matrix carries everything the
/// solve needs: its relation rows, their coefficients and their sense (`=`,
/// `>=`, `<=`), declared by the constraints that built them — no model is
/// passed alongside.
///
/// `relations` says how the constraint relations are enforced:
///
/// - `"lagrange"` (default) — by their multipliers, the saddle-point solved as
/// assembled; the multipliers come back in the solution as the reactions.
/// As soon as the matrix carries an inequality, the **active-set** loop
/// decides which relations are saturated: an active relation holds as an
/// equation (its `lambda` is `<= 0` for `>=`, `>= 0` for `<=`), an inactive
/// one reports `lambda = 0`;
/// - `"eliminate"` — each equality relation eliminates one unknown, and the
/// smaller system left, without multipliers, is solved; each eliminated
/// unknown's reaction is returned in its dual row. An inequality is not
/// eliminated: it stays on the reduced system, resolved by the same
/// active-set loop, its `lambda` returned at its multiplier node. Scope:
/// non-chained, disjoint slaves.
///
/// `method` selects the factorization: `"lu"` (default) works on any square
/// matrix, `"cholesky"` asks that the system be symmetric **and** positive
/// definite — never a Lagrange saddle-point, usually a system reduced by
/// elimination. The active-set loop factorizes by LU whatever is asked.
///
/// `active_set` selects how each status of the active-set loop is factorized:
/// `"schur"` (default) factorizes the inequality-free base once and updates it
/// per status (falling back when that base is singular), `"refactorize"`
/// refactorizes the full system at each status change. `max_iter` (default
/// `100`) bounds the status loop; `tol` (default `1e-10`) is its sign
/// tolerance on the multiplier and on the gap.
///
/// `cache` (default `True`) reuses what is stored transparently on the matrix —
/// the factorization, the condensation, the active-set state and its last
/// status — cleared automatically when the matrix changes. A matrix keeps one
/// of them at a time, and a factorization serves the `method` it was made
/// with only: another `relations` or `method` computes afresh and replaces it. `verbosity` says
/// how much the solve reports on stdout: `"silent"` (default), `"brief"` or
/// `"detailed"`.
///
/// A `Ctrl+C` is honoured at the solver's phase boundaries and at each status
/// iteration; a factorization itself is a single library call and is not
/// interrupted mid-way.