Commit d8bb2a8
authored
use-case motivated addition:
- `DiscreteSumConstraint` gets a `coefficients` that works akin to whats
been done in the continuous constraint
- `from_simplex` gets a `simplex_coefficients` keyword that allows
specifying coefficients for the simplex parameters. This is possible by
changing the way the max/min incoming sums are assessed
- I'm using matrix multiplication `@` for `from_simplex` because we
ensure by construciton that the incoming array is contiguous and does
not have to be copied for a reshape and multiplication. This
contiguousness is not guaranteed for `data[params]` in `get_invalid` in
`DiscreteSumConstraint` so its more memory efficient to use per-column
approaches in the assumption of a small countable amount of parameters
(usually the case)
- The restriction that `values` of simplex parameters must be positive
has been lifted (no longer needed)
**Unrelated optimization**
I also replaced the inner loop of `from_simplex` to use numpy and not
pandas. This is also motivated by memory and time efficiency. This
commit can be dropped tho if undesired, but there are singificant time
and mem savings:
| Scenario | Rows | main time (s) | feature time (s) | Δ time | main mem
(MB) | feature mem (MB) | Δ mem |
|---|---:|---:|---:|---:|---:|---:|---:|
| 4p × 11v | 1,001 | 0.025 | 0.005 | -81% | 0.3 | 0.2 | -48% |
| 6p × 11v | 8,008 | 0.068 | 0.005 | -93% | 4.1 | 1.6 | -62% |
| 8p × 11v | 43,758 | 0.280 | 0.010 | -96% | 32.9 | 10.8 | -67% |
| 6p × 21v | 230,230 | 0.904 | 0.019 | -98% | 137.3 | 46.2 | -66% |
| 6p × 21v boundary | 53,130 | 0.961 | 0.020 | -98% | 137.3 | 45.5 |
-67% |
(p = simplex parameters, v = values)
10 files changed
Lines changed: 433 additions & 150 deletions
File tree
- baybe
- constraints
- searchspace
- tests
- constraints
- hypothesis_strategies
- alternative_creation
- serialization
- validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
13 | 23 | | |
14 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
15 | 28 | | |
16 | 29 | | |
17 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
94 | 100 | | |
95 | 101 | | |
96 | 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 | + | |
97 | 134 | | |
98 | 135 | | |
99 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
100 | 142 | | |
101 | 143 | | |
102 | 144 | | |
| |||
105 | 147 | | |
106 | 148 | | |
107 | 149 | | |
108 | | - | |
| 150 | + | |
| 151 | + | |
109 | 152 | | |
110 | 153 | | |
111 | 154 | | |
| |||
0 commit comments