Geophysical Inversion and Modelling Library v1.5.4
|
#include <inversion.h>
Public Types | |
typedef RVector | Vec |
typedef RVector | ModelVector |
![]() | |
typedef Vector< double > | ModelVector |
Public Member Functions | |
RInversion (bool verbose=false, bool dosave=false) | |
RInversion (ModellingBase &forward, bool verbose=false, bool dosave=false) | |
RInversion (const Vec &data, ModellingBase &forward, bool verbose=false, bool dosave=false) | |
RInversion (const Vec &data, ModellingBase &forward, Trans< Vec > &transData, bool verbose=true, bool dosave=false) | |
RInversion (const Vec &data, ModellingBase &forward, Trans< Vec > &transData, Trans< Vec > &transModel, bool verbose=true, bool dosave=false) | |
virtual | ~RInversion () |
void | setData (const Vec &data) |
const Vec & | data () const |
void | setRelativeError (const Vec &e) |
void | setRelativeError (double relerr) |
void | setAbsoluteError (const Vec &abserr) |
void | setAbsoluteError (double abserr) |
void | setError (const Vec &err, bool isRelative=true) |
void | setError (double err, bool isRelative=true) |
const Vec & | error () const |
void | checkError () |
Vec | errorDefault_ () |
void | setForwardOperator (ModellingBase &forward) |
ModellingBase * | forwardOperator () |
ModellingBase * | fop () |
void | setTransData (Trans< Vec > &tD) |
Trans< Vec > & | transData () |
void | setTransModel (Trans< Vec > &tM) |
Trans< Vec > & | transModel () |
uint | constraintsCount () const |
uint | dataCount () const |
void | setVerbose (bool verbose) |
bool | verbose () const |
void | setDoSave (bool d) |
bool | doSave () const |
void | saveModelHistory (bool doSaveModelHistory) |
void | setLineSearch (bool linesearch) |
bool | lineSearch () const |
void | setBlockyModel (bool isBlocky) |
bool | blockyModel () const |
void | setRobustData (bool isRobust) |
bool | robustData () const |
void | setLambda (double lambda) |
double | lambda () const |
double | getLambda () const |
void | setLambdaFactor (double lambdaFactor) |
double | lambdaFactor () const |
void | setLambdaMinimum (double l) |
double | lambdaMinimum () const |
void | setLocalRegularization (bool localReg) |
bool | localRegularization () const |
void | setOptimizeLambda (bool opt) |
bool | optimizeLambda () const |
void | setMaxIter (int maxiter) |
int | maxIter () const |
void | setMaxCGLSIter (int iter) |
int | maxCGLSIter () const |
void | setCGLSTolerance (double tol) |
double | maxCGLSTolerance () const |
uint | iter () const |
bool | isRunning () const |
void | abort () |
void | stopAtChi1 (bool stopAtChi1) |
void | setDeltaPhiAbortPercent (double dPhi) |
double | deltaPhiAbortPercent () const |
void | setMarquardtScheme (double lambdaFactor=0.8) |
void | checkTransFunctions () |
void | setRecalcJacobian (bool recalc) |
bool | recalcJacobian () const |
void | setBroydenUpdate (bool broydenUpdate) |
bool | broydenUpdate () const |
void | setModel (const Vec &model) |
const ModelVector & | model () const |
void | setReferenceModel (const Vec &model) |
void | setResponse (const Vec &response) |
void | setConstraintsH (const Vec &constraintsH) |
const Vec & | response () const |
Vec | getIRLS () const |
void | setCWeight (const Vec &cWeight) |
const Vec & | cWeight () const |
void | setMWeight (const Vec &mweight) |
const Vec & | mWeight () const |
void | robustWeighting () |
void | constrainBlocky () |
void | checkConstraints () |
void | checkJacobian (bool force=false) |
void | echoStatus () const |
void | echoStatus (const Vec &response, const Vec &model, const std::string &xtra="") const |
Vec | modelCellResolution (int iModel) |
Vec | modelCellResolution (const RVector3 &pos) |
RMatrix | modelResolutionMatrix () |
RVector | roughness (const RVector &model) const |
RVector | roughness () const |
RVector | pureRoughness (const RVector &model) const |
double | getPhiD (const Vec &response) const |
double | getPhiM (const Vec &model) const |
double | getPhi (const Vec &model, const Vec &response) const |
double | getPhiD () const |
double | getPhiM () const |
double | getPhi () const |
double | getChi2 () const |
double | getChi2 (const Vec &response) const |
double | chi2 () const |
double | absrms () const |
double | relrms () const |
double | linesearch (const Vec &modelNew, const Vec &responseNew) const |
double | linesearchQuad (const Vec &modelNew, const Vec &responseNew, const Vec &modelQuad, const Vec &responseQuad, double tauquad) const |
const std::vector< RVector > & | modelHistory () const |
Vec | invSubStep (const Vec &rhs) |
Vec | optLambda (const Vec &deltaData, const Vec &deltaModel0) |
bool | oneStep () |
!! h-variante | |
const Vec & | invert (const Vec &data) |
const Vec & | start () |
const Vec & | run () |
Vec | runChi1 (double acc=0.01, int maxiter=50) |
const RVector & | modelWeight () const |
const RVector & | modelRef () const |
const RVector & | dataWeight () const |
const RVector & | deltaDataIter () const |
const RVector & | deltaModelIter () const |
void | reset () |
![]() | |
InversionBase () | |
virtual | ~InversionBase () |
Protected Member Functions | |
void | init_ () |
Protected Attributes | |
Vec | data_ |
ModellingBase * | forward_ |
Trans< Vec > * | tD_ |
Trans< Vec > * | tM_ |
Trans< Vec > * | transModelDefault_ |
Trans< Vec > * | transDataDefault_ |
bool | verbose_ |
bool | dosave_ |
bool | saveModelHistory_ |
Vec | error_ |
Vec | response_ |
Vec | model_ |
Vec | modelRef_ |
Vec | constraintsH_ |
Vec | constraintWeights_ |
Vec | modelWeight_ |
Vec | dataWeight_ |
Vec | deltaDataIter_ |
Vec | deltaModelIter_ |
int | maxiter_ |
int | iter_ |
int | maxCGLSIter_ |
double | lambda_ |
double | lambdaFactor_ |
double | lambdaMin_ |
double | dPhiAbortPercent_ |
double | CGLStol_ |
bool | isBlocky_ |
bool | isRobust_ |
bool | isRunning_ |
bool | useLinesearch_ |
bool | optimizeLambda_ |
bool | abort_ |
bool | stopAtChi1_ |
bool | doBroydenUpdate_ |
bool | localRegularization_ |
bool | haveReferenceModel_ |
bool | recalcJacobian_ |
bool | jacobiNeedRecalc_ |
bool | activateFillConstraintWeights_ |
bool | fixError_ |
std::vector< RVector > | modelHist_ |
Inversion template using a Generalized Minimization Approach, atm fixed to Gauss-Newton solver Inversion(bool verbose, bool dosave Inversion(RVector data, FOP f, bool verbose, bool dosave Inversion(RVector data, FOP f, transData, transModel, bool verbose, bool dosave
|
inline |
Minimal constructor. verbose – gives some output and status information about the inversion progress; dosave – advanced debuging, saves alot of stuff and temporary data
References init_(), and GIMLI::InversionBase< double >::InversionBase().
|
inline |
Contructor for forward operator only
References init_(), GIMLI::InversionBase< double >::InversionBase(), and setForwardOperator().
|
inline |
Usual constructor. data – vector of the given data; forward – the associated forward operator
References data(), init_(), GIMLI::InversionBase< double >::InversionBase(), setData(), and setForwardOperator().
|
inline |
Intermediate constructor including transforms and data transformation function
References data(), init_(), GIMLI::InversionBase< double >::InversionBase(), setData(), setForwardOperator(), and setTransData().
|
inline |
Full constructor including transforms. transData – data transformation function; transModel – model transformation function
References data(), init_(), GIMLI::InversionBase< double >::InversionBase(), setData(), setForwardOperator(), setTransData(), and setTransModel().
|
inlinevirtual |
Destructor. Frees allocated memory
|
inlinevirtual |
Force abort at next iteration
Implements GIMLI::InversionBase< double >.
|
inline |
Return last absolute RMS misfit
void GIMLI::RInversion::checkConstraints | ( | ) |
Create constraints, check and compare size of constraint matrix with model/boundary control
Referenced by run().
|
inline |
Validate the data error. This check will be called at every new run or change of the error; Check size and content unequal to zero. If problems found, warn and set the data error to errorDefault_()
References errorDefault_(), and fixError_.
Referenced by robustWeighting(), run(), and setRelativeError().
void GIMLI::RInversion::checkJacobian | ( | bool | force = false | ) |
Check size of Jacobian matrix against data and model number
References GIMLI::Stopwatch::duration().
|
inline |
Check if transfunctions are valid, set default if no transfunctions are given or override given functions by regionManager.transfunctions if available
References setTransModel().
Referenced by run().
|
inlinevirtual |
Return last chi-squared data misfit
Implements GIMLI::InversionBase< double >.
References getPhiD().
Referenced by echoStatus(), and runChi1().
|
inline |
Apply blocky model constraints (see also setBlockyModel)
References GIMLI::getIRLSWeights(), and setCWeight().
Referenced by run().
|
inline |
Return number of constraints
Referenced by oneStep().
|
inlinevirtual |
Return reference to the current constraints weight vector
Implements GIMLI::InversionBase< double >.
Referenced by setCWeight().
|
inline |
Get data vector
Referenced by invert(), RInversion(), RInversion(), RInversion(), and setData().
|
inline |
Return number of data
|
inline |
Shortcut for echoStatus(response_, model_).
References echoStatus().
Referenced by echoStatus(), linesearch(), and oneStep().
|
inline |
Return the used data error
|
inline |
Return a copy of the default data error array, [ Relative data error of 1% ]
Referenced by checkError().
|
inline |
Return forward operator. Shortcut for forwardOperator()
References forwardOperator().
|
inlinevirtual |
|
inline |
|
inline |
Return the chi-squared data misfit for given forward response. DEPRECATED wrong nameing scheme
References getPhiD(), and response().
|
inline |
Return IRLS function of roughness vector
References GIMLI::getIRLSWeights().
|
inline |
Return total objective function (data OF plus lambda times model OF) DEPRECATED wrong nameing scheme
References getPhiD(), getPhiM(), model(), and response().
Referenced by echoStatus(), linesearch(), and linesearchQuad().
|
inline |
Shortcut for getPhiD(response_) necessary ? DEPRECATED wrong nameing scheme
References getPhiD().
Referenced by getPhiD(), optLambda(), and run().
double GIMLI::RInversion::getPhiD | ( | const Vec & | response | ) | const |
Return data objective function (sum of squared data-weighted misfit)
References response().
Referenced by chi2(), echoStatus(), getChi2(), getChi2(), getPhi(), getPhi(), and linesearch().
|
inline |
Shortcut for getPhiM(model_) necessary ? DEPRECATED wrong nameing scheme
References getPhiM().
Referenced by getPhiM(), optLambda(), and run().
double GIMLI::RInversion::getPhiM | ( | const Vec & | model | ) | const |
Return model objective function (squared model roughness)
References model(), and roughness().
Referenced by echoStatus(), getPhi(), and getPhi().
|
inlineprotected |
Internal initialization function, which is called from constructor. Set default paramater and allocate required memory
References fixError_.
Referenced by RInversion(), RInversion(), RInversion(), RInversion(), and RInversion().
Compute model update by solving one inverse sub-step
rhs | The right-hand-side vector of the system of equation |
!! h-variante
|
inlinevirtual |
Return true if inversion is running
Implements GIMLI::InversionBase< double >.
|
inlinevirtual |
Return curent iteration number
Implements GIMLI::InversionBase< double >.
Referenced by runChi1(), and setMaxCGLSIter().
|
inline |
Return the minimum lambda value that can be reached if lambda factor is set.
Start with linear interpolation, followed by quadratic fit if linesearch parameter tau is lower than 0.03. Tries to return values between 0.03 and 1
rigorous minimization of the total objective function
parabolic line search using step 0, 1 and tauquad to fit parabola
too large
negative or nearly zero (stucked) -> use small step instead
only if not nearly one (which saves a forward run
References echoStatus(), getPhi(), getPhiD(), and linesearchQuad().
Referenced by oneStep(), and setLineSearch().
|
inline |
Compute objective function for old (tau=0), new (tau=1) and another model
References getPhi().
Referenced by linesearch().
|
inline |
Return whether regularization is global or local (e.g. Marquardt method)
|
inlinevirtual |
Return a const reference to the current model vector
Implements GIMLI::InversionBase< double >.
Referenced by echoStatus(), getPhi(), getPhiM(), pureRoughness(), roughness(), runChi1(), setModel(), and setReferenceModel().
Compute cell resolution for closest cell to given position
References modelCellResolution().
|
inline |
Compute model cell resolution (specific column of resolution matrix) by an LSCG solver (Guenther, 2004)
Referenced by modelCellResolution(), and modelResolutionMatrix().
|
inline |
Return the single models for each iteration. For debugging.
References modelHist_.
|
inline |
Compute whole resolution matrix by single cell resolutions
References modelCellResolution(), and GIMLI::Matrix< ValueType >::push_back().
|
inline |
Return reference to the current model weight vector
bool GIMLI::RInversion::oneStep | ( | ) |
!! h-variante
One iteration step. Return true if the step can be calculated successfully else false is returned.
full step possible;
normal line search parameter between 0.03 and 0.94
** temporary stuff
References checkJacobian(), constraintsCount(), echoStatus(), linesearch(), optLambda(), roughness(), and roughness().
Referenced by run().
Optimization of regularization parameter by L-curve
References getPhiD(), getPhiM(), roughness(), and roughness().
Referenced by oneStep().
Return (C * m) , i.e. the pure (unweighted) roughness
References model().
|
inline |
Return last relative RMS misfit
|
inline |
Resets this inversion to the given startmodel.
References setModel().
|
inline |
Return a reference to the current response vector
Referenced by echoStatus(), getChi2(), getPhi(), getPhiD(), and setResponse().
|
inline |
Call robust date reweighting (see also setRobustData)
References checkError(), and GIMLI::getIRLSWeights().
Referenced by run().
|
inline |
Shortcut for roughness for the current model vector
References roughness().
Referenced by getPhiM(), oneStep(), and optLambda().
Return (C * m * m_w) * c_w
References model().
Referenced by oneStep(), optLambda(), and roughness().
|
virtual |
Start the inversion procedure from the last model and return the final model vector.
Run inversion with current model.
calculation of initial modelresponse
() clear the model history
validate and rebuild the data error if necessary
validate and rebuild the constraint matrix if necessary
compute roughness constraint and correct it for inter-region constraints
validate and rebuild the jacobian if necessary
Implements GIMLI::InversionBase< double >.
References checkConstraints(), checkError(), checkJacobian(), checkTransFunctions(), constrainBlocky(), getPhi(), getPhiD(), getPhiM(), modelHist_, oneStep(), robustWeighting(), and setModel().
|
inline |
Specialized run function that tries to reach a datafit chi^2=1 by varying the regularization paramater lambda
References chi2(), getChi2(), iter(), model(), run(), setLambda(), and stopAtChi1().
|
inline |
Set and get verbose behaviour
|
inline |
Set the absolute data error to the vector abserr
References setRelativeError().
|
inline |
Set absolute data error to the scalar value abserr
References setRelativeError().
|
inline |
Set and get blocky model behaviour (by L1 reweighting of constraints)
|
inline |
Enable/disable broyden update (which enforces scaling by transform function derivatives
|
inline |
Set and get abort tolerance for cgls solver. -1 means default scaling [default]
|
inline |
Set constraint right-hand side by hand (very special cases, so be careful)
|
inline |
Set the constraint weight (boundary control) vector
References cWeight().
Referenced by constrainBlocky().
|
inlinevirtual |
Set data vector
Implements GIMLI::InversionBase< double >.
References data().
Referenced by invert(), RInversion(), RInversion(), and RInversion().
|
inline |
Set and get relative objective function decrease
|
inline |
Set debug output
|
inlinevirtual |
Implements GIMLI::InversionBase< double >.
|
inlinevirtual |
Set the forward operator and the model-transform-function derived from fop-regionManager if not set before.
why is this so strictly necessary???
Always use a region manager
Implements GIMLI::InversionBase< double >.
Referenced by RInversion(), RInversion(), RInversion(), and RInversion().
|
inlinevirtual |
Set and get regularization parameter and its change over iteration
Implements GIMLI::InversionBase< double >.
Referenced by runChi1().
|
inline |
Set the minimum lambda value that can be reached if lambda factor is set. Default is 1.
|
inline |
Set and get line search
References linesearch().
|
inline |
Set whether regularization is global or local (e.g. Marquardt method)
Referenced by setMarquardtScheme().
|
inline |
Marquardt scheme (local damping with decreasing regularization strength
no contribution of regularization to objective function
lambda is decreased towards zero
let the solution fully converge (important for statistics)
References setLocalRegularization(), and stopAtChi1().
|
inline |
Set and get maximum iteration number for inverse sub step
References iter().
|
inlinevirtual |
Set and get maximum iteration number
Implements GIMLI::InversionBase< double >.
|
inlinevirtual |
Set model vector . If you call run() the inversion starts with this model, otherwise it will start with fop.startModel().
Implements GIMLI::InversionBase< double >.
References model().
|
inline |
Set the model weight vector
|
inline |
Set and get whether lambda is being optimized by Lcurve
|
inline |
Define and find out whether Jacobian is recalculated in each iteration
|
inlinevirtual |
|
inline |
Set the relative data error to the vector err.
References checkError().
Referenced by setAbsoluteError(), setAbsoluteError(), and setRelativeError().
|
inline |
Set relative data error to scalar error value relerr. If you force relerr == 0 here. Data will not corrected or weighted.
References fixError_, and setRelativeError().
|
inline |
Set current model response (e.g. to avoid time-consuming forward calculation, but be careful)
References response().
|
inline |
Set and get robust data weighting by L1 reweighting scheme
Set and get data transform. WARNING! we just store a reference to the trans .. U have to ensure that the trans is and stayes valid. TODO change this!!!
Implements GIMLI::InversionBase< double >.
Referenced by RInversion(), and RInversion().
Set and get Model transform WARNING! we just store a reference to the trans .. U have to ensure that the trans is and stayes valid. TODO change this!!!
Implements GIMLI::InversionBase< double >.
Referenced by checkTransFunctions(), and RInversion().
|
inline |
Set verbose output
const RVector & GIMLI::RInversion::start | ( | ) |
|
inline |
Define whether minimization stops at chi^2=1
References stopAtChi1().
Referenced by runChi1(), setMarquardtScheme(), and stopAtChi1().
|
protected |
Set this to zero if u want to use absolute errors == zero
Referenced by checkError(), init_(), and setRelativeError().
|
protected |
Hold old models, for debuging
Referenced by modelHistory(), and run().