Skip to content

Commit cb0b8a4

Browse files
authored
Merge pull request #120 from MiraGeoscience/GEOPY-2518
GEOPY-2518: Crash on no-upper bound for MVI within a joint process
2 parents 825b0b7 + 96eaf5b commit cb0b8a4

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

simpeg/directives/_vector_models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def endIter(self):
129129
model = self.invProb.model.copy()
130130

131131
# Project bounds
132-
if self.mode == "cartesian" and np.any(~np.isinf(self.opt.upper)):
132+
if self.mode == "cartesian":
133133
vec_model = []
134134
indices = []
135135
upper_bound = []
@@ -140,12 +140,12 @@ def endIter(self):
140140
indices.append(mapping.indices)
141141

142142
amplitude = np.linalg.norm(np.vstack(vec_model), axis=0)
143-
upper_bound = np.hstack(upper_bound)
144-
upper_bound = np.max(upper_bound[~np.isinf(upper_bound)])
143+
upper_bound = np.linalg.norm(np.vstack(upper_bound), axis=0)
145144
out_bound = amplitude > upper_bound
146145

147146
if np.any(out_bound):
148147
scale = upper_bound / amplitude
148+
149149
for ind in indices:
150150
vec = model[ind]
151151
vec[out_bound] *= scale[out_bound]
@@ -165,16 +165,19 @@ def endIter(self):
165165
vec_ref = []
166166
indices = []
167167
mappings = []
168+
upper_bound = []
168169
for reg in self.regularizations.objfcts:
169170
mappings.append(reg.mapping)
170171
vec_model.append(reg.mapping * model)
171172
vec_ref.append(reg.mapping * reg.reference_model)
173+
upper_bound.append(reg.mapping * self.opt.upper)
172174
mapping = reg.mapping.deriv(np.zeros(reg.mapping.shape[1]))
173175
indices.append(mapping.indices)
174176

175177
indices = np.hstack(indices)
176178
nC = mapping.shape[0]
177179
vec_model = cartesian2spherical(np.vstack(vec_model).T)
180+
upper_bound = np.linalg.norm(np.vstack(upper_bound), axis=0)
178181
vec_ref = cartesian2spherical(np.vstack(vec_ref).T).flatten()
179182
model[indices] = vec_model.flatten()
180183

@@ -218,7 +221,9 @@ def endIter(self):
218221
self.opt.lower[indices] = np.kron(
219222
np.asarray([0, -np.inf, -np.inf]), np.ones(nC)
220223
)
221-
self.opt.upper[indices[nC:]] = np.inf
224+
self.opt.upper[indices] = np.r_[
225+
upper_bound, np.ones_like(indices[nC:]) * np.inf
226+
]
222227

223228
updates = {}
224229
for misfit in self.misfits:

0 commit comments

Comments
 (0)