DP3
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
dp3::ddecal::SolverBase Class Referenceabstract

#include <SolverBase.h>

Inheritance diagram for dp3::ddecal::SolverBase:
dp3::ddecal::DiagonalLowRankSolver dp3::ddecal::DiagonalSolver dp3::ddecal::FullJonesSolver dp3::ddecal::HybridSolver dp3::ddecal::IterativeDiagonalSolver< VisMatrix > dp3::ddecal::IterativeDiagonalSolverCuda< VisMatrix > dp3::ddecal::IterativeFullJonesSolver dp3::ddecal::IterativeScalarSolver< VisMatrix > dp3::ddecal::ScalarSolver

Classes

class  Matrix
 
struct  SolveResult
 

Public Types

typedef std::complex< float > Complex
 
typedef std::complex< double > DComplex
 

Public Member Functions

 SolverBase ()
 
virtual ~SolverBase ()=default
 
void AddConstraint (std::unique_ptr< Constraint > constraint)
 
virtual std::vector< SolverBase * > ConstraintSolvers ()
 
const std::vector< std::unique_ptr< Constraint > > & GetConstraints ()
 
LLSSolverType GetLLSSolverType () const
 
bool GetPhaseOnly () const
 
void GetTimings (std::ostream &os, double duration) const
 
virtual void Initialize (size_t n_antennas, const std::vector< size_t > &n_solutions_per_direction, size_t n_channel_blocks)
 
virtual size_t NSolutionPolarizations () const =0
 
void SetDdConstraintWeights (const std::vector< std::vector< double >> &weights)
 
void SetLLSSolverType (LLSSolverType solver_type)
 
void SetPhaseOnly (bool phase_only)
 
virtual SolveResult Solve (const DuoSolveData &data, std::vector< std::vector< DComplex >> &solutions, double time)
 
virtual SolveResult Solve (const FullSolveData &data, std::vector< std::vector< DComplex >> &solutions, double time)
 
virtual SolveResult Solve (const UniSolveData &data, std::vector< std::vector< DComplex >> &solutions, double time)
 
virtual bool SupportsDdSolutionIntervals () const
 
size_t GetMaxIterations () const
 
void SetMaxIterations (size_t max_iterations)
 
size_t GetMinIterations () const
 
void SetMinIterations (size_t min_iterations)
 
void SetAccuracy (double accuracy)
 
double GetAccuracy () const
 
void SetConstraintAccuracy (double constraint_accuracy)
 
double GetConstraintAccuracy () const
 
void SetStepSize (double step_size)
 
double GetStepSize () const
 
void SetDetectStalling (bool detect_stalling, double step_diff_sigma)
 
bool GetDetectStalling () const
 

Protected Member Functions

bool ApplyConstraints (size_t iteration, double time, bool has_previously_converged, SolutionSpan &next_solutions) const
 
bool ApplyConstraints (size_t iteration, double time, bool has_previously_converged, SolutionTensor &next_solutions) const
 
bool AssignSolutions (std::vector< std::vector< DComplex >> &solutions, SolutionSpan &new_solutions, bool use_constraint_accuracy, double &avg_abs_diff, std::vector< double > &step_magnitudes) const
 
bool AssignSolutions (std::vector< std::vector< DComplex >> &solutions, SolutionTensor &new_solutions, bool use_constraint_accuracy, double &avg_abs_diff, std::vector< double > &step_magnitudes) const
 
std::unique_ptr< LLSSolverCreateLLSSolver (size_t m, size_t n, size_t nrhs) const
 
bool DetectStall (size_t iteration, const std::vector< double > &step_magnitudes)
 
std::unique_ptr< aocommon::RecursiveFor > MakeOptionalRecursiveFor () const
 
SolveResult MakeResult (size_t iteration, bool has_converged, bool constraints_satisfied) const
 
size_t NAntennas () const
 
size_t NChannelBlocks () const
 
size_t NDirections () const
 
size_t NSubSolutions () const
 
size_t NSubThreads () const
 
size_t NVisibilities () const
 
