@@ -6,6 +6,34 @@ to use this in an actual problem, see
6
6
7
7
Notation wise we are trying to solve for ` x ` such that ` nlfunc(x) = 0 ` .
8
8
9
+ ## Big Table for Determining Sparsity Detection and Coloring Algorithms
10
+
11
+ | ` f.sparsity ` | ` f.jac_prototype ` | ` f.colorvec ` | Sparsity Detection | Coloring Algorithm |
12
+ | :------------------------- | :---------------- | :----------- | :----------------------------------------------- | :---------------------------------------- |
13
+ | ❌ | ❌ | ` Any ` | ` NoSparsityDetector() ` | ` NoColoringAlgorithm() ` |
14
+ | ❌ | Not Structured | ` Any ` | ` NoSparsityDetector() ` | ` NoColoringAlgorithm() ` |
15
+ | ❌ | Structured | ✅ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
16
+ | ❌ | Structured | ❌ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
17
+ | - | - | - | - | - |
18
+ | ` AbstractMatrix ` | ❌ | ✅ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
19
+ | ` AbstractMatrix ` | ❌ | ❌ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
20
+ | ` AbstractMatrix ` | Not Structured | ✅ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
21
+ | ` AbstractMatrix ` | Not Structured | ❌ | ` KnownJacobianSparsityDetector(f.sparsity) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
22
+ | ` AbstractMatrix ` | Structured | ` Any ` | 🔴 | 🔴 |
23
+ | - | - | - | - | - |
24
+ | ` AbstractSparsityDetector ` | ❌ | ` Any ` | ` f.sparsity ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
25
+ | ` AbstractSparsityDetector ` | Not Structured | ✅ | ` f.sparsity ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
26
+ | ` AbstractSparsityDetector ` | Not Structured | ❌ | ` f.sparsity ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
27
+ | ` AbstractSparsityDetector ` | Structured | ✅ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` ConstantColoringAlgorithm(f.colorvec) ` |
28
+ | ` AbstractSparsityDetector ` | Structured | ❌ | ` KnownJacobianSparsityDetector(f.jac_prototype) ` | ` GreedyColoringAlgorithm(LargestFirst()) ` |
29
+
30
+ 1 . ` Structured ` means either a ` AbstractSparseMatrix ` or ` ArrayInterface.isstructured(x) ` is true.
31
+ 2 . ❌ means not provided (default)
32
+ 3 . ✅ means provided
33
+ 4 . 🔴 means an error will be thrown
34
+ 5 . Providing a colorvec without specifying either sparsity or jac_prototype with a sparse or structured matrix will cause us to ignore the colorvec.
35
+ 6 . The function calls demonstrated above are simply pseudo-code to show the general idea.
36
+
9
37
## Case I: Sparse Jacobian Prototype is Provided
10
38
11
39
Let's say you have a Sparse Jacobian Prototype ` jac_prototype ` , in this case you can
@@ -27,19 +55,12 @@ prob = NonlinearProblem(
27
55
If the ` colorvec ` is not provided, then it is computed on demand.
28
56
29
57
!!! note
30
-
58
+
31
59
One thing to be careful about in this case is that `colorvec` is dependent on the
32
60
autodiff backend used. `ADTypes.mode(ad) isa ADTypes.ForwardMode` will assume that the
33
61
colorvec is the column colorvec, otherwise we will assume that the colorvec is the
34
62
row colorvec.
35
63
36
- !!! warning
37
-
38
- Previously you could provide a ` sparsity ` argument to ` NonlinearFunction ` to specify
39
- the jacobian prototype. However, to avoid confusion, this is now deprecated. Instead,
40
- use the ` jac_prototype ` argument. ` sparsity ` must be used to exclusively specify the
41
- sparsity detection algorithm.
42
-
43
64
## Case II: Sparsity Detection algorithm is provided
44
65
45
66
If you don't have a Sparse Jacobian Prototype, but you know the which sparsity detection
@@ -59,7 +80,7 @@ for more information on sparsity detection algorithms.
59
80
## Case III: Sparse AD Type is being Used
60
81
61
82
!!! warning
62
-
83
+
63
84
This is now deprecated. Please use the previous two cases instead.
64
85
65
86
If you constructed a Nonlinear Solver with a sparse AD type, for example
0 commit comments