improve PCGSolverParameters
							parent
							
								
									322a23d49c
								
							
						
					
					
						commit
						91d637b092
					
				| 
						 | 
				
			
			@ -40,7 +40,7 @@ void PCGSolverParameters::print(ostream &os) const {
 | 
			
		|||
/*****************************************************************************/
 | 
			
		||||
PCGSolver::PCGSolver(const PCGSolverParameters &p) {
 | 
			
		||||
  parameters_ = p;
 | 
			
		||||
  preconditioner_ = createPreconditioner(p.preconditioner_);
 | 
			
		||||
  preconditioner_ = createPreconditioner(p.preconditioner());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PCGSolverParameters::setPreconditionerParams(const std::shared_ptr<PreconditionerParameters> preconditioner) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,26 +34,30 @@ struct PreconditionerParameters;
 | 
			
		|||
 * Parameters for PCG
 | 
			
		||||
 */
 | 
			
		||||
struct GTSAM_EXPORT PCGSolverParameters: public ConjugateGradientParameters {
 | 
			
		||||
public:
 | 
			
		||||
 public:
 | 
			
		||||
  typedef ConjugateGradientParameters Base;
 | 
			
		||||
  typedef std::shared_ptr<PCGSolverParameters> shared_ptr;
 | 
			
		||||
 | 
			
		||||
  PCGSolverParameters() {
 | 
			
		||||
  }
 | 
			
		||||
protected:
 | 
			
		||||
  std::shared_ptr<PreconditionerParameters> preconditioner_;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
  PCGSolverParameters() {}
 | 
			
		||||
 | 
			
		||||
  PCGSolverParameters(
 | 
			
		||||
      const std::shared_ptr<PreconditionerParameters> &preconditioner)
 | 
			
		||||
      : preconditioner_(preconditioner) {}
 | 
			
		||||
 | 
			
		||||
  void print(std::ostream &os) const override;
 | 
			
		||||
 | 
			
		||||
  /* interface to preconditioner parameters */
 | 
			
		||||
  inline const PreconditionerParameters& preconditioner() const {
 | 
			
		||||
    return *preconditioner_;
 | 
			
		||||
  const std::shared_ptr<PreconditionerParameters> preconditioner() const {
 | 
			
		||||
    return preconditioner_;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // needed for python wrapper
 | 
			
		||||
  void setPreconditionerParams(
 | 
			
		||||
      const std::shared_ptr<PreconditionerParameters> preconditioner);
 | 
			
		||||
 | 
			
		||||
  void print(const std::string &s) const;
 | 
			
		||||
 | 
			
		||||
  std::shared_ptr<PreconditionerParameters> preconditioner_;
 | 
			
		||||
 | 
			
		||||
  void setPreconditionerParams(const std::shared_ptr<PreconditionerParameters> preconditioner);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,20 +67,15 @@ ShonanAveragingParameters<d>::ShonanAveragingParameters(
 | 
			
		|||
  builderParameters.augmentationWeight = SubgraphBuilderParameters::SKELETON;
 | 
			
		||||
  builderParameters.augmentationFactor = 0.0;
 | 
			
		||||
 | 
			
		||||
  auto pcg = std::make_shared<PCGSolverParameters>();
 | 
			
		||||
 | 
			
		||||
  // Choose optimization method
 | 
			
		||||
  if (method == "SUBGRAPH") {
 | 
			
		||||
    lm.iterativeParams =
 | 
			
		||||
        std::make_shared<SubgraphSolverParameters>(builderParameters);
 | 
			
		||||
  } else if (method == "SGPC") {
 | 
			
		||||
    pcg->preconditioner_ =
 | 
			
		||||
        std::make_shared<SubgraphPreconditionerParameters>(builderParameters);
 | 
			
		||||
    lm.iterativeParams = pcg;
 | 
			
		||||
    lm.iterativeParams = std::make_shared<PCGSolverParameters>(
 | 
			
		||||
        std::make_shared<SubgraphPreconditionerParameters>(builderParameters));
 | 
			
		||||
  } else if (method == "JACOBI") {
 | 
			
		||||
    pcg->preconditioner_ =
 | 
			
		||||
        std::make_shared<BlockJacobiPreconditionerParameters>();
 | 
			
		||||
    lm.iterativeParams = pcg;
 | 
			
		||||
    lm.iterativeParams = std::make_shared<PCGSolverParameters>(std::make_shared<BlockJacobiPreconditionerParameters>());
 | 
			
		||||
  } else if (method == "QR") {
 | 
			
		||||
    lm.setLinearSolverType("MULTIFRONTAL_QR");
 | 
			
		||||
  } else if (method == "CHOLESKY") {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue