Corrected scoped enum issue for non c++11 compilers

release/4.3a0
Andrew Melim 2014-11-17 11:57:22 -05:00
parent f00f8d1d7a
commit ffae14d42e
7 changed files with 24 additions and 25 deletions

View File

@ -87,7 +87,7 @@ int main(int argc, char** argv) {
// optimize using Levenberg-Marquardt optimization
LevenbergMarquardtParams params;
params.orderingType = Ordering::Type::METIS_;
params.orderingType = OrderingType::METIS;
LevenbergMarquardtOptimizer optimizer(graph, initial, params);
Values result = optimizer.optimize();
result.print("Final Result:\n");

View File

@ -54,7 +54,7 @@ namespace gtsam {
// If no Ordering provided, compute one and call this function again. We are guaranteed to
// have a VariableIndex already here because we computed one if needed in the previous 'else'
// block.
if (orderingType == Ordering::Type::METIS_)
if (orderingType == OrderingType::METIS)
return eliminateSequential(Ordering::METIS(asDerived()), function, variableIndex, orderingType);
else
return eliminateSequential(Ordering::COLAMD(*variableIndex), function, variableIndex, orderingType);
@ -92,7 +92,7 @@ namespace gtsam {
// If no Ordering provided, compute one and call this function again. We are guaranteed to
// have a VariableIndex already here because we computed one if needed in the previous 'else'
// block.
if (orderingType == Ordering::Type::METIS_)
if (orderingType == OrderingType::METIS)
return eliminateMultifrontal(Ordering::METIS(asDerived()), function, variableIndex, orderingType);
else
return eliminateMultifrontal(Ordering::COLAMD(*variableIndex), function, variableIndex, orderingType);

View File

@ -95,7 +95,7 @@ namespace gtsam {
typedef boost::optional<const VariableIndex&> OptionalVariableIndex;
/// Typedef for an optional ordering type
typedef boost::optional<Ordering::Type> OptionalOrderingType;
typedef boost::optional<OrderingType> OptionalOrderingType;
/** Do sequential elimination of all variables to produce a Bayes net. If an ordering is not
* provided, the ordering provided by COLAMD will be used.
@ -107,7 +107,7 @@ namespace gtsam {
*
* <b> Example - METIS ordering for elimination
* \code
* boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(Ordering::Type::METIS_);
* boost::shared_ptr<GaussianBayesNet> result = graph.eliminateSequential(OrderingType::METIS);
*
* <b> Example - Full QR elimination in specified order:
* \code

View File

@ -29,6 +29,11 @@
#include <gtsam/inference/FactorGraph.h>
namespace gtsam {
enum OrderingType {
COLAMD, METIS, CUSTOM
};
class Ordering : public std::vector<Key> {
protected:
typedef std::vector<Key> Base;
@ -37,12 +42,6 @@ namespace gtsam {
typedef Ordering This; ///< Typedef to this class
typedef boost::shared_ptr<This> shared_ptr; ///< shared_ptr to this class
/** See NonlinearOptimizer::orderingType */
enum Type {
COLAMD_, METIS_, CUSTOM_ // Add underscores to prevent declaration errors
};
/// Create an empty ordering
GTSAM_EXPORT Ordering() {}

View File

@ -341,7 +341,7 @@ void LevenbergMarquardtOptimizer::iterate() {
LevenbergMarquardtParams LevenbergMarquardtOptimizer::ensureHasOrdering(
LevenbergMarquardtParams params, const NonlinearFactorGraph& graph) const {
if (!params.ordering){
if (params.orderingType = Ordering::Type::METIS_)
if (params.orderingType = OrderingType::METIS)
params.ordering = Ordering::METIS(graph);
else
params.ordering = Ordering::COLAMD(graph);

View File

@ -109,10 +109,10 @@ void NonlinearOptimizerParams::print(const std::string& str) const {
}
switch (orderingType){
case Ordering::Type::COLAMD_:
case OrderingType::COLAMD:
std::cout << " ordering: COLAMD\n";
break;
case Ordering::Type::METIS_:
case OrderingType::METIS:
std::cout << " ordering: METIS\n";
break;
default:
@ -165,11 +165,11 @@ NonlinearOptimizerParams::LinearSolverType NonlinearOptimizerParams::linearSolve
}
/* ************************************************************************* */
std::string NonlinearOptimizerParams::orderingTypeTranslator(Ordering::Type type) const{
std::string NonlinearOptimizerParams::orderingTypeTranslator(OrderingType type) const{
switch (type) {
case Ordering::Type::METIS_:
case OrderingType::METIS:
return "METIS";
case Ordering::Type::COLAMD_:
case OrderingType::COLAMD:
return "COLAMD";
default:
if (ordering)
@ -181,11 +181,11 @@ std::string NonlinearOptimizerParams::orderingTypeTranslator(Ordering::Type type
}
/* ************************************************************************* */
Ordering::Type NonlinearOptimizerParams::orderingTypeTranslator(const std::string& type) const{
OrderingType NonlinearOptimizerParams::orderingTypeTranslator(const std::string& type) const{
if (type == "METIS")
return Ordering::Type::METIS_;
return OrderingType::METIS;
if (type == "COLAMD")
return Ordering::Type::COLAMD_;
return OrderingType::COLAMD;
throw std::invalid_argument(
"Invalid ordering type: You must provide an ordering for a custom ordering type. See setOrdering");
}

View File

@ -43,11 +43,11 @@ public:
double absoluteErrorTol; ///< The maximum absolute error decrease to stop iterating (default 1e-5)
double errorTol; ///< The maximum total error to stop iterating (default 0.0)
Verbosity verbosity; ///< The printing verbosity during optimization (default SILENT)
Ordering::Type orderingType; ///< The method of ordering use during variable elimination (default COLAMD)
OrderingType orderingType; ///< The method of ordering use during variable elimination (default COLAMD)
NonlinearOptimizerParams() :
maxIterations(100), relativeErrorTol(1e-5), absoluteErrorTol(1e-5), errorTol(
0.0), verbosity(SILENT), linearSolverType(MULTIFRONTAL_CHOLESKY), orderingType(Ordering::Type::COLAMD_) {
0.0), verbosity(SILENT), linearSolverType(MULTIFRONTAL_CHOLESKY), orderingType(COLAMD) {
}
virtual ~NonlinearOptimizerParams() {
@ -154,7 +154,7 @@ public:
void setOrdering(const Ordering& ordering) {
this->ordering = ordering;
this->orderingType = Ordering::Type::CUSTOM_;
this->orderingType = OrderingType::CUSTOM;
}
std::string getOrderingType() const {
@ -171,9 +171,9 @@ private:
LinearSolverType linearSolverTranslator(const std::string& linearSolverType) const;
std::string orderingTypeTranslator(Ordering::Type type) const;
std::string orderingTypeTranslator(OrderingType type) const;
Ordering::Type orderingTypeTranslator(const std::string& type) const;
OrderingType orderingTypeTranslator(const std::string& type) const;
};