14#ifndef OR_TOOLS_FLATZINC_MODEL_H_
15#define OR_TOOLS_FLATZINC_MODEL_H_
21#include "absl/container/flat_hash_map.h"
22#include "absl/strings/string_view.h"
56 static Domain Interval(int64_t included_min, int64_t included_max);
79 int64_t
Value()
const;
131 bool Merge(absl::string_view other_name,
const Domain& other_domain,
132 bool other_temporary);
150 Variable(absl::string_view name_,
const Domain& domain_,
bool temporary_);
189 int64_t
Value()
const;
198 int64_t
ValueAt(
int pos)
const;
277 std::vector<Annotation> args);
307 Bounds(int64_t min_value_, int64_t max_value_)
322 absl::string_view
name, std::vector<Bounds>
bounds,
341 : name_(
name), objective_(nullptr), maximize_(true) {}
353 void AddConstraint(absl::string_view
id, std::vector<Argument> arguments,
355 void AddConstraint(
const std::string&
id, std::vector<Argument> arguments);
369 const std::vector<Variable*>&
variables()
const {
return variables_; }
370 const std::vector<Constraint*>&
constraints()
const {
return constraints_; }
372 return search_annotations_;
379 const std::vector<SolutionOutputSpecs>&
output()
const {
return output_; }
392 const std::string&
name()
const {
return name_; }
395 const std::string name_;
398 std::vector<Variable*> variables_;
401 std::vector<Constraint*> constraints_;
406 std::vector<Annotation> search_annotations_;
407 std::vector<SolutionOutputSpecs> output_;
415 : model_(
model), logger_(logger) {}
417 return constraints_per_variables_[
var].size();
425 std::map<std::string, std::vector<Constraint*>> constraints_per_type_;
426 absl::flat_hash_map<const Variable*, std::vector<Constraint*>>
427 constraints_per_variables_;
util::MutableVectorIteration< SolutionOutputSpecs > mutable_output()
Model(absl::string_view name)
void AddConstraint(absl::string_view id, std::vector< Argument > arguments, bool is_domain)
const std::string & name() const
const std::vector< Annotation > & search_annotations() const
const std::vector< SolutionOutputSpecs > & output() const
void SetObjective(Variable *obj)
Variable * AddConstant(int64_t value)
void Satisfy(std::vector< Annotation > search_annotations)
std::string DebugString() const
void AddOutput(SolutionOutputSpecs output)
util::MutableVectorIteration< Annotation > mutable_search_annotations()
Variable * AddVariable(absl::string_view name, const Domain &domain, bool defined)
Variable * objective() const
void Maximize(Variable *obj, std::vector< Annotation > search_annotations)
bool IsInconsistent() const
void Minimize(Variable *obj, std::vector< Annotation > search_annotations)
Variable * AddFloatConstant(double value)
const std::vector< Constraint * > & constraints() const
const std::vector< Variable * > & variables() const
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()
static Annotation Identifier(absl::string_view id)
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)