CUQIpy 1.2.0.post0.dev305__py3-none-any.whl → 1.2.0.post0.dev333__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of CUQIpy might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CUQIpy
3
- Version: 1.2.0.post0.dev305
3
+ Version: 1.2.0.post0.dev333
4
4
  Summary: Computational Uncertainty Quantification for Inverse problems in Python
5
5
  Maintainer-email: "Nicolai A. B. Riis" <nabr@dtu.dk>, "Jakob S. Jørgensen" <jakj@dtu.dk>, "Amal M. Alghamdi" <amaal@dtu.dk>, Chao Zhang <chaz@dtu.dk>
6
6
  License: Apache License
@@ -1,6 +1,6 @@
1
1
  cuqi/__init__.py,sha256=LsGilhl-hBLEn6Glt8S_l0OJzAA1sKit_rui8h-D-p0,488
2
2
  cuqi/_messages.py,sha256=fzEBrZT2kbmfecBBPm7spVu7yHdxGARQB4QzXhJbCJ0,415
3
- cuqi/_version.py,sha256=CQLIC5_dwm8tSsiUeJmyVr-z-B8P5Oay1-7eVxbDQkk,510
3
+ cuqi/_version.py,sha256=qPKK2uUFBvtSRlgd2DlR8troFnOrSR3hAOTup08CdOY,510
4
4
  cuqi/config.py,sha256=wcYvz19wkeKW2EKCGIKJiTpWt5kdaxyt4imyRkvtTRA,526
5
5
  cuqi/diagnostics.py,sha256=5OrbJeqpynqRXOe5MtOKKhe7EAVdOEpHIqHnlMW9G_c,3029
6
6
  cuqi/array/__init__.py,sha256=-EeiaiWGNsE3twRS4dD814BIlfxEsNkTCZUc5gjOXb0,30
@@ -46,14 +46,14 @@ cuqi/experimental/mcmc/_langevin_algorithm.py,sha256=NIoCLKL5x89Bxm-JLDLR_NTunRE
46
46
  cuqi/experimental/mcmc/_laplace_approximation.py,sha256=XcGIa2wl9nCSTtAFurejYYOKkDVAJ22q75xQKsyu2nI,5803
47
47
  cuqi/experimental/mcmc/_mh.py,sha256=MXo0ahXP4KGFkaY4HtvcBE-TMQzsMlTmLKzSvpz7drU,2941
48
48
  cuqi/experimental/mcmc/_pcn.py,sha256=wqJBZLuRFSwxihaI53tumAg6AWVuceLMOmXssTetd1A,3374
49
- cuqi/experimental/mcmc/_rto.py,sha256=j3PD3ZfOuGifbBu51Z7GdMCM47HjH0luhpWFDPXNtxc,10477
49
+ cuqi/experimental/mcmc/_rto.py,sha256=lzfeUuV8jUiWG-80KQ4if6toVcX7bMv-a0chBZq0vZ4,12021
50
50
  cuqi/experimental/mcmc/_sampler.py,sha256=BZHnpB6s-YSddd46wQSds0vNF61RA58Nc9ZU05WngdU,20184
51
51
  cuqi/experimental/mcmc/_utilities.py,sha256=kUzHbhIS3HYZRbneNBK41IogUYX5dS_bJxqEGm7TQBI,525
52
52
  cuqi/geometry/__init__.py,sha256=Tz1WGzZBY-QGH3c0GiyKm9XHN8MGGcnU6TUHLZkzB3o,842
53
- cuqi/geometry/_geometry.py,sha256=SDRZdiN2CIuS591lXxqgFoPWPIpwY-MHk75116QvdYY,46901
53
+ cuqi/geometry/_geometry.py,sha256=5ZNrw6LivxEEw0vrk1eCxKIw-8mkAh7930voRVywDbY,47089
54
54
  cuqi/implicitprior/__init__.py,sha256=6z3lvw-tWDyjZSpB3pYzvijSMK9Zlf1IYqOVTtMD2h4,309
