14 #ifndef OR_TOOLS_FLATZINC_MODEL_H_
15 #define OR_TOOLS_FLATZINC_MODEL_H_
21 #include "absl/container/flat_hash_map.h"
55 static Domain Interval(int64_t included_min, int64_t included_max);
74 int64_t
Value()
const;
120 bool Merge(
const std::string& other_name,
const Domain& other_domain,
121 bool other_temporary);
173 int64_t
Value()
const;
182 int64_t
ValueAt(
int pos)
const;
256 std::vector<Annotation> args);
286 Bounds(int64_t min_value_, int64_t max_value_)
301 const std::string&
name, std::vector<Bounds>
bounds,
320 : name_(
name), objective_(nullptr), maximize_(true) {}
331 void AddConstraint(
const std::string&
id, std::vector<Argument> arguments,
333 void AddConstraint(
const std::string&
id, std::vector<Argument> arguments);
349 const std::vector<IntegerVariable*>&
variables()
const {
return variables_; }
350 const std::vector<Constraint*>&
constraints()
const {
return constraints_; }
352 return search_annotations_;
359 const std::vector<SolutionOutputSpecs>&
output()
const {
return output_; }
372 const std::string&
name()
const {
return name_; }
375 const std::string name_;
378 std::vector<IntegerVariable*> variables_;
381 std::vector<Constraint*> constraints_;
386 std::vector<Annotation> search_annotations_;
387 std::vector<SolutionOutputSpecs> output_;
395 : model_(
model), logger_(logger) {}
397 return constraints_per_variables_[
var].size();
405 std::map<std::string, std::vector<Constraint*>> constraints_per_type_;
406 absl::flat_hash_map<const IntegerVariable*, std::vector<Constraint*>>
407 constraints_per_variables_;
util::MutableVectorIteration< Annotation > mutable_search_annotations()
IntegerVariable * AddVariable(const std::string &name, const Domain &domain, bool defined)
util::MutableVectorIteration< SolutionOutputSpecs > mutable_output()
Model(const std::string &name)
IntegerVariable * AddConstant(int64_t value)
void Satisfy(std::vector< Annotation > search_annotations)
const std::vector< Constraint * > & constraints() const
IntegerVariable * objective() const
void Maximize(IntegerVariable *obj, std::vector< Annotation > search_annotations)
std::string DebugString() const
const std::vector< Annotation > & search_annotations() const
void AddOutput(SolutionOutputSpecs output)
const std::vector< SolutionOutputSpecs > & output() const
void SetObjective(IntegerVariable *obj)
void AddConstraint(const std::string &id, std::vector< Argument > arguments, bool is_domain)
void Minimize(IntegerVariable *obj, std::vector< Annotation > search_annotations)
const std::vector< IntegerVariable * > & variables() const
bool IsInconsistent() const
const std::string & name() const
void PrintStatistics() const
ModelStatistics(const Model &model, SolverLogger *logger)
int NumVariableOccurrences(IntegerVariable *var)
void FlattenAnnotations(const Annotation &ann, std::vector< Annotation > *out)
Collection of objects used to extend the Constraint Solver library.
static Annotation IntegerValue(int64_t value)
std::vector< IntegerVariable * > variables
static Annotation Variable(IntegerVariable *const var)
std::string DebugString() const
static Annotation FunctionCall(const std::string &id)
static Annotation AnnotationList(std::vector< Annotation > list)
static Annotation String(const std::string &str)
static Annotation Identifier(const std::string &id)
bool IsFunctionCallWithIdentifier(const std::string &identifier) const
std::vector< Annotation > annotations
static Annotation Interval(int64_t interval_min, int64_t interval_max)
static Annotation Empty()
void AppendAllIntegerVariables(std::vector< IntegerVariable * > *vars) const
static Annotation FunctionCallWithArguments(const std::string &id, std::vector< Annotation > args)
static Annotation VariableList(std::vector< IntegerVariable * > variables)
IntegerVariable * Var() const
static Argument DomainList(std::vector< Domain > domains)
std::vector< IntegerVariable * > variables
bool Contains(int64_t value) const
static Argument IntegerList(std::vector< int64_t > values)
IntegerVariable * VarAt(int pos) const
static Argument VoidArgument()
static Argument IntVarRefArray(std::vector< IntegerVariable * > vars)
static Argument IntegerValue(int64_t value)
static Argument Interval(int64_t imin, int64_t imax)
std::string DebugString() const
std::vector< Domain > domains
std::vector< int64_t > values
int64_t ValueAt(int pos) const
static Argument IntVarRef(IntegerVariable *const var)
bool IsArrayOfValues() const
static Argument FromDomain(const Domain &domain)
Constraint(const std::string &t, std::vector< Argument > args, bool strong_propag)
bool presolve_propagation_done
void RemoveArg(int arg_pos)
std::string DebugString() const
std::vector< Argument > arguments
static Domain IntegerValue(int64_t value)
static Domain EmptyDomain()
bool Contains(int64_t value) const
bool OverlapsDomain(const Domain &other) const
static Domain SetOfAllInt64()
bool IntersectWithSingleton(int64_t value)
static Domain SetOfInterval(int64_t included_min, int64_t included_max)
static Domain IntegerList(std::vector< int64_t > values)
std::string DebugString() const
bool IntersectWithInterval(int64_t interval_min, int64_t interval_max)
bool IntersectWithDomain(const Domain &domain)
bool OverlapsIntInterval(int64_t lb, int64_t ub) const
static Domain SetOfIntegerValue(int64_t value)
bool OverlapsIntList(const std::vector< int64_t > &vec) const
static Domain Interval(int64_t included_min, int64_t included_max)
std::vector< int64_t > values
static Domain SetOfBoolean()
static Domain SetOfIntegerList(std::vector< int64_t > values)
bool IntersectWithListOfIntegers(const std::vector< int64_t > &integers)
bool RemoveValue(int64_t value)
std::string DebugString() const
bool Merge(const std::string &other_name, const Domain &other_domain, bool other_temporary)
Bounds(int64_t min_value_, int64_t max_value_)
std::string DebugString() const
static SolutionOutputSpecs MultiDimensionalArray(const std::string &name, std::vector< Bounds > bounds, std::vector< IntegerVariable * > flat_variables, bool display_as_boolean)
std::vector< IntegerVariable * > flat_variables
static SolutionOutputSpecs VoidOutput()
std::string DebugString() const
IntegerVariable * variable
std::vector< Bounds > bounds
static SolutionOutputSpecs SingleVariable(const std::string &name, IntegerVariable *variable, bool display_as_boolean)