14 #ifndef OR_TOOLS_FLATZINC_MODEL_H_
15 #define OR_TOOLS_FLATZINC_MODEL_H_
23 #include "absl/container/flat_hash_map.h"
24 #include "absl/strings/string_view.h"
58 static Domain Interval(int64_t included_min, int64_t included_max);
81 int64_t
Value()
const;
133 bool Merge(absl::string_view other_name,
const Domain& other_domain,
134 bool other_temporary);
152 Variable(absl::string_view name_,
const Domain& domain_,
bool temporary_);
191 int64_t
Value()
const;
200 int64_t
ValueAt(
int pos)
const;
280 std::vector<Annotation> args);
312 Bounds(int64_t min_value_, int64_t max_value_)
327 absl::string_view
name, std::vector<Bounds>
bounds,
346 : name_(
name), objective_(nullptr), maximize_(true) {}
358 void AddConstraint(absl::string_view
id, std::vector<Argument> arguments,
360 void AddConstraint(absl::string_view
id, std::vector<Argument> arguments);
374 const std::vector<Variable*>&
variables()
const {
return variables_; }
375 const std::vector<Constraint*>&
constraints()
const {
return constraints_; }
377 return search_annotations_;
384 const std::vector<SolutionOutputSpecs>&
output()
const {
return output_; }
397 const std::string&
name()
const {
return name_; }
400 const std::string name_;
403 std::vector<Variable*> variables_;
406 std::vector<Constraint*> constraints_;
411 std::vector<Annotation> search_annotations_;
412 std::vector<SolutionOutputSpecs> output_;
420 : model_(
model), logger_(logger) {}
422 return constraints_per_variables_[
var].size();
430 std::map<std::string, std::vector<Constraint*>> constraints_per_type_;
431 absl::flat_hash_map<const Variable*, std::vector<Constraint*>>
432 constraints_per_variables_;
Model(absl::string_view name)
void AddConstraint(absl::string_view id, std::vector< Argument > arguments, bool is_domain)
util::MutableVectorIteration< Annotation > mutable_search_annotations()
util::MutableVectorIteration< SolutionOutputSpecs > mutable_output()
Variable * objective() const
void SetObjective(Variable *obj)
Variable * AddConstant(int64_t value)
void Satisfy(std::vector< Annotation > search_annotations)
const std::vector< Constraint * > & constraints() const
std::string DebugString() const
const std::vector< Annotation > & search_annotations() const
void AddOutput(SolutionOutputSpecs output)
const std::vector< SolutionOutputSpecs > & output() const
Variable * AddVariable(absl::string_view name, const Domain &domain, bool defined)
void Maximize(Variable *obj, std::vector< Annotation > search_annotations)
bool IsInconsistent() const
const std::string & name() const
const std::vector< Variable * > & variables() const
void Minimize(Variable *obj, std::vector< Annotation > search_annotations)
Variable * AddFloatConstant(double value)
int NumVariableOccurrences(Variable *var)
void PrintStatistics() const
ModelStatistics(const Model &model, SolverLogger *logger)
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)
void AppendAllVariables(std::vector< Variable * > *vars) const
static Annotation String(absl::string_view str)
static Annotation FunctionCallWithArguments(absl::string_view id, std::vector< Annotation > args)
bool IsFunctionCallWithIdentifier(absl::string_view identifier) const
std::string DebugString() const
static Annotation FunctionCall(absl::string_view id)
static Annotation AnnotationList(std::vector< Annotation > list)
std::vector< Variable * > variables
std::vector< Annotation > annotations
static Annotation Interval(int64_t interval_min, int64_t interval_max)
static Annotation VarRefArray(std::vector< Variable * > variables)
static Annotation VarRef(Variable *const var)
static Annotation Empty()
std::vector< int64_t > values
static Annotation Identifier(absl::string_view id)
static Annotation IntegerList(const std::vector< int64_t > &values)
static Argument FloatInterval(double lb, double ub)
static Argument DomainList(std::vector< Domain > domains)
Variable * VarAt(int pos) const
static Argument VarRef(Variable *const var)
std::vector< double > floats
bool Contains(int64_t value) const
static Argument IntegerList(std::vector< int64_t > values)
static Argument VoidArgument()
static Argument VarRefArray(std::vector< Variable * > vars)
static Argument IntegerValue(int64_t value)
static Argument Interval(int64_t imin, int64_t imax)
std::string DebugString() const
std::vector< Variable * > variables
static Argument FloatValue(double value)
std::vector< Domain > domains
bool HasOneValueAt(int pos) const
std::vector< int64_t > values
int64_t ValueAt(int pos) const
static Argument FloatList(std::vector< double > floats)
bool IsArrayOfValues() const
static Argument FromDomain(const Domain &domain)
bool presolve_propagation_done
void RemoveArg(int arg_pos)
std::string DebugString() const
std::vector< Argument > arguments
Constraint(absl::string_view t, std::vector< Argument > args, bool strong_propag)
static Domain IntegerValue(int64_t value)
static Domain EmptyDomain()
bool Contains(int64_t value) const
bool SetEmptyFloatDomain()
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 IntersectWithFloatDomain(const Domain &domain)
bool IntersectWithDomain(const Domain &domain)
std::vector< double > float_values
static Domain FloatInterval(double lb, double ub)
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)
static Domain FloatValue(double value)
bool IntersectWithListOfIntegers(const std::vector< int64_t > &integers)
static Domain AllFloats()
bool RemoveValue(int64_t value)
Bounds(int64_t min_value_, int64_t max_value_)
std::string DebugString() const
static SolutionOutputSpecs MultiDimensionalArray(absl::string_view name, std::vector< Bounds > bounds, std::vector< Variable * > flat_variables, bool display_as_boolean)
static SolutionOutputSpecs VoidOutput()
std::string DebugString() const
std::vector< Variable * > flat_variables
std::vector< Bounds > bounds
static SolutionOutputSpecs SingleVariable(absl::string_view name, Variable *variable, bool display_as_boolean)
std::string DebugString() const
bool Merge(absl::string_view other_name, const Domain &other_domain, bool other_temporary)