55
- cuqi/implicitprior/_regularizedGMRF.py,sha256=IR9tKzNMoz-b0RKu6ahVgMx_lDNB3jZHVWFMQm6QqZk,6259
56
- cuqi/implicitprior/_regularizedGaussian.py,sha256=cQtrgzyJU2pwoK4ORGl1erKLE9VY5NqwZTiqiViDswA,12371
55
+ cuqi/implicitprior/_regularizedGMRF.py,sha256=rr3R2C1aheuu_KD35MureZKfOwY8O1pkVDHvuaFnFFU,6300
56
+ cuqi/implicitprior/_regularizedGaussian.py,sha256=mzaAHq0yz73FZo-OB2iqFMd2i2NNzVv4mjd9-ger8a0,15435
57
57
  cuqi/implicitprior/_regularizedUnboundedUniform.py,sha256=H2fTOSqYTlDiLxQ7Ya6wnpCUIkpO4qKrkTOsOPnBBeU,3483
58
58
  cuqi/implicitprior/_restorator.py,sha256=ixnH8RGcLpqlaIUdR5Dwjx72sO9f3BeotNFRC7Z7qZo,9198
59
59
  cuqi/likelihood/__init__.py,sha256=QXif382iwZ5bT3ZUqmMs_n70JVbbjxbqMrlQYbMn4Zo,1776
@@ -81,14 +81,14 @@ cuqi/sampler/_sampler.py,sha256=TkZ_WAS-5Q43oICa-Elc2gftsRTBd7PEDUMDZ9tTGmU,5712
81
81
  cuqi/samples/__init__.py,sha256=vCs6lVk-pi8RBqa6cIN5wyn6u-K9oEf1Na4k1ZMrYv8,44
82
82
  cuqi/samples/_samples.py,sha256=hUc8OnCF9CTCuDTrGHwwzv3wp8mG_6vsJAFvuQ-x0uA,35832
83
83
  cuqi/solver/__init__.py,sha256=3eoTTgBHe3M6ygrbgUVG3GlqaZVe5lGajNV9rolXZJ8,179
84
- cuqi/solver/_solver.py,sha256=4LdfxLaU-fUHltZw7Sq-Xohyxd_6RvKy03xxtIMW6Zs,29488
84
+ cuqi/solver/_solver.py,sha256=GquU_rj-9yfPQnBVE_gXo4wdF84xw_pLks3bJarzR58,29491
85
85
  cuqi/testproblem/__init__.py,sha256=DWTOcyuNHMbhEuuWlY5CkYkNDSAqhvsKmJXBLivyblU,202
86
86
  cuqi/testproblem/_testproblem.py,sha256=x769LwwRdJdzIiZkcQUGb_5-vynNTNALXWKato7sS0Q,52540
87
87
  cuqi/utilities/__init__.py,sha256=H7xpJe2UinjZftKvE2JuXtTi4DqtkR6uIezStAXwfGg,428
88
88
  cuqi/utilities/_get_python_variable_name.py,sha256=QwlBVj2koJRA8s8pWd554p7-ElcI7HUwY32HknaR92E,1827
89
89
  cuqi/utilities/_utilities.py,sha256=Jc4knn80vLoA7kgw9FzXwKVFGaNBOXiA9kgvltZU3Ao,11777
90
- CUQIpy-1.2.0.post0.dev305.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
91
- CUQIpy-1.2.0.post0.dev305.dist-info/METADATA,sha256=HMjktvjoT8Oo0N4v-2SYK5MnRGT6RdeqEwnQ2pMsAik,18496
92
- CUQIpy-1.2.0.post0.dev305.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
93
- CUQIpy-1.2.0.post0.dev305.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
94
- CUQIpy-1.2.0.post0.dev305.dist-info/RECORD,,
90
+ CUQIpy-1.2.0.post0.dev333.dist-info/LICENSE,sha256=kJWRPrtRoQoZGXyyvu50Uc91X6_0XRaVfT0YZssicys,10799
91
+ CUQIpy-1.2.0.post0.dev333.dist-info/METADATA,sha256=01FrLb_xnRL-lDXDLU48mtTy--nELMrPyY_rX0deLUg,18496
92
+ CUQIpy-1.2.0.post0.dev333.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
93
+ CUQIpy-1.2.0.post0.dev333.dist-info/top_level.txt,sha256=AgmgMc6TKfPPqbjV0kvAoCBN334i_Lwwojc7HE3ZwD0,5
94
+ CUQIpy-1.2.0.post0.dev333.dist-info/RECORD,,
cuqi/_version.py CHANGED
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2024-11-19T23:04:41+0300",
11
+ "date": "2024-11-20T12:41:18+0100",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "40cfaf6a083e595a757ef044e21ab931a869b2fe",
15
- "version": "1.2.0.post0.dev305"
14
+ "full-revisionid": "e495208f39ca278465cb4819799b22c942a1b863",
15
+ "version": "1.2.0.post0.dev333"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -3,7 +3,7 @@ from scipy.linalg.interpolative import estimate_spectral_norm
3
3
  from scipy.sparse.linalg import LinearOperator as scipyLinearOperator
4
4
  import numpy as np
5
5
  import cuqi
6
- from cuqi.solver import CGLS, FISTA
6
+ from cuqi.solver import CGLS, FISTA, ADMM
7
7
  from cuqi.experimental.mcmc import Sampler
8
8
 
9
9
 
@@ -161,6 +161,13 @@ class RegularizedLinearRTO(LinearRTO):
161
161
  Regularized Linear RTO (Randomize-Then-Optimize) sampler.
162
162
 
163
163
  Samples posterior related to the inverse problem with Gaussian likelihood and implicit Gaussian prior, and where the forward model is Linear.
164
+ The sampler works by repeatedly solving regularized linear least squares problems for perturbed data.
165
+ The solver for these optimization problems is chosen based on how the regularized is provided in the implicit Gaussian prior.
166
+ Currently we use the following solvers:
167
+ FISTA: [1] Beck, Amir, and Marc Teboulle. "A fast iterative shrinkage-thresholding algorithm for linear inverse problems." SIAM journal on imaging sciences 2.1 (2009): 183-202.
168
+ Used when prior.proximal is callable.
169
+ ADMM: [2] Boyd et al. "Distributed optimization and statistical learning via the alternating direction method of multipliers."Foundations and Trends® in Machine learning, 2011.
170
+ Used when prior.proximal is a list of penalty terms.
164
171
 
165
172
  Parameters
166
173
  ------------
@@ -171,12 +178,19 @@ class RegularizedLinearRTO(LinearRTO):
171
178
  Initial point for the sampler. *Optional*.
172
179
 
173
180
  maxit : int
174
- Maximum number of iterations of the inner FISTA solver. *Optional*.
181
+ Maximum number of iterations of the inner FISTA/ADMM solver. *Optional*.
182
+
183
+ inner_max_it : int
184
+ Maximum number of iterations of the CGLS solver used within the ADMM solver. *Optional*.
175
185
 
176
186
  stepsize : string or float
177
187
  If stepsize is a string and equals either "automatic", then the stepsize is automatically estimated based on the spectral norm.
178
188
  If stepsize is a float, then this stepsize is used.
179
189
 
190
+ penalty_parameter : int
191
+ Penalty parameter of the inner ADMM solver. *Optional*.
192
+ See [2] or `cuqi.solver.ADMM`
193
+
180
194
  abstol : float
181
195
  Absolute tolerance of the inner FISTA solver. *Optional*.
182
196
 