void PrepareConstraints ()
 
bool ReachedStoppingCriterion (size_t iteration, bool has_converged, bool constraints_satisfied, const std::vector< double > &step_magnitudes)
 
void Step (const std::vector< std::vector< DComplex >> &solutions, SolutionTensor &next_solutions) const
 

Static Protected Member Functions

static void MakeSolutionsFinite1Pol (std::vector< std::vector< DComplex >> &solutions)
 
static void MakeSolutionsFinite2Pol (std::vector< std::vector< DComplex >> &solutions)
 
static void MakeSolutionsFinite4Pol (std::vector< std::vector< DComplex >> &solutions)
 

Member Typedef Documentation

◆ Complex

typedef std::complex<float> dp3::ddecal::SolverBase::Complex

◆ DComplex

typedef std::complex<double> dp3::ddecal::SolverBase::DComplex

Constructor & Destructor Documentation

◆ SolverBase()

dp3::ddecal::SolverBase::SolverBase ( )

◆ ~SolverBase()

virtual dp3::ddecal::SolverBase::~SolverBase ( )
virtualdefault

Member Function Documentation

◆ AddConstraint()

void dp3::ddecal::SolverBase::AddConstraint ( std::unique_ptr< Constraint constraint)
inline

Add a constraint to the solver.

Parameters
constraintA valid constraint pointer, must not be nullptr.

◆ ApplyConstraints() [1/2]

bool dp3::ddecal::SolverBase::ApplyConstraints ( size_t  iteration,
double  time,
bool  has_previously_converged,
SolutionSpan next_solutions 
) const
protected

◆ ApplyConstraints() [2/2]

bool dp3::ddecal::SolverBase::ApplyConstraints ( size_t  iteration,
double  time,
bool  has_previously_converged,
SolutionTensor next_solutions 
) const
protected

◆ AssignSolutions() [1/2]

bool dp3::ddecal::SolverBase::AssignSolutions ( std::vector< std::vector< DComplex >> &  solutions,
SolutionSpan new_solutions,
bool  use_constraint_accuracy,
double &  avg_abs_diff,
std::vector< double > &  step_magnitudes 
) const
protected

◆ AssignSolutions() [2/2]

bool dp3::ddecal::SolverBase::AssignSolutions ( std::vector< std::vector< DComplex >> &  solutions,
SolutionTensor new_solutions,
bool  use_constraint_accuracy,
double &  avg_abs_diff,
std::vector< double > &  step_magnitudes 
) const
protected

Assign the solutions in nextSolutions to the solutions.

Returns
whether the solutions have converged. Appends the current step magnitude to step_magnitudes

◆ ConstraintSolvers()

virtual std::vector<SolverBase*> dp3::ddecal::SolverBase::ConstraintSolvers ( )
inlinevirtual

Returns a list of solvers that this solver uses and for which constraints should be set up. The HybridSolver overrides this function to make it possible to initialize the solvers it combines.

Reimplemented in dp3::ddecal::HybridSolver.

◆ CreateLLSSolver()

std::unique_ptr<LLSSolver> dp3::ddecal::SolverBase::CreateLLSSolver ( size_t  m,
size_t  n,
size_t  nrhs 
) const
protected

Create an LLSSolver with the given matrix dimensions. Set the tolerance using 'iteration_fraction' and 'solver_precision'.

◆ DetectStall()

bool dp3::ddecal::SolverBase::DetectStall ( size_t  iteration,
const std::vector< double > &  step_magnitudes 
)
protected

◆ GetAccuracy()

double dp3::ddecal::SolverBase::GetAccuracy ( ) const
inline

◆ GetConstraintAccuracy()

double dp3::ddecal::SolverBase::GetConstraintAccuracy ( ) const
inline

◆ GetConstraints()

const std::vector<std::unique_ptr<Constraint> >& dp3::ddecal::SolverBase::GetConstraints ( )
inline

Get the constraints for the solver.

Returns
A non-modifiable list of modifiable Constraints. All pointers in the list are valid.

◆ GetDetectStalling()

