15#include <unordered_map>
18#include "dlinear/libs/libgmp.h"
19#include "dlinear/parser/Driver.h"
20#include "dlinear/parser/mps/BoundType.h"
21#include "dlinear/parser/mps/Sense.h"
22#include "dlinear/parser/mps/scanner.h"
23#include "dlinear/solver/Context.h"
24#include "dlinear/symbolic/symbolic.h"
47 static void error(
const location &l,
const std::string &m);
102 void AddColumn(
const std::string &column,
const std::string &row, mpq_class value);
121 void AddRhs(
const std::string &rhs,
const std::string &row, mpq_class value);
147 void AddRange(
const std::string &rhs,
const std::string &row, mpq_class value);
164 void AddBound(
BoundType type,
const std::string &bound,
const std::string &column, mpq_class value);
181 void AddBound(
BoundType type,
const std::string &bound,
const std::string &column);
214 void ToSmt2(std::ostream &os)
const;
245 std::unordered_map<std::string, std::map<Expression, mpq_class>>
rows_;
247 std::unordered_map<std::string, Variable>
columns_;
252 std::map<std::string, Formula>
rhs_;
Context class that holds the set of constraints and provide Assert/Push/Pop/CheckSat functionalities.
The Driver is the base class for all the parsers.
const Context & context() const
Get read-only access to the enabled of the Driver.
The MpsDriver class brings together all components.
bool ParseStreamCore(std::istream &in) override
Parse the stream.
void AddRow(Sense sense, const std::string &row)
Add a row to the problem.
std::size_t n_assertions() const
Get read-only access to the number of assertions of the MpsDriver.
void ObjectiveSense(bool is_min)
Set the objective sense of the problem after having encountered the OBJSENSE section.
std::unordered_map< std::string, mpq_class > rhs_values_
The values of the hand side of the problem.
static void error(const location &l, const std::string &m)
Error handling with associated line number.
bool is_min_
True if the problem is a minimization problem.
std::string bound_name_
The name of the first bound found. Used if strict_mps_ is true.
bool is_min() const
Check whether the minimization is enabled.
std::map< std::string, Formula > bounds_
Assertions built by combining the columns and the bounds.
void ObjectiveName(const std::string &row)
Set the name of the objective row after having encountered the OBJNAME section.
void ToSmt2(std::ostream &os) const
Print the problem in the smt2 format.
std::string rhs_name_
The name of the first rhs found. Used if strict_mps_ is true.
std::string obj_row_
The name of the objective row.
bool strict_mps_
If true, the parser will check that all rhs, ranges and bounds have the same name.
MpsScanner * scanner_
The scanner producing the tokens for the parser.
bool strict_mps() const
Check whether the strict mps is enabled.
std::map< std::string, Formula > rhs_
Assertions built by combining the rows and the rhs.
void AddRange(const std::string &rhs, const std::string &row, mpq_class value)
Add a new row contraint based on the range.
std::unordered_map< std::string, Sense > row_senses_
The sense of each row.
void AddBound(BoundType type, const std::string &bound, const std::string &column, mpq_class value)
Add a bound to a variable (column).
void set_strict_mps(bool b)
Set the strict mps mode.
std::unordered_map< std::string, Variable > columns_
The columns of the problem. Contains the variables.
bool VerifyStrictBound(const std::string &bound)
If strict_mps_ is true, keeps track of the name of the first bound found.
void AddColumn(const std::string &column, const std::string &row, mpq_class value)
Add a column to the problem.
std::string problem_name_
The name of the problem. Used to name the context.
const std::string & problem_name() const
Get read-only access to the problem_name of the MpsDriver.
std::unordered_map< std::string, std::map< Expression, mpq_class > > rows_
The rows of the problem.
std::unordered_map< std::string, bool > skip_lower_bound_
True if there is no need to manually add the lb 0 <= V.
void End()
Called when the parser has reached the ENDATA section.
MpsScanner * scanner()
Get read-only access to the scanner of the MpsDriver.
bool VerifyStrictRhs(const std::string &rhs)
If strict_mps_ is true, keeps track of the name of the first rhs found.
void AddRhs(const std::string &rhs, const std::string &row, mpq_class value)
Add the right hand side of the row.
std::string & m_problem_name()
Get read-write access to the problem_name of the MpsDriver.
const std::string & obj_row() const
Get read-only access to the objective row name of the MpsDriver.
MpsScanner is a derived class to add some extra function to the scanner class.
Namespace for the MPS parser of the dlinear library.
Sense
Sense of a constraint row.