@@ -190,7 +204,7 @@ class RegularizedLinearRTO(LinearRTO):
190
204
  An example is shown in demos/demo31_callback.py.
191
205
 
192
206
  """
193
- def __init__(self, target=None, initial_point=None, maxit=100, stepsize="automatic", abstol=1e-10, adaptive=True, **kwargs):
207
+ def __init__(self, target=None, initial_point=None, maxit=100, inner_max_it=10, stepsize="automatic", penalty_parameter=10, abstol=1e-10, adaptive=True, **kwargs):
194
208
 
195
209
  super().__init__(target=target, initial_point=initial_point, **kwargs)
196
210
 
@@ -199,10 +213,13 @@ class RegularizedLinearRTO(LinearRTO):
199
213
  self.abstol = abstol
200
214
  self.adaptive = adaptive
201
215
  self.maxit = maxit
216
+ self.inner_max_it = inner_max_it
217
+ self.penalty_parameter = penalty_parameter
202
218
 
203
219
  def _initialize(self):
204
220
  super()._initialize()
205
- self._stepsize = self._choose_stepsize()
221
+ if self._inner_solver == "FISTA":
222
+ self._stepsize = self._choose_stepsize()
206
223
 
207
224
  @property
208
225
  def proximal(self):
@@ -212,8 +229,7 @@ class RegularizedLinearRTO(LinearRTO):
212
229
  super().validate_target()
213
230
  if not isinstance(self.target.prior, (cuqi.implicitprior.RegularizedGaussian, cuqi.implicitprior.RegularizedGMRF)):
214
231
  raise TypeError("Prior needs to be RegularizedGaussian or RegularizedGMRF")
215
- if not callable(self.proximal):
216
- raise TypeError("Proximal needs to be callable")
232
+ self._inner_solver = "FISTA" if callable(self.proximal) else "ADMM"
217
233
 
218
234
  def _choose_stepsize(self):
219
235
  if isinstance(self.stepsize, str):
@@ -237,8 +253,16 @@ class RegularizedLinearRTO(LinearRTO):
237
253
 
238
254
  def step(self):
239
255
  y = self.b_tild + np.random.randn(len(self.b_tild))
240
- sim = FISTA(self.M, y, self.proximal,
241
- self.current_point, maxit = self.maxit, stepsize = self._stepsize, abstol = self.abstol, adaptive = self.adaptive)
256
+
257
+ if self._inner_solver == "FISTA":
258
+ sim = FISTA(self.M, y, self.proximal,
259
+ self.current_point, maxit = self.maxit, stepsize = self._stepsize, abstol = self.abstol, adaptive = self.adaptive)
260
+ elif self._inner_solver == "ADMM":
261
+ sim = ADMM(self.M, y, self.proximal,
262
+ self.current_point, self.penalty_parameter, maxit = self.maxit, inner_max_it = self.inner_max_it, adaptive = self.adaptive)
263
+ else:
264
+ raise ValueError("Choice of solver not supported.")
265
+
242
266
  self.current_point, _ = sim.solve()
243
267
  acc = 1
244
268
  return acc
@@ -522,6 +522,9 @@ class Image2D(Geometry):
522
522
  Plotting is handled via matplotlib.pyplot.imshow.
523
523
  Colormap is defaulted to grayscale.
524
524
 
525
+ A How-To guide on the use of Image2D as the domain/range geometry of a CUQI
526
+ :class:`Model` is available `here <https://cuqi-dtu.github.io/CUQIpy/user/_auto_howtos/myula.html>`_.
527
+
525
528
  Parameters
526
529
  -----------
527
530
  im_shape : tuple
@@ -63,6 +63,7 @@ class RegularizedGMRF(RegularizedGaussian):
63
63
 
64
64
  # Underlying explicit GMRF
65
65
  self._gaussian = GMRF(mean, prec, bc_type=bc_type, order=order, **kwargs)
66
+ kwargs.pop("geometry", None)
66
67
 
67
68
  # Init from abstract distribution class
68
69
  super(Distribution, self).__init__(**kwargs)
@@ -1,6 +1,8 @@
1
1
  from cuqi.utilities import get_non_default_args
2
2
  from cuqi.distribution import Distribution, Gaussian
3
3
  from cuqi.solver import ProjectNonnegative, ProjectBox, ProximalL1
4
+ from cuqi.geometry import Continuous1D, Continuous2D, Image2D
5
+ from cuqi.operator import FirstOrderFiniteDifference
4
6
 
5
7
  import numpy as np
6
8
 
@@ -39,17 +41,22 @@ class RegularizedGaussian(Distribution):
39
41
  sqrtprec
40
42
  See :class:`~cuqi.distribution.Gaussian` for details.
41
43
 
42
- proximal : callable f(x, scale) or None
43
- Euclidean proximal operator f of the regularization function g, that is, a solver for the optimization problem
44
- min_z 0.5||x-z||_2^2+scale*g(x).
45
-
44
+ proximal : callable f(x, scale), list of tuples (callable proximal operator of f_i, linear operator L_i) or None
45
+ If callable:
46
+ Euclidean proximal operator f of the regularization function g, that is, a solver for the optimization problem
47
+ min_z 0.5||x-z||_2^2+scale*g(x).
48
+ If list of tuples (callable proximal operator of f_i, linear operator L_i):
49
+ Each callable proximal operator of f_i accepts two arguments (x, p) and should return the minimizer of p/2||x-z||^2 + f(x) over z for some f.
50
+ The corresponding regularization takes the form
51
+ sum_i f_i(L_i x),
52
+ where the sum ranges from 1 to an arbitrary n.
46
53
 
47
54
  projector : callable f(x) or None
48
55
  Euclidean projection onto the constraint C, that is, a solver for the optimization problem
49
56
  min_(z in C) 0.5||x-z||_2^2.
50
57
 
51
58
  constraint : string or None
52
- Preset constraints. Can be set to "nonnegativity" and "box". Required for use in Gibbs.
59
+ Preset constraints that generate the corresponding proximal parameter. Can be set to "nonnegativity" and "box". Required for use in Gibbs.
53
60
  For "box", the following additional parameters can be passed:
54
61
  lower_bound : array_like or None
55
62
  Lower bound of box, defaults to zero
@@ -57,10 +64,10 @@ class RegularizedGaussian(Distribution):
57
64
  Upper bound of box, defaults to one
58
65
 
59
66
  regularization : string or None
60
- Preset regularization. Can be set to "l1". Required for use in Gibbs in future update.
61
- For "l1", the following additional parameters can be passed:
67
+ Preset regularization that generate the corresponding proximal parameter. Can be set to "l1" or 'tv'. Required for use in Gibbs in future update.
68
+ For "l1" or "tv", the following additional parameters can be passed:
62
69
  strength : scalar
63
- Regularization parameter, i.e., strength*||x||_1 , defaults to one
70
+ Regularization parameter, i.e., strength*||Lx||_1, defaults to one
64
71
 
65
72
  """
