20#include "absl/container/flat_hash_map.h"
21#include "absl/log/check.h"
33 type_name_ = type_name;
38 integer_argument_[arg_name] =
value;
42 const std::string& arg_name,
const std::vector<int64_t>& values) {
43 integer_array_argument_[arg_name] = values;
48 std::pair<std::string, IntTupleSet> to_insert =
49 std::make_pair(arg_name, values);
50 matrix_argument_.insert(to_insert);
55 integer_expression_argument_[arg_name] = expr;
59 const std::string& arg_name,
const std::vector<IntVar*>& vars) {
60 integer_variable_array_argument_[arg_name] = vars;
65 interval_argument_[arg_name] =
var;
69 const std::string& arg_name,
const std::vector<IntervalVar*>& vars) {
70 interval_array_argument_[arg_name] = vars;
75 sequence_argument_[arg_name] =
var;
79 const std::string& arg_name,
const std::vector<SequenceVar*>& vars) {
80 sequence_array_argument_[arg_name] = vars;
84 const std::string& arg_name)
const {
85 return integer_expression_argument_.contains(arg_name);
89 const std::string& arg_name)
const {
90 return integer_variable_array_argument_.contains(arg_name);
94 const std::string& arg_name, int64_t def)
const {
99 const std::string& arg_name)
const {
104 const std::string& arg_name)
const {
109 const std::string& arg_name)
const {
113const std::vector<IntVar*>&
115 const std::string& arg_name)
const {
116 return gtl::FindOrDie(integer_variable_array_argument_, arg_name);
120 const std::string& arg_name)
const {
166 const std::string& operation,
173 const std::string& operation,
176 if (delegate !=
nullptr) {
193 const std::string& arg_name,
const std::vector<int64_t>& values) {
210 const std::string& arg_name,
const std::vector<IntVar*>& arguments) {
212 for (
int i = 0; i < arguments.size(); ++i) {
213 arguments[i]->Accept(
this);
225 const std::string& arg_name,
const std::vector<IntervalVar*>& arguments) {
227 for (
int i = 0; i < arguments.size(); ++i) {
228 arguments[i]->Accept(
this);
240 const std::string& arg_name,
const std::vector<SequenceVar*>& arguments) {
242 for (
int i = 0; i < arguments.size(); ++i) {
243 arguments[i]->Accept(
this);
252 CHECK(!holders_.empty());
253 delete holders_.back();
258 CHECK(!holders_.empty());
259 return holders_.back();
Argument Holder: useful when visiting a model.
const IntTupleSet & FindIntegerMatrixArgumentOrDie(const std::string &arg_name) const
void SetIntegerVariableArrayArgument(const std::string &arg_name, const std::vector< IntVar * > &vars)
void SetIntervalArgument(const std::string &arg_name, IntervalVar *var)
void SetIntervalArrayArgument(const std::string &arg_name, const std::vector< IntervalVar * > &vars)
IntExpr * FindIntegerExpressionArgumentOrDie(const std::string &arg_name) const
void SetTypeName(const std::string &type_name)
bool HasIntegerExpressionArgument(const std::string &arg_name) const
Checks if arguments exist.
void SetIntegerArrayArgument(const std::string &arg_name, const std::vector< int64_t > &values)
const std::vector< IntVar * > & FindIntegerVariableArrayArgumentOrDie(const std::string &arg_name) const
void SetSequenceArgument(const std::string &arg_name, SequenceVar *var)
const std::string & TypeName() const
Type of the argument.
void SetIntegerMatrixArgument(const std::string &arg_name, const IntTupleSet &values)
bool HasIntegerVariableArrayArgument(const std::string &arg_name) const
const std::vector< int64_t > & FindIntegerArrayArgumentOrDie(const std::string &arg_name) const
int64_t FindIntegerArgumentOrDie(const std::string &arg_name) const
void SetIntegerArgument(const std::string &arg_name, int64_t value)
Setters.
void SetIntegerExpressionArgument(const std::string &arg_name, IntExpr *expr)
void SetSequenceArrayArgument(const std::string &arg_name, const std::vector< SequenceVar * > &vars)
int64_t FindIntegerArgumentWithDefault(const std::string &arg_name, int64_t def) const
Getters.
virtual void Accept(ModelVisitor *visitor) const
Accepts the given visitor.
--— Main IntTupleSet class --—
void Accept(ModelVisitor *visitor) const override
Accepts the given visitor.
virtual void Accept(ModelVisitor *visitor) const =0
Accepts the given visitor.
void VisitIntervalArgument(const std::string &arg_name, IntervalVar *argument) override
Visit interval argument.
void VisitIntervalArrayArgument(const std::string &arg_name, const std::vector< IntervalVar * > &arguments) override
void VisitIntervalVariable(const IntervalVar *variable, const std::string &operation, int64_t value, IntervalVar *delegate) override
void VisitIntegerArgument(const std::string &arg_name, int64_t value) override
Integer arguments.
void VisitIntegerArrayArgument(const std::string &arg_name, const std::vector< int64_t > &values) override
void VisitSequenceVariable(const SequenceVar *variable) override
void BeginVisitIntegerExpression(const std::string &type_name, const IntExpr *expr) override
void VisitSequenceArgument(const std::string &arg_name, SequenceVar *argument) override
Visit sequence argument.
void VisitSequenceArrayArgument(const std::string &arg_name, const std::vector< SequenceVar * > &arguments) override
void VisitIntegerVariable(const IntVar *variable, IntExpr *delegate) override
void VisitIntegerVariableArrayArgument(const std::string &arg_name, const std::vector< IntVar * > &arguments) override
ModelParser()
-------— ModelParser ------—
void BeginVisitModel(const std::string &solver_name) override
Header/footers.
void BeginVisitConstraint(const std::string &type_name, const Constraint *constraint) override
void PushArgumentHolder()
void EndVisitConstraint(const std::string &type_name, const Constraint *constraint) override
ArgumentHolder * Top() const
void VisitIntegerMatrixArgument(const std::string &arg_name, const IntTupleSet &values) override
void EndVisitIntegerExpression(const std::string &type_name, const IntExpr *expr) override
void EndVisitModel(const std::string &solver_name) override
void VisitIntegerExpressionArgument(const std::string &arg_name, IntExpr *argument) override
Variables.
virtual void Accept(ModelVisitor *visitor) const
Accepts the given visitor.
const Collection::value_type::second_type & FindOrDie(const Collection &collection, const typename Collection::value_type::first_type &key)
const MapUtilMappedT< Collection > & FindWithDefault(const Collection &collection, const KeyType &key, const MapUtilMappedT< Collection > &value)
In SWIG mode, we don't want anything besides these top-level includes.