Back-Propagation Algorithm for Electromagnetic Inverse Scattering.
This module implements the Back-Propagation algorithm for solving two-dimensional
electromagnetic inverse scattering problems. The algorithm uses scattered field
measurements to reconstruct the contrast function of the scattering object.
The Back-Propagation method is a non-iterative technique that provides a fast
approximation to the inverse scattering problem by computing the contrast
directly from the scattered field measurements using Green’s function relationships.
Back-Propagation Algorithm for Electromagnetic Inverse Scattering.
This class implements the Back-Propagation algorithm, a non-iterative method
for solving electromagnetic inverse scattering problems. The algorithm
reconstructs the contrast function directly from scattered field measurements
using Green’s function relationships.
The method provides a fast approximation to the inverse problem by computing
the contrast in a single step, making it suitable for real-time applications
or as an initial guess for iterative methods.
Parameters:
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver object used to compute incident fields and Green’s functions.
alias (str, default: 'backprop') – Alias name for the algorithm instance.
Solve the inverse scattering problem using Back-Propagation.
This method implements the Back-Propagation algorithm to reconstruct
the contrast function from scattered field measurements. The algorithm
computes the solution in a single step using Green’s function relationships.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements and
configuration parameters.
discretization (Discretization) – Discretization object containing domain information and Green’s
function matrix.
Compute contrast function from total field and current density.
Computes the contrast function (relative permittivity or conductivity
contrast) using the relationship between total field and current density
in the scattering domain.
Parameters:
E (numpy.ndarray) – Total field matrix with shape (ND, NS) where ND is the number
of domain points and NS is the number of sources.
J (numpy.ndarray) – Current density matrix with shape (ND, NS).
Compute current density from scattered field measurements.
Computes the current density in the scattering domain using the
Back-Propagation algorithm. The current density is estimated using
the adjoint of the Green’s function matrix scaled by the gamma parameter.
Parameters:
Es (numpy.ndarray) – Scattered field measurements matrix. Shape (NM, NS) where NM is
the number of measurement points and NS is the number of sources.
GS (numpy.ndarray) – Green’s function matrix from sources to measurement points.
Shape (NM, ND) where ND is the number of domain points.
gamma (numpy.ndarray) – Gamma scaling parameter array with shape (NS,).
Born Iterative Method for Electromagnetic Inverse Scattering.
This module implements the Born Iterative Method (BIM) for solving nonlinear
electromagnetic inverse scattering problems. The BIM is a classical iterative
approach that couples forward and inverse solvers to reconstruct the material
properties of scattering objects.
The method works by iteratively improving the solution using the Born
approximation, where each iteration involves solving a linearized inverse
problem and updating the total field using a forward solver.
The implementation follows the Deterministic solver abstract class and provides
a complete framework for nonlinear inverse scattering reconstruction.
Born Iterative Method for Nonlinear Electromagnetic Inverse Scattering.
This class implements the Born Iterative Method (BIM), a classical iterative
approach for solving nonlinear electromagnetic inverse scattering problems.
The method couples forward and inverse solvers in an iterative process to
reconstruct material properties from scattered field measurements.
The algorithm works by:
1. Starting with the incident field as initial guess
2. Solving the linearized inverse problem using the current total field
3. Updating the total field using the forward solver
4. Repeating until convergence criteria are met
Parameters:
forward_solver (ForwardSolver) – Forward solver implementation for computing total electric field.
regularization (Regularization) – Regularization method for the linear inverse problem.
stop_criteria (StopCriteria) – Convergence criteria for the iterative process.
alias (str, default: 'bim') – Alias name for the method instance.
Creates a new BIM instance with the specified forward solver,
regularization method, and convergence criteria.
Parameters:
forward_solver (ForwardSolver) – Forward solver implementation for computing the total electric field
in the scattering domain. Must implement the ForwardSolver interface.
regularization (Regularization) – Regularization method for solving the linearized inverse problem.
Used to handle ill-conditioning in the linear system.
stop_criteria (StopCriteria) – Convergence criteria object that determines when to stop the
iterative process. Typically based on relative change in solution
or maximum number of iterations.
alias (str, default: 'bim') – Alias name for this method instance, used for identification
and file naming.
import_filename (str, optional) – Filename to import previously saved method state. If provided,
other parameters are ignored and state is loaded from file.
import_filepath (str, default: '') – Path to the file containing saved method state.
Notes
The method uses the standard Born iterative approach where:
The incident field serves as the initial guess for total field
At each iteration, the linear inverse problem is solved using
the current total field estimate
The forward solver computes the new total field
The process continues until convergence criteria are met
where \(\\chi\) is the contrast, \(E_s\) is the scattered field,
\(E_t^{(n)}\) is the total field at iteration n, and \(\\mathcal{L}^{-1}\)
is the linearized inverse operator.
Loads a previously saved BIM configuration from file, restoring
all method parameters and settings.
Parameters:
file_name (str) – Name of the file containing saved method state.
file_path (str, default: '') – Path to the file containing saved method state.
Notes
This method restores the complete BIM configuration including:
- Forward solver with all its parameters
- Regularization method configuration
- Stop criteria settings
- Base class attributes
The loaded configuration can be used to recreate the exact same
method instance as was saved.
Saves the complete method configuration including forward solver,
regularization method, and stop criteria to a file for later retrieval.
Parameters:
file_path (str, default: '') – Path where to save the method state file. The file will be
saved with the method’s alias as the filename.
Notes
The method saves all necessary information to recreate the BIM
instance, including:
- Forward solver configuration
- Regularization method parameters
- Stop criteria settings
- Base class attributes (alias, etc.)
The file is saved using pickle serialization format.
Solve the nonlinear inverse scattering problem using BIM.
Implements the Born Iterative Method to reconstruct material properties
from scattered field measurements. The method iteratively refines the
solution by coupling forward and inverse solvers.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements,
configuration parameters, and other problem-specific information.
discretization (Discretization) – Discretization object containing domain information, Green’s
function matrices, and methods for field computation.
print_info (bool, default: True) – Whether to print iteration progress information to output.
print_file (file-like object, default: sys.stdout) – File object to write progress information to.
Returns:
result – Result object containing the reconstructed material properties,
fields, error metrics, and algorithm performance information.
Update material properties and create auxiliary InputData
Solve forward problem to get new total field:
\(E_t^{(k)} = E_i + G_D \chi^{(k)} E_t^{(k)}\)
Compute objective function and check convergence
Termination: Stop when convergence criteria are satisfied
The method handles both dielectric and conducting materials, automatically
converting between contrast and physical parameters (permittivity,
conductivity) as needed.
Convergence Criteria: The algorithm stops when the stop criteria
object determines convergence based on iteration count, objective
function value, or relative change in solution.
Error Tracking: The method computes and tracks various error metrics
including relative permittivity error, objective function value, and
field reconstruction errors.
First-Order Born Approximation for Electromagnetic Inverse Scattering.
This module implements the First-Order Born Approximation (FOBA) method for
solving electromagnetic inverse scattering problems. The Born approximation
is a linearization technique that assumes the total field inside the scattering
object is approximately equal to the incident field.
This is a non-iterative method that provides a fast solution to the inverse
scattering problem by solving a single linear system. While it’s limited to
weak scatterers, it serves as an excellent starting point for more complex
iterative methods and provides good results for low-contrast objects.
The method solves the linearized scattering equation:
E_s = G_S * chi * E_i
where E_s is the scattered field, G_S is the scattering Green’s function,
chi is the contrast function, and E_i is the incident field.
First-Order Born Approximation for Electromagnetic Inverse Scattering.
This class implements the First-Order Born Approximation (FOBA), a
linearization technique for solving electromagnetic inverse scattering
problems. The method assumes that the total field inside the scattering
object is approximately equal to the incident field, making it suitable
for weak scatterers.
The Born approximation converts the nonlinear inverse scattering problem
into a linear one by replacing the unknown total field with the known
incident field in the scattering integral equation. This results in a
single linear system that can be solved directly.
Mathematical Formulation:
The method solves the linearized equation:
E_s = G_S * chi * E_i
where:
- E_s: scattered field (measured data)
- G_S: scattering Green’s function matrix
- chi: contrast function (unknown to be reconstructed)
- E_i: incident field (known)
Parameters:
regularization (Regularization) – Regularization method for solving the linear inverse problem.
Required to handle the ill-conditioned nature of the inverse problem.
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver for computing incident fields and Green’s functions.
alias (str, default: 'ba') – Alias name for the method instance.
Validity Range: The Born approximation is valid when:
- The contrast is small (|\chi| << 1)
- The scatterer is electrically small
- The refractive index variation is gradual
Advantages:
- Fast computation (single linear solve)
- No iteration required
- Good initial guess for iterative methods
- Stable and well-understood
Limitations:
- Limited to weak scatterers
- Poor performance for high-contrast objects
- No nonlinear coupling effects
Initialize the First-Order Born Approximation method.
Creates a new FOBA instance with the specified regularization method
and forward solver configuration.
Parameters:
regularization (Regularization) – Regularization method for solving the ill-conditioned linear
inverse problem. Common choices include Tikhonov regularization,
truncated SVD, or iterative methods like CGLS.
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver implementation for computing incident fields and
Green’s function matrices. Must implement the ForwardSolver interface.
alias (str, default: 'ba') – Short alias name for this method instance, used for identification
and file naming purposes.
import_filename (str, optional) – Filename to import previously saved method state. If provided,
other parameters are ignored and the state is loaded from file.
import_filepath (str, default: '') – Path to the file containing saved method state.
Notes
The regularization parameter is crucial for the Born approximation
because the inverse scattering problem is inherently ill-conditioned.
The choice of regularization method and its parameters significantly
affects the reconstruction quality.
The forward solver is used to compute the incident field, which serves
as the approximation for the total field in the Born approximation.
Different forward solvers may be used depending on the problem geometry
and computational requirements.
Return string representation of the First-Order Born Approximation.
Creates a comprehensive string description of the FOBA instance
including all its components and configuration.
Returns:
String representation including:
- Base class information (name, alias, etc.)
- Regularization method details
- Forward solver configuration
Return type:
str
Notes
This method provides a complete overview of the FOBA configuration,
which is useful for debugging, logging, and understanding the
method setup. The string includes detailed information about
the regularization method and forward solver parameters.
Examples
>>> print(born)First-Order Born Approximation (ba)Regularization: Tikhonov (λ=1e-3)Forward Solver: MoM-CG-FFT...
The copy includes all method components:
- Regularization method (reference copy)
- Forward solver (reference copy)
- Base class attributes (alias, etc.)
This method is useful for creating multiple instances with the same
configuration, parameter studies, or backup purposes before
modifying parameters.
Examples
>>> # Create a copy>>> born_copy=born.copy()>>>>>> # Copy to existing instance>>> new_born=FirstOrderBornApproximation(some_regularization)>>> born.copy(new_born)# copies configuration to new_born
Import First-Order Born Approximation method state from file.
Loads a previously saved FOBA configuration from file, restoring
all method parameters and settings.
Parameters:
file_name (str) – Name of the file containing saved method state.
file_path (str, default: '') – Path to the file containing saved method state.
Notes
This method restores the complete FOBA configuration including:
- Regularization method with all its parameters
- Forward solver configuration and settings
- Base class attributes and state
The loaded configuration can be used to recreate the exact same
method instance as was saved, ensuring reproducibility of results.
Examples
>>> # Import from current directory>>> born=FirstOrderBornApproximation(None)# dummy init>>> born.importdata('ba')# load from file>>>>>> # Import from specific path>>> born.importdata('my_method','/path/to/files/')
Save the First-Order Born Approximation method state to file.
Saves the complete method configuration including regularization
method and forward solver settings to a file for later retrieval.
Parameters:
file_path (str, default: '') – Path where to save the method state file. The file will be
saved with the method’s alias as the filename.
Notes
The method saves all necessary information to recreate the FOBA
instance, including:
- Regularization method and its parameters
- Forward solver configuration
- Base class attributes (alias, etc.)
The file is saved using pickle serialization format, which preserves
the complete object state including any custom parameters or
configurations.
Examples
>>> # Save method to current directory>>> born.save()>>>>>> # Save to specific path>>> born.save('/path/to/save/')
Solve the inverse scattering problem using First-Order Born Approximation.
Implements the Born approximation to reconstruct material properties
from scattered field measurements. The method solves a single linearized
system by approximating the total field with the incident field.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements,
configuration parameters, and problem setup information.
discretization (Discretization) – Discretization object containing domain information, Green’s
function matrices, and numerical methods for field computation.
print_info (bool, default: True) – Whether to print algorithm progress and results information.
print_file (file-like object, default: sys.stdout) – File object to write progress information to.
Returns:
result – Result object containing the reconstructed material properties,
fields, error metrics, and algorithm performance information.
Incident Field Computation: Calculate the incident field E_i
in the discretization domain using the forward solver.
Linear System Solution: Solve the linearized equation:
\[\chi = \mathcal{R}[G_S^H E_s]\]
where \(\mathcal{R}\) is the regularization operator,
\(G_S^H\) is the adjoint scattering Green’s function,
and \(E_s\) is the scattered field.
Field Reconstruction: Compute the reconstructed scattered field
using the estimated contrast:
\[E_s^{rec} = G_S \chi E_i\]
Parameter Conversion: Convert the contrast function to physical
parameters (relative permittivity, conductivity) based on the
problem configuration.
Error Computation: Calculate various error metrics and
performance indicators.
Computational Complexity: O(N²) where N is the number of
discretization points, dominated by the linear system solution.
Memory Requirements: Depends on the regularization method and
Green’s function matrix storage.
The method automatically handles both dielectric and conducting
materials, converting between contrast and physical parameters
as needed based on the problem configuration.
Conjugated Gradient Method for Electromagnetic Inverse Scattering
This module implements the Conjugated Gradient Method (CGM) for solving
nonlinear electromagnetic inverse scattering problems. The method is based
on gradient-based optimization techniques and uses the conjugate gradient
algorithm to iteratively reconstruct the electromagnetic properties of
scatterers from scattered field measurements.
The implementation includes various initialization strategies, step size
optimization methods, and stopping criteria for robust convergence.
Conjugated Gradient Method for nonlinear inverse scattering.
This class implements the Conjugated Gradient Method (CGM) for solving
nonlinear electromagnetic inverse scattering problems. The method uses
gradient-based optimization with conjugate gradient updates to iteratively
reconstruct the electromagnetic properties of unknown scatterers from
scattered field measurements.
The algorithm minimizes the following objective function:
where \(\\chi\) is the contrast function, \(\mathbf{E}^s\) is the
scattered field, \(\mathbf{G}^s\) is the Green’s function matrix,
and \(\mathbf{L}^{-1}\) is the inverse of the Lippmann-Schwinger
operator.
Parameters:
initial_guess (str) – Strategy for initial guess:
- ‘background’: Start with background medium
- ‘backpropagation’: Use backpropagation algorithm
- ‘image’: Use direct image reconstruction
- ‘qualitative’: Use qualitative method (OSM)
step (str) – Step size computation method:
- ‘fixed’: Fixed step size based on gradient
- ‘optimum’: Optimal step size via line search
The conjugate gradient method is particularly effective for problems where
the gradient computation is efficient. The method uses the Polak-Ribière
formula for computing conjugate directions:
Creates a new instance of the CGM with specified initialization
strategy, step size method, and stopping criteria.
Parameters:
initial_guess (str) – Strategy for initial guess:
- ‘background’: Start with background medium (zero contrast)
- ‘backpropagation’: Use backpropagation algorithm for initialization
- ‘image’: Use direct image reconstruction as initial guess
- ‘qualitative’: Use qualitative method (OSM) for initialization
step (str) – Step size computation method:
- ‘fixed’: Fixed step size based on gradient and residual
- ‘optimum’: Optimal step size via line search optimization
stop_criteria (object) – Stopping criteria object that defines convergence conditions
(e.g., maximum iterations, error tolerance)
alias (str, default='cgm') – Alias name for the method used in saving/loading
import_filename (str, optional) – If provided, import method parameters from this file
import_filepath (str, default='') – Path to the import file
Examples
>>> # Create CGM with background initial guess and optimal step>>> cgm=ConjugatedGradientMethod(initial_guess='background',... step='optimum',... stop_criteria=my_criteria)
>>> # Create CGM with qualitative initial guess and fixed step>>> cgm=ConjugatedGradientMethod(initial_guess='qualitative',... step='fixed',... stop_criteria=my_criteria)
>>> # Import from saved configuration>>> cgm=ConjugatedGradientMethod(initial_guess='background',... step='optimum',... stop_criteria=my_criteria,... import_filename='cgm_config.pkl')
Solve the nonlinear inverse scattering problem using CGM.
Applies the conjugated gradient method to iteratively reconstruct
the electromagnetic properties of unknown scatterers from scattered
field measurements. The method minimizes the data misfit using
gradient-based optimization with conjugate gradient updates.
Parameters:
inputdata (inputdata.InputData) – Input data object containing:
- scattered_field: Measured scattered electric field
- configuration: Problem configuration (frequency, geometry, etc.)
- resolution: Target resolution for reconstruction
- indicators: List of performance indicators to compute
discretization (object) – Discretization object containing:
- elements: Grid dimensions (NY, NX)
- GS: Green’s function matrix for scattered field
- GD: Green’s function matrix for domain interaction
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – File object for printing iteration information
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- total_error: Final data misfit error
- data_error: Data error evolution
- execution_time: Total execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
Contrast Source Inversion Method for Electromagnetic Inverse Scattering
This module implements the Contrast Source Inversion (CSI) method for solving
nonlinear electromagnetic inverse scattering problems. The CSI method is an
iterative algorithm that simultaneously reconstructs both the contrast function
and the contrast sources (induced currents) in the investigation domain.
The method is based on minimizing a cost functional that includes both data
error (difference between measured and computed scattered fields) and object
error (consistency between contrast and current distributions). The algorithm
uses conjugate gradient optimization to efficiently solve the nonlinear
inverse problem.
where \(F_S\) is the data error term, \(F_D\) is the object error term,
\(\mathbf{J}\) is the contrast source, \(\\chi\) is the contrast function,
and \(\mathbf{E}\) is the total electric field.
The method uses conjugate gradient optimization with Polak-Ribière updates
for efficient convergence to the solution.
Contrast Source Inversion method for nonlinear electromagnetic inverse scattering.
This class implements the Contrast Source Inversion (CSI) method, which
simultaneously reconstructs both the contrast function and the contrast
sources (induced currents) in electromagnetic inverse scattering problems.
The method uses an iterative conjugate gradient optimization approach to
minimize a cost functional with both data and object error terms.
The CSI method solves the nonlinear inverse problem by minimizing:
where:
- (F_S) is the data error term (scattered field misfit)
- (F_D) is the object error term (current-contrast consistency)
- (mathbf{J}) is the contrast source (induced current)
- (chi) is the contrast function
- (mathbf{E}) is the total electric field
- (mathbf{E}^s) is the scattered field
- (mathbf{E}^i) is the incident field
- (mathbf{G}^s) is the scattered field Green’s function
Creates a new CSI instance with specified stopping criteria and
forward solver for electromagnetic field computation.
Parameters:
stop_criteria (object) – Stopping criteria object that defines convergence conditions
such as maximum iterations, error tolerance, or divergence limits
forward_solver (object, default=mom.MoM_CG_FFT()) – Forward solver implementation for computing electromagnetic fields.
Must implement the incident_field() method and support the
required discretization formats
alias (str, default='csi') – Alias name for the method used in file operations and identification
import_filename (str, optional) – If provided, import method parameters from this file instead
of using the provided parameters
import_filepath (str, default='') – Path to the import file
Examples
>>> # Create CSI with default forward solver>>> csi=ContrastSourceInversion(stop_criteria=my_criteria)
>>> # Create CSI with custom forward solver>>> csi=ContrastSourceInversion(stop_criteria=my_criteria,... forward_solver=my_forward_solver)
>>> # Import from saved configuration>>> csi=ContrastSourceInversion(stop_criteria=my_criteria,... import_filename='csi_config.pkl')
Solve the nonlinear inverse scattering problem using CSI.
Applies the Contrast Source Inversion method to reconstruct the
electromagnetic properties of unknown scatterers. The method
simultaneously updates both the contrast function and contrast
sources using conjugate gradient optimization.
Parameters:
inputdata (inputdata.InputData) – Input data object containing:
- scattered_field: Measured scattered electric field
- configuration: Problem configuration (frequency, geometry, etc.)
- resolution: Target resolution for reconstruction
- indicators: List of performance indicators to compute
discretization (object) – Discretization object containing:
- elements: Grid dimensions (NY, NX)
- GS: Green’s function matrix for scattered field
- contrast_image: Method for contrast imaging
- total_image: Method for total field imaging
- solve: Method for solving linear systems
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – File object for printing iteration information
initial_guess (numpy.ndarray, optional) – Initial guess for the contrast function. If None, uses
backpropagation method for initialization
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- scattered_field: Reconstructed scattered field
- total_field: Reconstructed total field
- total_error: Final objective function value
- data_error: Data error evolution
- execution_time: Total execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
Distorted Born Iterative Method for Electromagnetic Inverse Scattering.
This module implements the Distorted Born Iterative Method (DBIM) [1]_ for solving
two-dimensional electromagnetic inverse scattering problems. The DBIM is a nonlinear
iterative method that couples forward and inverse solvers to reconstruct the
electromagnetic properties of unknown scatterers from scattered field measurements.
The method is based on the Born approximation with distorted incident fields,
where the Green’s function is iteratively updated to account for the estimated
contrast function. This approach provides better convergence properties compared
to the standard Born Iterative Method, particularly for high-contrast scatterers.
Distorted Born Iterative Method for electromagnetic inverse scattering.
This class implements the Distorted Born Iterative Method (DBIM) [1]_, a
nonlinear iterative algorithm for solving electromagnetic inverse scattering
problems. The method couples forward and inverse solvers iteratively,
updating the Green’s function at each iteration to account for the
estimated contrast function.
The DBIM algorithm works by:
1. Starting with Born approximation (incident field as total field)
2. Solving linear inverse problem to get initial contrast estimate
3. Updating Green’s function using current contrast estimate
4. Solving forward problem with updated Green’s function
5. Computing residual scattered field
6. Solving linear inverse problem for contrast update
7. Repeating until convergence or maximum iterations
The method provides improved convergence compared to standard BIM,
particularly for high-contrast scatterers, by using distorted incident
fields that better approximate the true total field.
Parameters:
forward_solver (Forward) – Forward solver implementation for computing total electric field
and scattered field from given contrast distribution
regularization (Regularization) – Regularization method for solving the linear inverse problem
(e.g., Tikhonov regularization, truncated SVD)
stop_criteria (StopCriteria) – Stopping criteria object defining when to terminate iterations
(e.g., maximum iterations, relative error threshold)
alias (str, default='dbim') – Alias name for the algorithm instance
import_filename (str, optional) – Filename to import previously saved algorithm state
import_filepath (str, default='') – Path to directory containing import file
Initialize the Distorted Born Iterative Method solver.
Parameters:
forward_solver (Forward) – Forward solver implementation for computing electromagnetic fields.
Must implement methods for computing incident field and solving
the forward scattering problem.
regularization (Regularization) – Regularization method for solving the linear inverse problem.
Common choices include Tikhonov regularization, truncated SVD,
or other regularization schemes.
stop_criteria (StopCriteria) – Stopping criteria object that determines when to terminate
the iterative process. Can be based on maximum iterations,
relative error, objective function value, etc.
alias (str, default='dbim') – Alias name for the algorithm instance, used for identification
and file naming when saving/loading algorithm state.
import_filename (str, optional) – If provided, imports algorithm state from this file instead
of initializing with provided parameters.
import_filepath (str, default='') – Directory path where the import file is located.
Notes
If import_filename is provided, the algorithm state is loaded
from file and other parameters are ignored. Otherwise, a new
instance is created with the provided solver components.
Solve electromagnetic inverse scattering problem using DBIM.
This method implements the complete DBIM algorithm, iteratively
updating the contrast function and Green’s function until
convergence or maximum iterations are reached.
Algorithm Steps:
1. Initialize with Born approximation (incident field as total field)
2. Solve linear inverse problem for initial contrast estimate
3. Enter iterative loop:
Update Green’s function using current contrast
Solve forward problem with updated Green’s function
Compute residual scattered field
Solve linear inverse problem for contrast update
Check stopping criteria
Return final reconstruction results
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired output resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Discretization grid points
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix
- Methods for field interpolation and contrast imaging
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – Output stream for printing iteration information
initial_guess (array_like, optional) – Initial guess for contrast function. If None, uses Born
approximation with incident field as total field.
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- scattered_field: Final computed scattered field
- total_field: Final computed total field
- execution_time: Algorithm execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
- error_history: Convergence history
The algorithm automatically handles both good conductor and
perfect dielectric cases based on the configuration. For
good conductors, only conductivity is reconstructed. For
perfect dielectrics, only permittivity is reconstructed.
The Green’s function update is the key difference from standard
BIM, providing better convergence for high-contrast scatterers
by using distorted incident fields.
Examples
>>> # Solve with default settings>>> result=solver.solve(input_data,discretization)>>> print(f"Converged in {result.number_iterations} iterations")
>>> # Solve with initial guess and custom output>>> withopen('output.txt','w')asf:... result=solver.solve(input_data,discretization,... initial_guess=my_guess,... print_file=f)
eispy2d.solvers.inverse.dbim.faster_computation(X, I, GD, GS)#
Optimized computation for Green’s function update.
This JIT-compiled function performs the core matrix operations
required for updating the Green’s function in the DBIM algorithm.
The computation is optimized using Numba for maximum performance.
The function computes:
.. math:
G_S^{new}=[(I-G_D \chi)^{-1}G_S^T]^T
where the transposition is used to ensure proper matrix dimensions.
Parameters:
X (numpy.ndarray) – Diagonal matrix representation of the contrast function,
created from the flattened contrast array
I (numpy.ndarray) – Identity matrix of size matching the contrast function
GD (numpy.ndarray) – Domain Green’s function matrix
GS (numpy.ndarray) – Scattered field Green’s function matrix
Returns:
Updated scattered field Green’s function matrix
Return type:
numpy.ndarray
Notes
This function is JIT-compiled with Numba for high performance.
The matrix inversion is performed using standard linear algebra
operations. For large problems, this operation can be computationally
intensive and may benefit from specialized solvers.
The function assumes that the matrix (I - GD@X) is invertible.
In practice, this is generally true for physical scattering problems,
but numerical issues may arise for very high contrast values.
Update Green’s function matrix using current contrast estimate.
This function updates the scattered field Green’s function matrix
to account for the current contrast function estimate. This is the
key step that distinguishes DBIM from standard Born methods.
The update is performed using the formula:
\[G_S^{new} = (I - G_D \chi)^{-1} G_S\]
where (G_S) is the scattered field Green’s function,
(G_D) is the domain Green’s function, (chi) is the
contrast function, and (I) is the identity matrix.
:type contrast: numpy.ndarray
:param contrast: Current contrast function estimate as a 2D array representing
the spatial distribution of contrast values
Parameters:
greenf_d (numpy.ndarray) – Domain Green’s function matrix relating contrast sources to
total field within the investigation domain
greenf_s (numpy.ndarray) – Current scattered field Green’s function matrix
Returns:
Updated scattered field Green’s function matrix that incorporates
the current contrast estimate
Return type:
numpy.ndarray
Notes
This function creates a diagonal matrix from the contrast function
and uses the optimized JIT-compiled faster_computation function
to perform the matrix inversion and multiplication efficiently.
The updated Green’s function provides a better approximation to the
true scattering behavior, leading to improved convergence compared
to methods that use fixed Green’s functions.
This module implements the Extended Contrast Source Inversion (ECSI) method
for solving electromagnetic inverse scattering problems. ECSI is an advanced
iterative nonlinear solver that extends the classical Contrast Source Inversion
(CSI) approach by incorporating enhanced optimization techniques.
The method couples forward and inverse solvers in an iterative process,
alternately updating the contrast function and current density distribution
within the scattering domain. It employs conjugate gradient techniques for
efficient convergence and can handle both lossy and lossless media.
Compute the Polak-Ribière conjugate gradient parameter.
compute_constant_j
Calculate the step size for current density updates.
update_contrast
Update the contrast function using computed step size and direction.
get_gradient_x
Compute the gradient of the objective function with respect to contrast.
compute_constant_x
Calculate the step size for contrast updates.
Notes
The implementation uses Numba JIT compilation for performance-critical functions
and supports both perfect dielectric and good conductor approximations.
This class implements the Extended Contrast Source Inversion (ECSI) algorithm,
an advanced iterative nonlinear solver for electromagnetic inverse scattering
problems. ECSI extends the classical Contrast Source Inversion (CSI) approach
by incorporating enhanced optimization techniques and conjugate gradient methods.
The method alternately updates the contrast function (representing material
properties) and current density distribution within the scattering domain.
It employs a cost function minimization approach with conjugate gradient
optimization for efficient convergence.
where:
- \(\\chi\) is the contrast function
- \(\\mathbf{J}\) is the current density
- \(\\mathbf{E}^s\) is the scattered electric field
- \(\\mathbf{E}^{tot}\) is the total electric field
- \(\\mathbf{G}^s\) is the scattered field Green’s function
Initialize the Extended Contrast Source Inversion solver.
Creates an ECSI solver instance with specified stopping criteria and
forward solver. The solver can be initialized from scratch or loaded
from a previously saved state.
Parameters:
stop_criteria (stopcriteria.StopCriteria) – Object defining the stopping criteria for the iterative algorithm.
This includes maximum iterations, convergence thresholds, and
other termination conditions.
forward_solver (forward.Forward, optional) – Forward solver implementation for computing the total electric field.
Default is mom_cg_fft.MoM_CG_FFT.
alias (str, optional) – Short identifier for this solver instance. Used in result naming
and file operations. Default is ‘ecsi’.
import_filename (str, optional) – Name of file containing previously saved solver state. If provided,
the solver will be initialized from this saved state. Default is None.
import_filepath (str, optional) – Directory path containing the import file. Only used if import_filename
is provided. Default is empty string (current directory).
Raises:
FileNotFoundError – If import_filename is specified but the file cannot be found.
ValueError – If the loaded file contains invalid or corrupted solver state.
Creates a new solver instance with the same configuration or copies
configuration from another solver instance.
Parameters:
new (ExtendedContrastSourceInversion, optional) – Another solver instance to copy configuration from. If None,
creates a new instance with current configuration.
Solve the electromagnetic inverse scattering problem using ECSI.
Performs iterative reconstruction of the contrast function and current
density distribution using the Extended Contrast Source Inversion algorithm.
The method alternates between updating the current density (J) and the
contrast function (\chi) using conjugate gradient optimization.
Parameters:
inputdata (inputdata.InputData) – Object containing the measured scattered field data and problem
configuration including frequency, measurement points, and incident
field parameters.
discretization (discretization.Discretization) – Discretization scheme defining the computational grid, Green’s
functions, and spatial sampling of the investigation domain.
print_info (bool, optional) – Whether to print iteration progress information. Default is True.
print_file (file-like object, optional) – File object for printing output. Default is sys.stdout.
initial_guess (numpy.ndarray, optional) – Initial guess for the contrast function. If None, backpropagation
method is used to generate initial guess. Default is None.
Returns:
result – Object containing the reconstructed contrast function, relative
permittivity, conductivity, total field, and convergence information.
Return type:
result.Result
Raises:
ValueError – If input data or discretization are invalid.
RuntimeError – If the algorithm fails to converge within specified criteria.
Notes
The algorithm implements the following iterative procedure:
Initialization: Generate initial guess using backpropagation if not provided
Current Update: Minimize data and object error functionals with respect to J
Contrast Update: Minimize object error functional with respect to \chi
Convergence Check: Evaluate stopping criteria and continue if necessary
Compute optimal step size for current density update.
Calculates the optimal step size for updating the current density in the
ECSI algorithm by minimizing the cost function along the search direction.
Parameters:
gv (numpy.ndarray) – Product of gradient and conjugate direction for current density.
GSv (numpy.ndarray) – Green’s function applied to search direction.
eta_s (float) – Normalization factor for scattered field data.
v_XGDva (numpy.ndarray) – Auxiliary vector for object error computation.
eta_d (float) – Normalization factor for object error.
Returns:
Optimal step size for current density update.
Return type:
float
Notes
This function is JIT-compiled with Numba for performance. The step size
minimizes the quadratic approximation of the cost function along the
conjugate gradient direction.
eispy2d.solvers.inverse.ecsi.compute_constant_x(D, E, chi, J, Ei)#
Compute optimal step size for contrast update.
Calculates the optimal step size for updating the contrast function by
solving a quadratic optimization problem along the search direction.
Parameters:
D (numpy.ndarray) – Diagonal matrix representation of search direction.
E (numpy.ndarray) – Total electric field distribution.
chi (numpy.ndarray) – Current contrast function as diagonal matrix.
J (numpy.ndarray) – Current density distribution.
Ei (numpy.ndarray) – Incident electric field distribution.
Returns:
Optimal step size for contrast update.
Return type:
float
Notes
This function is JIT-compiled with Numba for performance. The step size
is computed by solving the quadratic equation:
This function is JIT-compiled with Numba for performance. The Polak-Ribière
method generally provides better convergence properties than the Fletcher-Reeves
method for nonlinear optimization problems.
eispy2d.solvers.inverse.ecsi.get_gradient_x(eta_d, J, E, X)#
Compute gradient of cost function with respect to contrast.
Calculates the gradient of the ECSI cost function with respect to the
contrast function using the current field and current density distributions.
Parameters:
eta_d (float) – Normalization factor for object error.
J (numpy.ndarray) – Current density distribution.
E (numpy.ndarray) – Electric field distribution.
X (numpy.ndarray) – Current contrast function values.
Returns:
Gradient vector with respect to contrast function.
Return type:
numpy.ndarray
Notes
This function is JIT-compiled with Numba for performance. The gradient
is computed using the relationship between current density and contrast:
\[\begin{split}\\nabla_X F = \\eta_d \\left( \\frac{\\mathbf{J} \\cdot \\mathbf{E}^*}{||\\mathbf{E}||^2} - X \\right)\end{split}\]
Evolutionary Algorithm for electromagnetic inverse scattering.
This class implements a general evolutionary algorithm framework for solving
electromagnetic inverse scattering problems. It supports various evolutionary
mechanisms including Differential Evolution, Particle Swarm Optimization,
and Genetic Algorithms.
Parameters:
population_size (int) – Size of the population.
initialization (Initialization) – Population initialization strategy.
objective_function (ObjectiveFunction) – Objective function to evaluate solution quality.
Linear Sampling Method for qualitative inverse scattering.
This class implements the Linear Sampling Method (LSM), a qualitative
technique for shape reconstruction of scatterers. The method identifies
the support of the scatterer without reconstructing material properties.
Parameters:
alias (str, default='') – Alias name for the algorithm.
regularization (Regularization, optional) – Regularization method for solving linear systems.
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
This module implements the Born Iterative Method [1]_ as a derivation of
Solver class. The object contains an object of a forward solver and
one of linear inverse solver. The method solves the nonlinear
inverse problem iteratively. The implemented in
BornIterativeMethod
This class implements a classical nonlinear inverse solver [1]_. The
method is based on coupling forward and inverse solvers in an
iterative process. Therefore, it depends on the definition of a
forward solver implementation and an linear inverse one.
Stop criterion for the algorithm. The algorithm will stop
when the amount of variation from the current iteration in
respect to the last one is below some threshold percentage:
Number of iterations in which it will be accepted a
divergence occurrence, i.e., the new solution has a larger
evaluation than the previous considering the stop criterion
measure.
configuration (configuration.Configuration) – It may be either an object of problem configuration or
a string to a pre-saved file or a 2-tuple with the file
name and path, respectively.
version (str) – A string naming the version of this method. It may be
useful when using different implementation of forward
and inverse solvers.
forward_solver (forward.Forward) – An implementation of the abstract class Forward which
defines a method for computing the total intern field.
inverse_solver (inverse.Inverse) – An implementation of the abstract class Inverse which
defines a method for solving the linear inverse problem.
maximum_iterations (int, default: 10) – Maximum number of iterations.
stopcriterion_measure (float, default: 1e-3) –
Define the measure for stop criterion. The algorithm
will stop when the amount of variation from the current
iteration in respect to the last one is below some
threshold percentage:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
Orthogonality Sampling Method for qualitative inverse scattering.
This class implements the Orthogonality Sampling Method (OSM), a qualitative
technique for shape reconstruction based on orthogonality properties of
the scattered field.
Parameters:
alias (str, default='osm') – Alias name for the algorithm.
threshold (float, optional) – Threshold for indicator function.
far_field (bool, optional) – Whether to use far-field approximation.
import_filename (str, optional) – Filename to import algorithm state from.
import_filepath (str, default='') – Path to import file.
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
This module implements the Born Iterative Method [1]_ as a derivation of
Solver class. The object contains an object of a forward solver and
one of linear inverse solver. The method solves the nonlinear
inverse problem iteratively. The implemented in
BornIterativeMethod
This class implements a classical nonlinear inverse solver [1]_. The
method is based on coupling forward and inverse solvers in an
iterative process. Therefore, it depends on the definition of a
forward solver implementation and an linear inverse one.
Stop criterion for the algorithm. The algorithm will stop
when the amount of variation from the current iteration in
respect to the last one is below some threshold percentage:
Number of iterations in which it will be accepted a
divergence occurrence, i.e., the new solution has a larger
evaluation than the previous considering the stop criterion
measure.
configuration (configuration.Configuration) – It may be either an object of problem configuration or
a string to a pre-saved file or a 2-tuple with the file
name and path, respectively.
version (str) – A string naming the version of this method. It may be
useful when using different implementation of forward
and inverse solvers.
forward_solver (forward.Forward) – An implementation of the abstract class Forward which
defines a method for computing the total intern field.
inverse_solver (inverse.Inverse) – An implementation of the abstract class Inverse which
defines a method for solving the linear inverse problem.
maximum_iterations (int, default: 10) – Maximum number of iterations.
stopcriterion_measure (float, default: 1e-3) –
Define the measure for stop criterion. The algorithm
will stop when the amount of variation from the current
iteration in respect to the last one is below some
threshold percentage:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Back-Propagation Algorithm for Electromagnetic Inverse Scattering.
This class implements the Back-Propagation algorithm, a non-iterative method
for solving electromagnetic inverse scattering problems. The algorithm
reconstructs the contrast function directly from scattered field measurements
using Green’s function relationships.
The method provides a fast approximation to the inverse problem by computing
the contrast in a single step, making it suitable for real-time applications
or as an initial guess for iterative methods.
Parameters:
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver object used to compute incident fields and Green’s functions.
alias (str, default: 'backprop') – Alias name for the algorithm instance.
Solve the inverse scattering problem using Back-Propagation.
This method implements the Back-Propagation algorithm to reconstruct
the contrast function from scattered field measurements. The algorithm
computes the solution in a single step using Green’s function relationships.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements and
configuration parameters.
discretization (Discretization) – Discretization object containing domain information and Green’s
function matrix.
Born Iterative Method for Nonlinear Electromagnetic Inverse Scattering.
This class implements the Born Iterative Method (BIM), a classical iterative
approach for solving nonlinear electromagnetic inverse scattering problems.
The method couples forward and inverse solvers in an iterative process to
reconstruct material properties from scattered field measurements.
The algorithm works by:
1. Starting with the incident field as initial guess
2. Solving the linearized inverse problem using the current total field
3. Updating the total field using the forward solver
4. Repeating until convergence criteria are met
Parameters:
forward_solver (ForwardSolver) – Forward solver implementation for computing total electric field.
regularization (Regularization) – Regularization method for the linear inverse problem.
stop_criteria (StopCriteria) – Convergence criteria for the iterative process.
alias (str, default: 'bim') – Alias name for the method instance.
Creates a new BIM instance with the specified forward solver,
regularization method, and convergence criteria.
Parameters:
forward_solver (ForwardSolver) – Forward solver implementation for computing the total electric field
in the scattering domain. Must implement the ForwardSolver interface.
regularization (Regularization) – Regularization method for solving the linearized inverse problem.
Used to handle ill-conditioning in the linear system.
stop_criteria (StopCriteria) – Convergence criteria object that determines when to stop the
iterative process. Typically based on relative change in solution
or maximum number of iterations.
alias (str, default: 'bim') – Alias name for this method instance, used for identification
and file naming.
import_filename (str, optional) – Filename to import previously saved method state. If provided,
other parameters are ignored and state is loaded from file.
import_filepath (str, default: '') – Path to the file containing saved method state.
Notes
The method uses the standard Born iterative approach where:
The incident field serves as the initial guess for total field
At each iteration, the linear inverse problem is solved using
the current total field estimate
The forward solver computes the new total field
The process continues until convergence criteria are met
where \(\\chi\) is the contrast, \(E_s\) is the scattered field,
\(E_t^{(n)}\) is the total field at iteration n, and \(\\mathcal{L}^{-1}\)
is the linearized inverse operator.
Loads a previously saved BIM configuration from file, restoring
all method parameters and settings.
Parameters:
file_name (str) – Name of the file containing saved method state.
file_path (str, default: '') – Path to the file containing saved method state.
Notes
This method restores the complete BIM configuration including:
- Forward solver with all its parameters
- Regularization method configuration
- Stop criteria settings
- Base class attributes
The loaded configuration can be used to recreate the exact same
method instance as was saved.
Saves the complete method configuration including forward solver,
regularization method, and stop criteria to a file for later retrieval.
Parameters:
file_path (str, default: '') – Path where to save the method state file. The file will be
saved with the method’s alias as the filename.
Notes
The method saves all necessary information to recreate the BIM
instance, including:
- Forward solver configuration
- Regularization method parameters
- Stop criteria settings
- Base class attributes (alias, etc.)
The file is saved using pickle serialization format.
Solve the nonlinear inverse scattering problem using BIM.
Implements the Born Iterative Method to reconstruct material properties
from scattered field measurements. The method iteratively refines the
solution by coupling forward and inverse solvers.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements,
configuration parameters, and other problem-specific information.
discretization (Discretization) – Discretization object containing domain information, Green’s
function matrices, and methods for field computation.
print_info (bool, default: True) – Whether to print iteration progress information to output.
print_file (file-like object, default: sys.stdout) – File object to write progress information to.
Returns:
result – Result object containing the reconstructed material properties,
fields, error metrics, and algorithm performance information.
Update material properties and create auxiliary InputData
Solve forward problem to get new total field:
\(E_t^{(k)} = E_i + G_D \chi^{(k)} E_t^{(k)}\)
Compute objective function and check convergence
Termination: Stop when convergence criteria are satisfied
The method handles both dielectric and conducting materials, automatically
converting between contrast and physical parameters (permittivity,
conductivity) as needed.
Convergence Criteria: The algorithm stops when the stop criteria
object determines convergence based on iteration count, objective
function value, or relative change in solution.
Error Tracking: The method computes and tracks various error metrics
including relative permittivity error, objective function value, and
field reconstruction errors.
Conjugated Gradient Method for nonlinear inverse scattering.
This class implements the Conjugated Gradient Method (CGM) for solving
nonlinear electromagnetic inverse scattering problems. The method uses
gradient-based optimization with conjugate gradient updates to iteratively
reconstruct the electromagnetic properties of unknown scatterers from
scattered field measurements.
The algorithm minimizes the following objective function:
where \(\\chi\) is the contrast function, \(\mathbf{E}^s\) is the
scattered field, \(\mathbf{G}^s\) is the Green’s function matrix,
and \(\mathbf{L}^{-1}\) is the inverse of the Lippmann-Schwinger
operator.
Parameters:
initial_guess (str) – Strategy for initial guess:
- ‘background’: Start with background medium
- ‘backpropagation’: Use backpropagation algorithm
- ‘image’: Use direct image reconstruction
- ‘qualitative’: Use qualitative method (OSM)
step (str) – Step size computation method:
- ‘fixed’: Fixed step size based on gradient
- ‘optimum’: Optimal step size via line search
The conjugate gradient method is particularly effective for problems where
the gradient computation is efficient. The method uses the Polak-Ribière
formula for computing conjugate directions:
Creates a new instance of the CGM with specified initialization
strategy, step size method, and stopping criteria.
Parameters:
initial_guess (str) – Strategy for initial guess:
- ‘background’: Start with background medium (zero contrast)
- ‘backpropagation’: Use backpropagation algorithm for initialization
- ‘image’: Use direct image reconstruction as initial guess
- ‘qualitative’: Use qualitative method (OSM) for initialization
step (str) – Step size computation method:
- ‘fixed’: Fixed step size based on gradient and residual
- ‘optimum’: Optimal step size via line search optimization
stop_criteria (object) – Stopping criteria object that defines convergence conditions
(e.g., maximum iterations, error tolerance)
alias (str, default='cgm') – Alias name for the method used in saving/loading
import_filename (str, optional) – If provided, import method parameters from this file
import_filepath (str, default='') – Path to the import file
Examples
>>> # Create CGM with background initial guess and optimal step>>> cgm=ConjugatedGradientMethod(initial_guess='background',... step='optimum',... stop_criteria=my_criteria)
>>> # Create CGM with qualitative initial guess and fixed step>>> cgm=ConjugatedGradientMethod(initial_guess='qualitative',... step='fixed',... stop_criteria=my_criteria)
>>> # Import from saved configuration>>> cgm=ConjugatedGradientMethod(initial_guess='background',... step='optimum',... stop_criteria=my_criteria,... import_filename='cgm_config.pkl')
Solve the nonlinear inverse scattering problem using CGM.
Applies the conjugated gradient method to iteratively reconstruct
the electromagnetic properties of unknown scatterers from scattered
field measurements. The method minimizes the data misfit using
gradient-based optimization with conjugate gradient updates.
Parameters:
inputdata (inputdata.InputData) – Input data object containing:
- scattered_field: Measured scattered electric field
- configuration: Problem configuration (frequency, geometry, etc.)
- resolution: Target resolution for reconstruction
- indicators: List of performance indicators to compute
discretization (object) – Discretization object containing:
- elements: Grid dimensions (NY, NX)
- GS: Green’s function matrix for scattered field
- GD: Green’s function matrix for domain interaction
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – File object for printing iteration information
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- total_error: Final data misfit error
- data_error: Data error evolution
- execution_time: Total execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
Contrast Source Inversion method for nonlinear electromagnetic inverse scattering.
This class implements the Contrast Source Inversion (CSI) method, which
simultaneously reconstructs both the contrast function and the contrast
sources (induced currents) in electromagnetic inverse scattering problems.
The method uses an iterative conjugate gradient optimization approach to
minimize a cost functional with both data and object error terms.
The CSI method solves the nonlinear inverse problem by minimizing:
where:
- (F_S) is the data error term (scattered field misfit)
- (F_D) is the object error term (current-contrast consistency)
- (mathbf{J}) is the contrast source (induced current)
- (chi) is the contrast function
- (mathbf{E}) is the total electric field
- (mathbf{E}^s) is the scattered field
- (mathbf{E}^i) is the incident field
- (mathbf{G}^s) is the scattered field Green’s function
Creates a new CSI instance with specified stopping criteria and
forward solver for electromagnetic field computation.
Parameters:
stop_criteria (object) – Stopping criteria object that defines convergence conditions
such as maximum iterations, error tolerance, or divergence limits
forward_solver (object, default=mom.MoM_CG_FFT()) – Forward solver implementation for computing electromagnetic fields.
Must implement the incident_field() method and support the
required discretization formats
alias (str, default='csi') – Alias name for the method used in file operations and identification
import_filename (str, optional) – If provided, import method parameters from this file instead
of using the provided parameters
import_filepath (str, default='') – Path to the import file
Examples
>>> # Create CSI with default forward solver>>> csi=ContrastSourceInversion(stop_criteria=my_criteria)
>>> # Create CSI with custom forward solver>>> csi=ContrastSourceInversion(stop_criteria=my_criteria,... forward_solver=my_forward_solver)
>>> # Import from saved configuration>>> csi=ContrastSourceInversion(stop_criteria=my_criteria,... import_filename='csi_config.pkl')
Solve the nonlinear inverse scattering problem using CSI.
Applies the Contrast Source Inversion method to reconstruct the
electromagnetic properties of unknown scatterers. The method
simultaneously updates both the contrast function and contrast
sources using conjugate gradient optimization.
Parameters:
inputdata (inputdata.InputData) – Input data object containing:
- scattered_field: Measured scattered electric field
- configuration: Problem configuration (frequency, geometry, etc.)
- resolution: Target resolution for reconstruction
- indicators: List of performance indicators to compute
discretization (object) – Discretization object containing:
- elements: Grid dimensions (NY, NX)
- GS: Green’s function matrix for scattered field
- contrast_image: Method for contrast imaging
- total_image: Method for total field imaging
- solve: Method for solving linear systems
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – File object for printing iteration information
initial_guess (numpy.ndarray, optional) – Initial guess for the contrast function. If None, uses
backpropagation method for initialization
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- scattered_field: Reconstructed scattered field
- total_field: Reconstructed total field
- total_error: Final objective function value
- data_error: Data error evolution
- execution_time: Total execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
Distorted Born Iterative Method for electromagnetic inverse scattering.
This class implements the Distorted Born Iterative Method (DBIM) [1]_, a
nonlinear iterative algorithm for solving electromagnetic inverse scattering
problems. The method couples forward and inverse solvers iteratively,
updating the Green’s function at each iteration to account for the
estimated contrast function.
The DBIM algorithm works by:
1. Starting with Born approximation (incident field as total field)
2. Solving linear inverse problem to get initial contrast estimate
3. Updating Green’s function using current contrast estimate
4. Solving forward problem with updated Green’s function
5. Computing residual scattered field
6. Solving linear inverse problem for contrast update
7. Repeating until convergence or maximum iterations
The method provides improved convergence compared to standard BIM,
particularly for high-contrast scatterers, by using distorted incident
fields that better approximate the true total field.
Parameters:
forward_solver (Forward) – Forward solver implementation for computing total electric field
and scattered field from given contrast distribution
regularization (Regularization) – Regularization method for solving the linear inverse problem
(e.g., Tikhonov regularization, truncated SVD)
stop_criteria (StopCriteria) – Stopping criteria object defining when to terminate iterations
(e.g., maximum iterations, relative error threshold)
alias (str, default='dbim') – Alias name for the algorithm instance
import_filename (str, optional) – Filename to import previously saved algorithm state
import_filepath (str, default='') – Path to directory containing import file
Initialize the Distorted Born Iterative Method solver.
Parameters:
forward_solver (Forward) – Forward solver implementation for computing electromagnetic fields.
Must implement methods for computing incident field and solving
the forward scattering problem.
regularization (Regularization) – Regularization method for solving the linear inverse problem.
Common choices include Tikhonov regularization, truncated SVD,
or other regularization schemes.
stop_criteria (StopCriteria) – Stopping criteria object that determines when to terminate
the iterative process. Can be based on maximum iterations,
relative error, objective function value, etc.
alias (str, default='dbim') – Alias name for the algorithm instance, used for identification
and file naming when saving/loading algorithm state.
import_filename (str, optional) – If provided, imports algorithm state from this file instead
of initializing with provided parameters.
import_filepath (str, default='') – Directory path where the import file is located.
Notes
If import_filename is provided, the algorithm state is loaded
from file and other parameters are ignored. Otherwise, a new
instance is created with the provided solver components.
Solve electromagnetic inverse scattering problem using DBIM.
This method implements the complete DBIM algorithm, iteratively
updating the contrast function and Green’s function until
convergence or maximum iterations are reached.
Algorithm Steps:
1. Initialize with Born approximation (incident field as total field)
2. Solve linear inverse problem for initial contrast estimate
3. Enter iterative loop:
Update Green’s function using current contrast
Solve forward problem with updated Green’s function
Compute residual scattered field
Solve linear inverse problem for contrast update
Check stopping criteria
Return final reconstruction results
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired output resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Discretization grid points
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix
- Methods for field interpolation and contrast imaging
print_info (bool, default=True) – Whether to print iteration information during solving
print_file (file-like object, default=sys.stdout) – Output stream for printing iteration information
initial_guess (array_like, optional) – Initial guess for contrast function. If None, uses Born
approximation with incident field as total field.
Returns:
Result object containing:
- rel_permittivity: Reconstructed relative permittivity
- conductivity: Reconstructed conductivity (if applicable)
- scattered_field: Final computed scattered field
- total_field: Final computed total field
- execution_time: Algorithm execution time
- number_iterations: Number of iterations performed
- number_evaluations: Number of function evaluations
- error_history: Convergence history
The algorithm automatically handles both good conductor and
perfect dielectric cases based on the configuration. For
good conductors, only conductivity is reconstructed. For
perfect dielectrics, only permittivity is reconstructed.
The Green’s function update is the key difference from standard
BIM, providing better convergence for high-contrast scatterers
by using distorted incident fields.
Examples
>>> # Solve with default settings>>> result=solver.solve(input_data,discretization)>>> print(f"Converged in {result.number_iterations} iterations")
>>> # Solve with initial guess and custom output>>> withopen('output.txt','w')asf:... result=solver.solve(input_data,discretization,... initial_guess=my_guess,... print_file=f)
Evolutionary Algorithm for electromagnetic inverse scattering.
This class implements a general evolutionary algorithm framework for solving
electromagnetic inverse scattering problems. It supports various evolutionary
mechanisms including Differential Evolution, Particle Swarm Optimization,
and Genetic Algorithms.
Parameters:
population_size (int) – Size of the population.
initialization (Initialization) – Population initialization strategy.
objective_function (ObjectiveFunction) – Objective function to evaluate solution quality.
This class implements the Extended Contrast Source Inversion (ECSI) algorithm,
an advanced iterative nonlinear solver for electromagnetic inverse scattering
problems. ECSI extends the classical Contrast Source Inversion (CSI) approach
by incorporating enhanced optimization techniques and conjugate gradient methods.
The method alternately updates the contrast function (representing material
properties) and current density distribution within the scattering domain.
It employs a cost function minimization approach with conjugate gradient
optimization for efficient convergence.
where:
- \(\\chi\) is the contrast function
- \(\\mathbf{J}\) is the current density
- \(\\mathbf{E}^s\) is the scattered electric field
- \(\\mathbf{E}^{tot}\) is the total electric field
- \(\\mathbf{G}^s\) is the scattered field Green’s function
Initialize the Extended Contrast Source Inversion solver.
Creates an ECSI solver instance with specified stopping criteria and
forward solver. The solver can be initialized from scratch or loaded
from a previously saved state.
Parameters:
stop_criteria (stopcriteria.StopCriteria) – Object defining the stopping criteria for the iterative algorithm.
This includes maximum iterations, convergence thresholds, and
other termination conditions.
forward_solver (forward.Forward, optional) – Forward solver implementation for computing the total electric field.
Default is mom_cg_fft.MoM_CG_FFT.
alias (str, optional) – Short identifier for this solver instance. Used in result naming
and file operations. Default is ‘ecsi’.
import_filename (str, optional) – Name of file containing previously saved solver state. If provided,
the solver will be initialized from this saved state. Default is None.
import_filepath (str, optional) – Directory path containing the import file. Only used if import_filename
is provided. Default is empty string (current directory).
Raises:
FileNotFoundError – If import_filename is specified but the file cannot be found.
ValueError – If the loaded file contains invalid or corrupted solver state.
Creates a new solver instance with the same configuration or copies
configuration from another solver instance.
Parameters:
new (ExtendedContrastSourceInversion, optional) – Another solver instance to copy configuration from. If None,
creates a new instance with current configuration.
Solve the electromagnetic inverse scattering problem using ECSI.
Performs iterative reconstruction of the contrast function and current
density distribution using the Extended Contrast Source Inversion algorithm.
The method alternates between updating the current density (J) and the
contrast function (\chi) using conjugate gradient optimization.
Parameters:
inputdata (inputdata.InputData) – Object containing the measured scattered field data and problem
configuration including frequency, measurement points, and incident
field parameters.
discretization (discretization.Discretization) – Discretization scheme defining the computational grid, Green’s
functions, and spatial sampling of the investigation domain.
print_info (bool, optional) – Whether to print iteration progress information. Default is True.
print_file (file-like object, optional) – File object for printing output. Default is sys.stdout.
initial_guess (numpy.ndarray, optional) – Initial guess for the contrast function. If None, backpropagation
method is used to generate initial guess. Default is None.
Returns:
result – Object containing the reconstructed contrast function, relative
permittivity, conductivity, total field, and convergence information.
Return type:
result.Result
Raises:
ValueError – If input data or discretization are invalid.
RuntimeError – If the algorithm fails to converge within specified criteria.
Notes
The algorithm implements the following iterative procedure:
Initialization: Generate initial guess using backpropagation if not provided
Current Update: Minimize data and object error functionals with respect to J
Contrast Update: Minimize object error functional with respect to \chi
Convergence Check: Evaluate stopping criteria and continue if necessary
First-Order Born Approximation for Electromagnetic Inverse Scattering.
This class implements the First-Order Born Approximation (FOBA), a
linearization technique for solving electromagnetic inverse scattering
problems. The method assumes that the total field inside the scattering
object is approximately equal to the incident field, making it suitable
for weak scatterers.
The Born approximation converts the nonlinear inverse scattering problem
into a linear one by replacing the unknown total field with the known
incident field in the scattering integral equation. This results in a
single linear system that can be solved directly.
Mathematical Formulation:
The method solves the linearized equation:
E_s = G_S * chi * E_i
where:
- E_s: scattered field (measured data)
- G_S: scattering Green’s function matrix
- chi: contrast function (unknown to be reconstructed)
- E_i: incident field (known)
Parameters:
regularization (Regularization) – Regularization method for solving the linear inverse problem.
Required to handle the ill-conditioned nature of the inverse problem.
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver for computing incident fields and Green’s functions.
alias (str, default: 'ba') – Alias name for the method instance.
Validity Range: The Born approximation is valid when:
- The contrast is small (|\chi| << 1)
- The scatterer is electrically small
- The refractive index variation is gradual
Advantages:
- Fast computation (single linear solve)
- No iteration required
- Good initial guess for iterative methods
- Stable and well-understood
Limitations:
- Limited to weak scatterers
- Poor performance for high-contrast objects
- No nonlinear coupling effects
Initialize the First-Order Born Approximation method.
Creates a new FOBA instance with the specified regularization method
and forward solver configuration.
Parameters:
regularization (Regularization) – Regularization method for solving the ill-conditioned linear
inverse problem. Common choices include Tikhonov regularization,
truncated SVD, or iterative methods like CGLS.
forward (ForwardSolver, default: mom.MoM_CG_FFT()) – Forward solver implementation for computing incident fields and
Green’s function matrices. Must implement the ForwardSolver interface.
alias (str, default: 'ba') – Short alias name for this method instance, used for identification
and file naming purposes.
import_filename (str, optional) – Filename to import previously saved method state. If provided,
other parameters are ignored and the state is loaded from file.
import_filepath (str, default: '') – Path to the file containing saved method state.
Notes
The regularization parameter is crucial for the Born approximation
because the inverse scattering problem is inherently ill-conditioned.
The choice of regularization method and its parameters significantly
affects the reconstruction quality.
The forward solver is used to compute the incident field, which serves
as the approximation for the total field in the Born approximation.
Different forward solvers may be used depending on the problem geometry
and computational requirements.
Return string representation of the First-Order Born Approximation.
Creates a comprehensive string description of the FOBA instance
including all its components and configuration.
Returns:
String representation including:
- Base class information (name, alias, etc.)
- Regularization method details
- Forward solver configuration
Return type:
str
Notes
This method provides a complete overview of the FOBA configuration,
which is useful for debugging, logging, and understanding the
method setup. The string includes detailed information about
the regularization method and forward solver parameters.
Examples
>>> print(born)First-Order Born Approximation (ba)Regularization: Tikhonov (λ=1e-3)Forward Solver: MoM-CG-FFT...
The copy includes all method components:
- Regularization method (reference copy)
- Forward solver (reference copy)
- Base class attributes (alias, etc.)
This method is useful for creating multiple instances with the same
configuration, parameter studies, or backup purposes before
modifying parameters.
Examples
>>> # Create a copy>>> born_copy=born.copy()>>>>>> # Copy to existing instance>>> new_born=FirstOrderBornApproximation(some_regularization)>>> born.copy(new_born)# copies configuration to new_born
Import First-Order Born Approximation method state from file.
Loads a previously saved FOBA configuration from file, restoring
all method parameters and settings.
Parameters:
file_name (str) – Name of the file containing saved method state.
file_path (str, default: '') – Path to the file containing saved method state.
Notes
This method restores the complete FOBA configuration including:
- Regularization method with all its parameters
- Forward solver configuration and settings
- Base class attributes and state
The loaded configuration can be used to recreate the exact same
method instance as was saved, ensuring reproducibility of results.
Examples
>>> # Import from current directory>>> born=FirstOrderBornApproximation(None)# dummy init>>> born.importdata('ba')# load from file>>>>>> # Import from specific path>>> born.importdata('my_method','/path/to/files/')
Save the First-Order Born Approximation method state to file.
Saves the complete method configuration including regularization
method and forward solver settings to a file for later retrieval.
Parameters:
file_path (str, default: '') – Path where to save the method state file. The file will be
saved with the method’s alias as the filename.
Notes
The method saves all necessary information to recreate the FOBA
instance, including:
- Regularization method and its parameters
- Forward solver configuration
- Base class attributes (alias, etc.)
The file is saved using pickle serialization format, which preserves
the complete object state including any custom parameters or
configurations.
Examples
>>> # Save method to current directory>>> born.save()>>>>>> # Save to specific path>>> born.save('/path/to/save/')
Solve the inverse scattering problem using First-Order Born Approximation.
Implements the Born approximation to reconstruct material properties
from scattered field measurements. The method solves a single linearized
system by approximating the total field with the incident field.
Parameters:
inputdata (InputData) – Input data object containing scattered field measurements,
configuration parameters, and problem setup information.
discretization (Discretization) – Discretization object containing domain information, Green’s
function matrices, and numerical methods for field computation.
print_info (bool, default: True) – Whether to print algorithm progress and results information.
print_file (file-like object, default: sys.stdout) – File object to write progress information to.
Returns:
result – Result object containing the reconstructed material properties,
fields, error metrics, and algorithm performance information.
Incident Field Computation: Calculate the incident field E_i
in the discretization domain using the forward solver.
Linear System Solution: Solve the linearized equation:
\[\chi = \mathcal{R}[G_S^H E_s]\]
where \(\mathcal{R}\) is the regularization operator,
\(G_S^H\) is the adjoint scattering Green’s function,
and \(E_s\) is the scattered field.
Field Reconstruction: Compute the reconstructed scattered field
using the estimated contrast:
\[E_s^{rec} = G_S \chi E_i\]
Parameter Conversion: Convert the contrast function to physical
parameters (relative permittivity, conductivity) based on the
problem configuration.
Error Computation: Calculate various error metrics and
performance indicators.
Computational Complexity: O(N²) where N is the number of
discretization points, dominated by the linear system solution.
Memory Requirements: Depends on the regularization method and
Green’s function matrix storage.
The method automatically handles both dielectric and conducting
materials, converting between contrast and physical parameters
as needed based on the problem configuration.
Linear Sampling Method for qualitative inverse scattering.
This class implements the Linear Sampling Method (LSM), a qualitative
technique for shape reconstruction of scatterers. The method identifies
the support of the scatterer without reconstructing material properties.
Parameters:
alias (str, default='') – Alias name for the algorithm.
regularization (Regularization, optional) – Regularization method for solving linear systems.
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
This class implements a classical nonlinear inverse solver [1]_. The
method is based on coupling forward and inverse solvers in an
iterative process. Therefore, it depends on the definition of a
forward solver implementation and an linear inverse one.
Stop criterion for the algorithm. The algorithm will stop
when the amount of variation from the current iteration in
respect to the last one is below some threshold percentage:
Number of iterations in which it will be accepted a
divergence occurrence, i.e., the new solution has a larger
evaluation than the previous considering the stop criterion
measure.
configuration (configuration.Configuration) – It may be either an object of problem configuration or
a string to a pre-saved file or a 2-tuple with the file
name and path, respectively.
version (str) – A string naming the version of this method. It may be
useful when using different implementation of forward
and inverse solvers.
forward_solver (forward.Forward) – An implementation of the abstract class Forward which
defines a method for computing the total intern field.
inverse_solver (inverse.Inverse) – An implementation of the abstract class Inverse which
defines a method for solving the linear inverse problem.
maximum_iterations (int, default: 10) – Maximum number of iterations.
stopcriterion_measure (float, default: 1e-3) –
Define the measure for stop criterion. The algorithm
will stop when the amount of variation from the current
iteration in respect to the last one is below some
threshold percentage:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
Orthogonality Sampling Method for qualitative inverse scattering.
This class implements the Orthogonality Sampling Method (OSM), a qualitative
technique for shape reconstruction based on orthogonality properties of
the scattered field.
Parameters:
alias (str, default='osm') – Alias name for the algorithm.
threshold (float, optional) – Threshold for indicator function.
far_field (bool, optional) – Whether to use far-field approximation.
import_filename (str, optional) – Filename to import algorithm state from.
import_filepath (str, default='') – Path to import file.
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information:
Solve the electromagnetic inverse scattering problem.
This method provides the standard interface for solving inverse
scattering problems using deterministic methods. The base implementation
calls the parent InverseSolver method to handle common setup and
validation tasks.
Parameters:
inputdata (InputData) – Input data object containing:
- scattered_field: Measured scattered field data
- configuration: Problem configuration (frequency, background, etc.)
- resolution: Desired reconstruction resolution
- indicators: Performance metrics to compute
discretization (Discretization) – Discretization object containing:
- elements: Spatial discretization grid
- GS: Scattered field Green’s function matrix
- GD: Domain Green’s function matrix (if needed)
- Methods for field interpolation and imaging
print_info (bool, default=True) – Whether to print algorithm progress and iteration information
during the solving process. Useful for monitoring convergence
and debugging.
print_file (file-like object, default=sys.stdout) – Output stream for printing information. Can be redirected to
files or other output streams as needed.
Returns:
Result object containing reconstruction results and performance
metrics. The specific contents depend on the algorithm
implementation but typically include:
- Reconstructed electromagnetic properties
- Convergence history
- Performance metrics
- Algorithm-specific information
This base implementation performs common setup tasks and validation
that are required by all deterministic solvers. Derived classes
should override this method to implement their specific algorithm
while calling the parent method for initialization:
This class implements a classical nonlinear inverse solver [1]_. The
method is based on coupling forward and inverse solvers in an
iterative process. Therefore, it depends on the definition of a
forward solver implementation and an linear inverse one.
Stop criterion for the algorithm. The algorithm will stop
when the amount of variation from the current iteration in
respect to the last one is below some threshold percentage:
Number of iterations in which it will be accepted a
divergence occurrence, i.e., the new solution has a larger
evaluation than the previous considering the stop criterion
measure.
configuration (configuration.Configuration) – It may be either an object of problem configuration or
a string to a pre-saved file or a 2-tuple with the file
name and path, respectively.
version (str) – A string naming the version of this method. It may be
useful when using different implementation of forward
and inverse solvers.
forward_solver (forward.Forward) – An implementation of the abstract class Forward which
defines a method for computing the total intern field.
inverse_solver (inverse.Inverse) – An implementation of the abstract class Inverse which
defines a method for solving the linear inverse problem.
maximum_iterations (int, default: 10) – Maximum number of iterations.
stopcriterion_measure (float, default: 1e-3) –
Define the measure for stop criterion. The algorithm
will stop when the amount of variation from the current
iteration in respect to the last one is below some
threshold percentage:
This method creates a deep copy of the current solver instance,
including all configuration parameters and settings. The copy
can be used independently without affecting the original solver.
Parameters:
new (Deterministic, optional) – If provided, the current solver’s configuration will be
copied into this existing instance. If None, a new instance
will be created and returned.
Returns:
If new is None, returns a new Deterministic instance with
the same configuration. If new is provided, returns None
and the configuration is copied into the new instance.
This method creates independent copies that can be used for
parallel processing, parameter studies, or comparative analysis
without interference between instances.
The base implementation copies common solver attributes. Derived
classes should override this method to handle algorithm-specific
parameters:
>>> # Copy configuration into existing instance>>> target_solver=Deterministic()>>> solver.copy(target_solver)>>> print(f"Target now has alias: {target_solver.alias}")
>>> # Use for parameter studies>>> solvers=[solver.copy()for_inrange(5)]>>> # Modify each copy independently for different parameters
This method deserializes solver state from a file that was
previously created using the save method. It restores all
configuration parameters, algorithm settings, and internal state
to recreate the exact solver configuration.
Parameters:
file_name (str) – Name of the file containing the saved solver state. This
should match the filename created by the save method.
file_path (str, default='') – Directory path where the save file is located. If empty,
looks in the current directory.
Returns:
Dictionary containing the loaded solver state data. This
provides access to all restored parameters and settings.
Return type:
dict
Notes
The base implementation loads common solver attributes. Derived
classes should override this method to restore algorithm-specific
state information:
data = super().importdata(file_name, file_path=file_path)
self.my_specific_param = data[‘my_specific_param’]
# Restore additional algorithm-specific data
return data
The method completely replaces the current solver state with
the loaded configuration, so any existing settings will be lost.
Examples
>>> # Load from current directory>>> data=solver.importdata('solver_state.pkl')>>> print(f"Loaded {len(data)} parameters")
>>> # Load from specific directory>>> data=solver.importdata('state.pkl',file_path='/path/to/files/')>>> print(f"Restored solver configuration from {file_path}")
Raises:
FileNotFoundError – If the specified file does not exist
pickle.UnpicklingError – If the file is corrupted or incompatible
This method serializes the current solver state including all
configuration parameters, algorithm settings, and internal state
to a file. The saved state can later be restored using the
importdata method.
Parameters:
file_path (str, default='') – Base path for saving the solver state. The actual filename
will be constructed by appending the solver’s alias to this
base path. If empty, saves to current directory.
Returns:
Dictionary containing the serialized solver state data.
This includes all necessary information to fully restore
the solver configuration and state.
Return type:
dict
Notes
The base implementation saves common solver attributes. Derived
classes should override this method to include algorithm-specific
state information: