From bc1d952f3b8a660744671bf57961ec4514851ee2 Mon Sep 17 00:00:00 2001 From: domfournier Date: Thu, 31 Oct 2024 08:43:24 -0700 Subject: [PATCH 1/2] Update the algo, remove multplicator in phi_d comp --- simpeg/dask/inverse_problem.py | 4 ++-- simpeg/directives/directives.py | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/simpeg/dask/inverse_problem.py b/simpeg/dask/inverse_problem.py index f1bd70f725..9c0d8d058d 100644 --- a/simpeg/dask/inverse_problem.py +++ b/simpeg/dask/inverse_problem.py @@ -137,9 +137,9 @@ def dask_evalFunction(self, m, return_g=True, return_H=True): self.dpred = self.get_dpred(m, compute_J=return_H) phi_d = 0 - for (mult, objfct), pred in zip(self.dmisfit, self.dpred): + for (_, objfct), pred in zip(self.dmisfit, self.dpred): residual = objfct.W * (objfct.data.dobs - pred) - phi_d += mult * np.vdot(residual, residual) + phi_d += np.vdot(residual, residual) phi_d = np.asarray(phi_d) # print(self.dpred[0]) diff --git a/simpeg/directives/directives.py b/simpeg/directives/directives.py index ac95c20c32..ef554a24c1 100644 --- a/simpeg/directives/directives.py +++ b/simpeg/directives/directives.py @@ -3586,7 +3586,7 @@ def __init__(self, path: Path | None, **kwargs): def initialize(self): self.last_beta = self.invProb.beta self.multipliers = self.invProb.dmisfit.multipliers - + self.scalings = np.ones_like(self.multipliers) with open(self.filepath, "w", encoding="utf-8") as f: f.write("Logging of [scaling * chi factor] per misfit function.\n\n") f.write( @@ -3599,28 +3599,31 @@ def initialize(self): def endIter(self): ratio = self.invProb.beta / self.last_beta + + if ratio > 1: + return + chi_factors = [] - phi_ds = [] for objfct, pred in zip(self.invProb.dmisfit.objfcts, self.invProb.dpred): residual = objfct.W * (objfct.data.dobs - pred) phi_d = np.vdot(residual, residual) chi_factors.append(phi_d / objfct.nD) - phi_ds.append(phi_d) - phi_ds = np.asarray(phi_ds) chi_factors = np.asarray(chi_factors) - scalings = chi_factors / chi_factors.max() - # Force beta ratio scaling if below target - scalings[chi_factors < 1] *= ratio + # Normalize scaling between [ratio, 1] + scalings = ( + 1 - (1 - ratio) * (chi_factors.max() - chi_factors) / chi_factors.max() + ) + + # Force the ones that overshot target + scalings[chi_factors < 1] = ratio * chi_factors[chi_factors < 1] + + # Update the scaling + self.scalings *= scalings # Normalize total phi_d with scalings - multipliers = ( - self.multipliers - * scalings - * phi_ds.sum() - / (self.multipliers * phi_ds * scalings).sum() - ) + multipliers = self.multipliers * self.scalings with open(self.filepath, "a", encoding="utf-8") as f: f.write( From edc650f5f4283d12a99983585370ef3c17da8ad8 Mon Sep 17 00:00:00 2001 From: domfournier Date: Thu, 31 Oct 2024 08:44:10 -0700 Subject: [PATCH 2/2] Suppress warning from pardiso --- simpeg/dask/electromagnetics/static/resistivity/simulation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simpeg/dask/electromagnetics/static/resistivity/simulation.py b/simpeg/dask/electromagnetics/static/resistivity/simulation.py index d82a0f2198..292cbfa206 100644 --- a/simpeg/dask/electromagnetics/static/resistivity/simulation.py +++ b/simpeg/dask/electromagnetics/static/resistivity/simulation.py @@ -7,6 +7,10 @@ import numcodecs +import warnings + +warnings.filterwarnings("ignore", category=FutureWarning) + numcodecs.blosc.use_threads = False Sim.sensitivity_path = "./sensitivity/"