66
73
 
@@ -75,6 +82,7 @@ class RegularizedGaussian(Distribution):
75
82
 
76
83
  # We init the underlying Gaussian first for geometry and dimensionality handling
77
84
  self._gaussian = Gaussian(mean=mean, cov=cov, prec=prec, sqrtcov=sqrtcov, sqrtprec=sqrtprec, **kwargs)
85
+ kwargs.pop("geometry", None)
78
86
 
79
87
  # Init from abstract distribution class
80
88
  super().__init__(**kwargs)
@@ -88,12 +96,6 @@ class RegularizedGaussian(Distribution):
88
96
  if (proximal is not None) + (projector is not None) + (constraint is not None) + (regularization is not None) != 1:
89
97
  raise ValueError("Precisely one of proximal, projector, constraint or regularization needs to be provided.")
90
98
 
91
- if proximal is not None:
92
- if not callable(proximal):
93
- raise ValueError("Proximal needs to be callable.")
94
- if len(get_non_default_args(proximal)) != 2:
95
- raise ValueError("Proximal should take 2 arguments.")
96
-
97
99
  if projector is not None:
98
100
  if not callable(projector):
99
101
  raise ValueError("Projector needs to be callable.")
@@ -104,7 +106,8 @@ class RegularizedGaussian(Distribution):
104
106
  self._preset = None
