/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file QPSVisitor.h * @brief * @author Ivan Dario Jimenez * @date 3/5/16 */ #pragma once #include #include #include #include #include #include #include #include #include namespace gtsam { /** * As the parser reads a file, it call functions in this visitor. This visitor in turn stores what the parser has read * in a way that can be later used to build the full QP problem in the file. */ class QPSVisitor { private: typedef std::unordered_map coefficient_v; typedef std::unordered_map constraint_v; std::unordered_map row_to_constraint_v; // Maps QPS ROWS to Variable-Matrix pairs constraint_v E; // Equalities constraint_v IG;// Inequalities >= constraint_v IL;// Inequalities <= unsigned int numVariables; std::unordered_map b; // maps from constraint name to b value for Ax = b equality constraints std::unordered_map ranges; // Inequalities can be specified as ranges on a variable std::unordered_map g; // linear term of quadratic cost std::unordered_map varname_to_key; // Variable QPS string name to key std::unordered_map > H; // H from hessian double f; // Constant term of quadratic cost std::string obj_name; // the objective function has a name in the QPS std::string name_; // the quadratic program has a name in the QPS std::unordered_map up; // Upper Bound constraints on variable where X < MAX std::unordered_map lo; // Lower Bound constraints on variable where MIN < X std::unordered_map fx; // Equalities specified as FX in BOUNDS part of QPS std::vector Free; // Variables can be specified as Free (to which no constraints apply) const bool debug = false; public: QPSVisitor() : numVariables(1) { } void setName( boost::fusion::vector, std::vector, std::vector> const & name); void addColumn( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector> const & vars); void addColumnDouble( boost::fusion::vector, std::vector, std::vector, std::vector, double, std::vector, std::vector, std::vector, double> const & vars); void addRHS( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector> const & vars); void addRHSDouble( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector, std::vector, std::vector, double> const & vars); void addRangeSingle( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector> const & vars); void addRangeDouble( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector, std::vector, std::vector, double> const & vars); void addRow( boost::fusion::vector, char, std::vector, std::vector, std::vector> const & vars); void addBound( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector, double> const & vars); void addBoundFr( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, std::vector, std::vector> const & vars); void addQuadTerm( boost::fusion::vector, std::vector, std::vector, std::vector, std::vector, double, std::vector> const & vars); QP makeQP(); } ; }