43std::unique_ptr<OptimizationAlgorithmFactory>
54 const std::shared_ptr<AbstractOptimizationAlgorithmCreator>& c) {
55 const string& name = c->property().name;
56 CreatorList::iterator foundIt =
findSolver(name);
59 G2O_WARN(
"SOLVER FACTORY: Overwriting Solver creator {}", name);
66 const std::shared_ptr<AbstractOptimizationAlgorithmCreator>& c) {
67 const string& name = c->property().name;
68 CreatorList::iterator foundIt =
findSolver(name);
75 const std::string& name,
77 CreatorList::const_iterator foundIt =
findSolver(name);
79 solverProperty = (*foundIt)->property();
80 return (*foundIt)->construct();
82 G2O_WARN(
"SOLVER FACTORY: Unable to create solver {}", name);
87 std::unique_ptr<OptimizationAlgorithmFactory> aux;
92 size_t solverNameColumnLength = 0;
93 for (CreatorList::const_iterator it =
_creator.begin(); it !=
_creator.end();
95 solverNameColumnLength =
96 std::max(solverNameColumnLength, (*it)->property().name.size());
97 solverNameColumnLength += 4;
99 for (CreatorList::const_iterator it =
_creator.begin(); it !=
_creator.end();
103 for (
size_t i = sp.
name.size(); i < solverNameColumnLength; ++i) os <<
' ';
104 os << sp.
type <<
" \t" << sp.
desc << endl;
108OptimizationAlgorithmFactory::CreatorList::const_iterator
110 for (CreatorList::const_iterator it =
_creator.begin(); it !=
_creator.end();
113 if (sp.
name == name)
return it;
118OptimizationAlgorithmFactory::CreatorList::iterator
123 if (sp.
name == name)
return it;
AbstractOptimizationAlgorithmCreator(const OptimizationAlgorithmProperty &p)
create solvers based on their short name
void registerSolver(const std::shared_ptr< AbstractOptimizationAlgorithmCreator > &c)
CreatorList::const_iterator findSolver(const std::string &name) const
OptimizationAlgorithm * construct(const std::string &tag, OptimizationAlgorithmProperty &solverProperty) const
static OptimizationAlgorithmFactory * instance()
return the instance
static std::unique_ptr< OptimizationAlgorithmFactory > factoryInstance
static void destroy()
free the instance
void listSolvers(std::ostream &os) const
list the known solvers into a stream
void unregisterSolver(const std::shared_ptr< AbstractOptimizationAlgorithmCreator > &c)
Generic interface for a non-linear solver operating on a graph.
describe the properties of a solver
std::string type
type of solver, e.g., "CSparse Cholesky", "PCG"
std::string desc
short description of the solver
std::string name
name of the solver, e.g., var