mirror of
https://github.com/wassname/simpeg.git
synced 2026-09-14 11:35:32 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef12a3674a |
+26
-13
@@ -253,8 +253,7 @@ class SaveOutputDictEveryIteration(_SaveEveryIteration):
|
|||||||
class Update_IRLS(InversionDirective):
|
class Update_IRLS(InversionDirective):
|
||||||
|
|
||||||
eps_min = None
|
eps_min = None
|
||||||
eps_p = None
|
eps = None
|
||||||
eps_q = None
|
|
||||||
norms = [2.,2.,2.,2.]
|
norms = [2.,2.,2.,2.]
|
||||||
factor = None
|
factor = None
|
||||||
gamma = None
|
gamma = None
|
||||||
@@ -263,6 +262,7 @@ class Update_IRLS(InversionDirective):
|
|||||||
f_old = None
|
f_old = None
|
||||||
f_min_change = 1e-2
|
f_min_change = 1e-2
|
||||||
beta_tol = 5e-2
|
beta_tol = 5e-2
|
||||||
|
prctile = 95
|
||||||
|
|
||||||
# Solving parameter for IRLS (mode:2)
|
# Solving parameter for IRLS (mode:2)
|
||||||
IRLSiter = 0
|
IRLSiter = 0
|
||||||
@@ -297,9 +297,22 @@ class Update_IRLS(InversionDirective):
|
|||||||
print "Convergence with smooth l2-norm regularization: Start IRLS steps..."
|
print "Convergence with smooth l2-norm regularization: Start IRLS steps..."
|
||||||
|
|
||||||
self.mode = 2
|
self.mode = 2
|
||||||
print self.eps_p, self.eps_q, self.norms
|
|
||||||
self.reg.eps_p = self.eps_p
|
# Either use the supplied epsilon, or fix base on distribution of
|
||||||
self.reg.eps_q = self.eps_q
|
# model values
|
||||||
|
if getattr(self, 'reg.eps', None) is None:
|
||||||
|
self.reg.eps_p = np.percentile(np.abs(self.invProb.curModel),self.prctile)
|
||||||
|
else:
|
||||||
|
self.reg.eps_p = self.eps[0]
|
||||||
|
|
||||||
|
if getattr(self, 'reg.eps', None) is None:
|
||||||
|
self.reg.eps_q = np.percentile(np.abs(self.reg.regmesh.cellDiffxStencil*(self.reg.mapping * self.invProb.curModel)),self.prctile)
|
||||||
|
else:
|
||||||
|
self.reg.eps_q = self.eps[1]
|
||||||
|
|
||||||
|
print "L[p qx qy qz]-norm : " + str(self.reg.norms)
|
||||||
|
print "eps_p: " + str(self.reg.eps_p) + " eps_q: " + str(self.reg.eps_q)
|
||||||
|
|
||||||
self.reg.norms = self.norms
|
self.reg.norms = self.norms
|
||||||
self.coolingFactor = 1.
|
self.coolingFactor = 1.
|
||||||
self.coolingRate = 1
|
self.coolingRate = 1
|
||||||
@@ -343,14 +356,14 @@ class Update_IRLS(InversionDirective):
|
|||||||
else:
|
else:
|
||||||
self.f_old = phim_new
|
self.f_old = phim_new
|
||||||
|
|
||||||
# Cool the threshold parameter if required
|
# # Cool the threshold parameter if required
|
||||||
if getattr(self, 'factor', None) is not None:
|
# if getattr(self, 'factor', None) is not None:
|
||||||
eps = self.reg.eps / self.factor
|
# eps = self.reg.eps / self.factor
|
||||||
|
#
|
||||||
if getattr(self, 'eps_min', None) is not None:
|
# if getattr(self, 'eps_min', None) is not None:
|
||||||
self.reg.eps = np.max([self.eps_min,eps])
|
# self.reg.eps = np.max([self.eps_min,eps])
|
||||||
else:
|
# else:
|
||||||
self.reg.eps = eps
|
# self.reg.eps = eps
|
||||||
|
|
||||||
# Get phi_m at the end of current iteration
|
# Get phi_m at the end of current iteration
|
||||||
self.phi_m_last = self.invProb.phi_m_last
|
self.phi_m_last = self.invProb.phi_m_last
|
||||||
|
|||||||
@@ -42,55 +42,33 @@ def run(N=100, plotIt=True):
|
|||||||
survey = Survey.LinearSurvey()
|
survey = Survey.LinearSurvey()
|
||||||
survey.pair(prob)
|
survey.pair(prob)
|
||||||
survey.dobs = prob.fields(mtrue) + std_noise * np.random.randn(nk)
|
survey.dobs = prob.fields(mtrue) + std_noise * np.random.randn(nk)
|
||||||
#survey.makeSyntheticData(mtrue, std=std_noise)
|
|
||||||
|
|
||||||
wd = np.ones(nk) * std_noise
|
wd = np.ones(nk) * std_noise
|
||||||
|
|
||||||
#print survey.std[0]
|
|
||||||
#M = prob.mesh
|
|
||||||
# Distance weighting
|
# Distance weighting
|
||||||
wr = np.sum(prob.G**2.,axis=0)**0.5
|
wr = np.sum(prob.G**2.,axis=0)**0.5
|
||||||
wr = ( wr/np.max(wr) )
|
wr = ( wr/np.max(wr) )
|
||||||
|
|
||||||
# reg = Regularization.Simple(mesh)
|
|
||||||
# reg.mref = mref
|
|
||||||
# reg.cell_weights = wr
|
|
||||||
#
|
|
||||||
dmis = DataMisfit.l2_DataMisfit(survey)
|
dmis = DataMisfit.l2_DataMisfit(survey)
|
||||||
dmis.Wd = 1./wd
|
dmis.Wd = 1./wd
|
||||||
#
|
|
||||||
# opt = Optimization.ProjectedGNCG(maxIter=20,lower=-2.,upper=2., maxIterCG= 10, tolCG = 1e-4)
|
|
||||||
# invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
|
|
||||||
# invProb.curModel = m0
|
|
||||||
#
|
|
||||||
# beta = Directives.BetaSchedule(coolingFactor=2, coolingRate=1)
|
|
||||||
# target = Directives.TargetMisfit()
|
|
||||||
#
|
|
||||||
betaest = Directives.BetaEstimate_ByEig()
|
betaest = Directives.BetaEstimate_ByEig()
|
||||||
# inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest, target])
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# mrec = inv.run(m0)
|
|
||||||
# ml2 = mrec
|
|
||||||
# print "Final misfit:" + str(invProb.dmisfit.eval(mrec))
|
|
||||||
#
|
|
||||||
# # Switch regularization to sparse
|
|
||||||
# phim = invProb.phi_m_last
|
|
||||||
# phid = invProb.phi_d
|
|
||||||
|
|
||||||
reg = Regularization.Sparse(mesh)
|
reg = Regularization.Sparse(mesh)
|
||||||
reg.mref = mref
|
reg.mref = mref
|
||||||
reg.cell_weights = wr
|
reg.cell_weights = wr
|
||||||
|
|
||||||
reg.mref = np.zeros(mesh.nC)
|
reg.mref = np.zeros(mesh.nC)
|
||||||
eps_p = 5e-2
|
|
||||||
eps_q = 5e-2
|
|
||||||
norms = [0., 0., 2., 2.]
|
|
||||||
|
|
||||||
opt = Optimization.ProjectedGNCG(maxIter=100 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3)
|
opt = Optimization.ProjectedGNCG(maxIter=100 ,lower=-2.,upper=2., maxIterLS = 20, maxIterCG= 10, tolCG = 1e-3)
|
||||||
invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
|
invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
|
||||||
update_Jacobi = Directives.Update_lin_PreCond()
|
update_Jacobi = Directives.Update_lin_PreCond()
|
||||||
IRLS = Directives.Update_IRLS( norms=norms, eps_p=eps_p, eps_q=eps_q)
|
|
||||||
|
# Set the IRLS directive, penalize the lowest 25 percentile of model values
|
||||||
|
# Start with an l2-l2, then switch to lp-norms
|
||||||
|
norms = [0., 0., 2., 2.]
|
||||||
|
IRLS = Directives.Update_IRLS( norms=norms, prctile = 25, maxIRLSiter = 15, minGNiter=3)
|
||||||
|
|
||||||
inv = Inversion.BaseInversion(invProb, directiveList=[IRLS,betaest,update_Jacobi])
|
inv = Inversion.BaseInversion(invProb, directiveList=[IRLS,betaest,update_Jacobi])
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -502,7 +502,9 @@ class InjectActiveCells(IdentityMap):
|
|||||||
if Utils.isScalar(valInactive):
|
if Utils.isScalar(valInactive):
|
||||||
self.valInactive = np.ones(self.nC)*float(valInactive)
|
self.valInactive = np.ones(self.nC)*float(valInactive)
|
||||||
else:
|
else:
|
||||||
self.valInactive = valInactive.copy()
|
self.valInactive = np.ones(self.nC)
|
||||||
|
self.valInactive[self.indInactive] = valInactive.copy()
|
||||||
|
|
||||||
self.valInactive[self.indActive] = 0
|
self.valInactive[self.indActive] = 0
|
||||||
|
|
||||||
inds = np.nonzero(self.indActive)[0]
|
inds = np.nonzero(self.indActive)[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user