105
107
 
106
108
  if proximal is not None:
107
- self._proximal = proximal
109
+ # No need to generate the proximal and associated information
110
+ self.proximal = proximal
108
111
  elif projector is not None:
109
112
  self._proximal = lambda z, gamma: projector(z)
110
113
  elif (isinstance(constraint, str) and constraint.lower() == "nonnegativity"):
@@ -113,15 +116,48 @@ class RegularizedGaussian(Distribution):
113
116
  elif (isinstance(constraint, str) and constraint.lower() == "box"):
114
117
  lower = optional_regularization_parameters["lower_bound"]
115
118
  upper = optional_regularization_parameters["upper_bound"]
116
- self._proximal = lambda z, gamma: ProjectBox(z, lower, upper)
119
+ self._proximal = lambda z, _: ProjectBox(z, lower, upper)
117
120
  self._preset = "box" # Not supported in Gibbs
118
121
  elif (isinstance(regularization, str) and regularization.lower() in ["l1"]):
119
- strength = optional_regularization_parameters["strength"]
120
- self._proximal = lambda z, gamma: ProximalL1(z, gamma*strength)
122
+ self._strength = optional_regularization_parameters["strength"]
123
+ self._proximal = lambda z, gamma: ProximalL1(z, gamma*self._strength)
121
124
  self._preset = "l1"
125
+ elif (isinstance(regularization, str) and regularization.lower() in ["tv"]):
126
+ self._strength = optional_regularization_parameters["strength"]
127
+ if isinstance(self.geometry, (Continuous1D, Continuous2D, Image2D)):
128
+ self._transformation = FirstOrderFiniteDifference(self.geometry.fun_shape, bc_type='neumann')
129
+ else:
130
+ raise ValueError("Geometry not supported for total variation")
131
+
132
+ self._regularization_prox = lambda z, gamma: ProximalL1(z, gamma*self._strength)
133
+ self._regularization_oper = self._transformation
134
+
135
+ self._proximal = [(self._regularization_prox, self._regularization_oper)]
136
+ self._preset = "tv"
122
137
  else:
123
138
  raise ValueError("Regularization not supported")
124
139
 
140
+
141
+ @property
142
+ def transformation(self):
143
+ return self._transformation
144
+
145
+ @property
146
+ def strength(self):
147
+ return self._strength
148
+
149
+ @strength.setter
150
+ def strength(self, value):
151
+ if self._preset not in self.regularization_options():
152
+ raise TypeError("Strength is only used when the regularization is set to l1 or TV.")
153
+
154
+ self._strength = value
155
+ if self._preset == "tv":
156
+ self._regularization_prox = lambda z, gamma: ProximalL1(z, gamma*self._strength)
157
+ self._proximal = [(self._regularization_prox, self._regularization_oper)]
158
+ elif self._preset == "l1":
159
+ self._proximal = lambda z, gamma: ProximalL1(z, gamma*self._strength)
160
+
125
161
  # This is a getter only attribute for the underlying Gaussian
126
162
  # It also ensures that the name of the underlying Gaussian
127
163
  # matches the name of the implicit regularized Gaussian
@@ -135,6 +171,25 @@ class RegularizedGaussian(Distribution):
135
171
  def proximal(self):
136
172
  return self._proximal
137
173
 
174
+ @proximal.setter
175
+ def proximal(self, value):
176
+ if callable(value):
177
+ if len(get_non_default_args(value)) != 2:
178
+ raise ValueError("Proximal should take 2 arguments.")
179
+ elif isinstance(value, list):
180
+ for (prox, op) in value:
181
+ if len(get_non_default_args(prox)) != 2:
182
+ raise ValueError("Proximal should take 2 arguments.")
183
+ if op.shape[1] != self.geometry.par_dim:
184
+ raise ValueError("Incorrect shape of linear operator in proximal list.")
185
+ else:
186
+ raise ValueError("Proximal needs to be callable or a list. See documentation.")
187
+
188
+ self._proximal = value
189
+
190
+ # For all the presets, self._proximal is set directly,
191
+ self._preset = None
192
+
138
193
  @property
139
194
  def preset(self):
140
195
  return self._preset
@@ -154,7 +209,7 @@ class RegularizedGaussian(Distribution):
154
209
 
155
210
  @staticmethod
156
211
  def regularization_options():
157
- return ["l1"]
212
+ return ["l1", "tv"]
158
213
 
159
214
 
160
215
  # --- Defer behavior of the underlying Gaussian --- #
@@ -206,16 +261,18 @@ class RegularizedGaussian(Distribution):
206
261
  def sqrtcov(self, value):
207
262
  self.gaussian.sqrtcov = value
208
263
 
209
- def get_conditioning_variables(self):
210
- return self.gaussian.get_conditioning_variables()
211
-
212
264
  def get_mutable_variables(self):
213
- return self.gaussian.get_mutable_variables()
265
+ mutable_vars = self.gaussian.get_mutable_variables().copy()
266
+ if self.preset in self.regularization_options():
267
+ mutable_vars += ["strength"]
268
+ return mutable_vars
214
269
 
215
270
  # Overwrite the condition method such that the underlying Gaussian is conditioned in general, except when conditioning on self.name
216
271
  # which means we convert Distribution to Likelihood or EvaluatedDensity.
217
272
  def _condition(self, *args, **kwargs):
218
-
273
+ if self.preset in self.regularization_options():
274
+ return super()._condition(*args, **kwargs)
275
+
219
276
  # Handle positional arguments (similar code as in Distribution._condition)
220
277
  cond_vars = self.get_conditioning_variables()
221
278
  kwargs = self._parse_args_add_to_kwargs(cond_vars, *args, **kwargs)
@@ -275,7 +332,7 @@ class ConstrainedGaussian(RegularizedGaussian):
275
332
  min_(z in C) 0.5||x-z||_2^2.
276
333
 
277
334
  constraint : string or None
278
- Preset constraints. Can be set to "nonnegativity" and "box". Required for use in Gibbs.
335
+ Preset constraints that generate the corresponding proximal parameter. Can be set to "nonnegativity" and "box". Required for use in Gibbs.
279
336
  For "box", the following additional parameters can be passed:
280
337
  lower_bound : array_like or None
281
338
  Lower bound of box, defaults to zero
cuqi/solver/_solver.py CHANGED
@@ -669,7 +669,7 @@ class ADMM(object):
669
669
  - flag=2 indicates multiplication of the transpose of A with vector x, that is A.T @ x.
670
670
  b : ndarray.
671
671
  penalty_terms : List of tuples (callable proximal operator of f_i, linear operator L_i)
672
- Each callable proximal operator f_i accepts two arguments (x, p) and should return the minimizer of p/2||x-z||^2 + f(x) over z for some f.
672
+ Each callable proximal operator of f_i accepts two arguments (x, p) and should return the minimizer of p/2||x-z||^2 + f(x) over z for some f.
673
673
  x0 : ndarray. Initial guess.
674
674
  penalty_parameter : Trade-off between linear least squares and regularization term in the solver iterates. Denoted as "rho" in [1].
675
675
  maxit : The maximum number of iterations.