bool dp3::ddecal::SolverBase::GetDetectStalling ( ) const
inline

◆ GetLLSSolverType()

LLSSolverType dp3::ddecal::SolverBase::GetLLSSolverType ( ) const
inline

◆ GetMaxIterations()

size_t dp3::ddecal::SolverBase::GetMaxIterations ( ) const
inline

Max nr of iterations (stopping criterion).

◆ GetMinIterations()

size_t dp3::ddecal::SolverBase::GetMinIterations ( ) const
inline

Min nr of iterations before stopping.

◆ GetPhaseOnly()

bool dp3::ddecal::SolverBase::GetPhaseOnly ( ) const
inline

If enabled, the solver will perform steps along the complex circle, instead of moving freely through complex space. See the implementation of MakeStep(). {

◆ GetStepSize()

double dp3::ddecal::SolverBase::GetStepSize ( ) const
inline

◆ GetTimings()

void dp3::ddecal::SolverBase::GetTimings ( std::ostream &  os,
double  duration 
) const

Output timing information to a stream.

◆ Initialize()

virtual void dp3::ddecal::SolverBase::Initialize ( size_t  n_antennas,
const std::vector< size_t > &  n_solutions_per_direction,
size_t  n_channel_blocks 
)
virtual

Prepares the solver with the given dimensionality info and antenna mapping. The antenna arrays map the data provided in @Solve to the antennas.

Reimplemented in dp3::ddecal::HybridSolver.

◆ MakeOptionalRecursiveFor()

std::unique_ptr<aocommon::RecursiveFor> dp3::ddecal::SolverBase::MakeOptionalRecursiveFor ( ) const
protected

If useful, make a RecursiveFor object. The existance of a RecursiveFor makes the StaticFor use the RecursiveFor. Using a StaticFor inside a RecursiveFor allows nested parallelization, but it is slower. Therefore, if no nested parallelization can be done, don't create a RecursiveFor. See also NSubThreads().

◆ MakeResult()

SolveResult dp3::ddecal::SolverBase::MakeResult ( size_t  iteration,
bool  has_converged,
bool  constraints_satisfied 
) const
protected

◆ MakeSolutionsFinite1Pol()

static void dp3::ddecal::SolverBase::MakeSolutionsFinite1Pol ( std::vector< std::vector< DComplex >> &  solutions)
staticprotected

◆ MakeSolutionsFinite2Pol()

static void dp3::ddecal::SolverBase::MakeSolutionsFinite2Pol ( std::vector< std::vector< DComplex >> &  solutions)
staticprotected

◆ MakeSolutionsFinite4Pol()

static void dp3::ddecal::SolverBase::MakeSolutionsFinite4Pol ( std::vector< std::vector< DComplex >> &  solutions)
staticprotected

◆ NAntennas()

size_t dp3::ddecal::SolverBase::NAntennas ( ) const
inlineprotected

◆ NChannelBlocks()

size_t dp3::ddecal::SolverBase::NChannelBlocks ( ) const
inlineprotected

◆ NDirections()

size_t dp3::ddecal::SolverBase::NDirections ( ) const
inlineprotected

◆ NSolutionPolarizations()

virtual size_t dp3::ddecal::SolverBase::NSolutionPolarizations ( ) const
pure virtual

◆ NSubSolutions()

size_t dp3::ddecal::SolverBase::NSubSolutions ( ) const
inlineprotected

Total number of solutions over all directions This might be different from n_directions_ when using direction-dependent intervals.

◆ NSubThreads()

size_t dp3::ddecal::SolverBase::NSubThreads ( ) const
protected

Returns the number of available thread for one channel. This assumes that the channel blocks is the main direction that is parallelized over (as all solvers are currently doing). For example, if there are 20 threads available, and the number of channel blocks is 10, then 2 is returned, because each channel block can use two threads to fill up the cpu. The returned value is at least 1.

◆ NVisibilities()

size_t dp3::ddecal::SolverBase::NVisibilities ( ) const
inlineprotected

Total number of visibilities over all channel blocks

◆ PrepareConstraints()

void dp3::ddecal::SolverBase::PrepareConstraints ( )
protected

◆ ReachedStoppingCriterion()

bool dp3::ddecal::SolverBase::ReachedStoppingCriterion ( size_t  iteration,
bool  has_converged,
bool  constraints_satisfied,
const std::vector< double > &  step_magnitudes 
)
inlineprotected

◆ SetAccuracy()

void dp3::ddecal::SolverBase::SetAccuracy ( double  accuracy)
inline

Required relative accuracy.

◆ SetConstraintAccuracy()

void dp3::ddecal::SolverBase::SetConstraintAccuracy ( double  constraint_accuracy)
inline

Required relative accuracy for the constraints to finish.

◆ SetDdConstraintWeights()

void dp3::ddecal::SolverBase::SetDdConstraintWeights ( const std::vector< std::vector< double >> &  weights)

Calls SetSolutionWeights() for all constraints.

◆ SetDetectStalling()

void dp3::ddecal::SolverBase::SetDetectStalling ( bool  detect_stalling,
double  step_diff_sigma 
)
inline

Whether stalling of the solutions should abort the solving.

◆ SetLLSSolverType()

void dp3::ddecal::SolverBase::SetLLSSolverType ( LLSSolverType  solver_type)

◆ SetMaxIterations()

void dp3::ddecal::SolverBase::SetMaxIterations ( size_t  max_iterations)
inline

◆ SetMinIterations()

void dp3::ddecal::SolverBase::SetMinIterations ( size_t  min_iterations)
inline

◆ SetPhaseOnly()

void dp3::ddecal::SolverBase::SetPhaseOnly ( bool  phase_only)
inline

◆ SetStepSize()

void dp3::ddecal::SolverBase::SetStepSize ( double  step_size)
inline

The step size taken each iteration. Higher values might make convergence faster, but may cause instability.

◆ Solve() [1/3]

virtual SolveResult dp3::ddecal::SolverBase::Solve ( const DuoSolveData data,
std::vector< std::vector< DComplex >> &  solutions,
double  time 
)
inlinevirtual

◆ Solve() [2/3]

virtual SolveResult dp3::ddecal::SolverBase::Solve ( const FullSolveData data,
std::vector< std::vector< DComplex >> &  solutions,
double  time 
)
inlinevirtual

Solves multi-directional Jones matrices. Takes the (single) measured data and the (multi-directional) model data, and solves the optimization problem that minimizes the norm of the differences.

Parameters
dataBuffer with weighted data and model data.
solutionsThe per-channel and per-antenna solutions. solutions[ch] is a pointer for channelblock ch to antenna x directions x pol solutions.

Reimplemented in dp3::ddecal::HybridSolver, dp3::ddecal::ScalarSolver, dp3::ddecal::IterativeFullJonesSolver, dp3::ddecal::FullJonesSolver, dp3::ddecal::DiagonalSolver, and dp3::ddecal::DiagonalLowRankSolver.

◆ Solve() [3/3]

virtual SolveResult dp3::ddecal::SolverBase::Solve ( const UniSolveData data,
std::vector< std::vector< DComplex >> &  solutions,
double  time 
)
inlinevirtual

◆ Step()

void dp3::ddecal::SolverBase::Step ( const std::vector< std::vector< DComplex >> &  solutions,
SolutionTensor next_solutions 
) const
protected

◆ SupportsDdSolutionIntervals()

virtual bool dp3::ddecal::SolverBase::SupportsDdSolutionIntervals ( ) const
inlinevirtual

True if this solver supports direction-dependent solution intervals. In that case, the solver can solve different directions with different solution intervals. More specific, each timestep of each direction can individually be set to belong to a specific solution.

Reimplemented in dp3::ddecal::IterativeScalarSolver< VisMatrix >, dp3::ddecal::IterativeFullJonesSolver, dp3::ddecal::IterativeDiagonalSolverCuda< VisMatrix >, and dp3::ddecal::IterativeDiagonalSolver< VisMatrix >.


The documentation for this class was generated from the following file: