OR-Tools  8.1
flatzinc/model.h
Go to the documentation of this file.
1 // Copyright 2010-2018 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #ifndef OR_TOOLS_FLATZINC_MODEL_H_
15 #define OR_TOOLS_FLATZINC_MODEL_H_
16 
17 #include <map>
18 #include <string>
19 
20 #include "absl/container/flat_hash_map.h"
22 #include "ortools/base/logging.h"
25 
26 namespace operations_research {
27 namespace fz {
28 
29 struct Constraint;
30 class Model;
31 
32 // A domain represents the possible values of a variable, and its type
33 // (which carries display information, i.e. a Boolean will be displayed
34 // differently than an integer with domain {0, 1}).
35 // It can be:
36 // - an explicit list of all possible values, in which case is_interval is
37 // false. If the list is empty, then the domain is empty.
38 // - an interval, in which case is_interval is true and values.size() == 2,
39 // and the interval is [values[0], values[1]].
40 // - all integers, in which case values is empty, and is_interval is true.
41 // Note that semi-infinite intervals aren't supported.
42 // - a Boolean domain({ 0, 1 } with Boolean display tag).
43 // TODO(user): Rework domains, all int64 should be kintmin..kint64max.
44 // It is a bit tricky though as we must take care of overflows.
45 // If is_a_set is true, then this domain has a set semantics. For a set
46 // variable, any subset of the initial set of values is a valid assignment,
47 // instead of exactly one value.
48 struct Domain {
49  // The values will be sorted and duplicate values will be removed.
50  static Domain IntegerList(std::vector<int64> values);
51  static Domain AllInt64();
53  static Domain Interval(int64 included_min, int64 included_max);
54  static Domain Boolean();
55  static Domain SetOfIntegerList(std::vector<int64> values);
56  static Domain SetOfAllInt64();
58  static Domain SetOfInterval(int64 included_min, int64 included_max);
59  static Domain SetOfBoolean();
60  static Domain EmptyDomain();
61 
62  bool HasOneValue() const;
63  bool empty() const;
64 
65  // Returns the min of the domain.
66  int64 Min() const;
67 
68  // Returns the max of the domain.
69  int64 Max() const;
70 
71  // Returns the value of the domain. HasOneValue() must return true.
72  int64 Value() const;
73 
74  // Returns true if the domain is [kint64min..kint64max]
75  bool IsAllInt64() const;
76 
77  // Various inclusion tests on a domain.
78  bool Contains(int64 value) const;
79  bool OverlapsIntList(const std::vector<int64>& vec) const;
80  bool OverlapsIntInterval(int64 lb, int64 ub) const;
81  bool OverlapsDomain(const Domain& other) const;
82 
83  // All the following modifiers change the internal representation
84  // list to interval or interval to list.
86  bool IntersectWithDomain(const Domain& domain);
87  bool IntersectWithInterval(int64 interval_min, int64 interval_max);
88  bool IntersectWithListOfIntegers(const std::vector<int64>& integers);
89 
90  // Returns true iff the value did belong to the domain, and was removed.
91  // Try to remove the value. It returns true if it was actually removed.
92  // If the value is inside a large interval, then it will not be removed.
93  bool RemoveValue(int64 value);
94  std::string DebugString() const;
95 
96  // These should never be modified from outside the class.
97  std::vector<int64> values;
100  // Indicates if the domain was created as a set domain.
101  bool is_a_set;
102 };
103 
104 // An int var is a name with a domain of possible values, along with
105 // some tags. Typically, an IntegerVariable is on the heap, and owned by the
106 // global Model object.
108  // This method tries to unify two variables. This can happen during the
109  // parsing of the model or during presolve. This is possible if at least one
110  // of the two variable is not the target of a constraint. (otherwise it
111  // returns false).
112  // The semantic of the merge is the following:
113  // - the resulting domain is the intersection of the two domains.
114  // - if one variable is not temporary, the result is not temporary.
115  // - if one variable is temporary, the name is the name of the other
116  // variable. If both variables are temporary or both variables are not
117  // temporary, the name is chosen arbitrarily between the two names.
118  bool Merge(const std::string& other_name, const Domain& other_domain,
119  bool other_temporary);
120 
121  std::string DebugString() const;
122 
123  std::string name;
125  // Indicates if the variable is a temporary variable created when flattening
126  // the model. For instance, if you write x == y * z + y, then it will be
127  // expanded into y * z == t and x = t + y. And t will be a temporary variable.
128  bool temporary : 1;
129  // Indicates if the variable should be created at all. A temporary variable
130  // can be unreachable in the active model if nobody uses it. In that case,
131  // there is no need to create it.
132  bool active : 1;
133 
134  private:
135  friend class Model;
136 
137  IntegerVariable(const std::string& name_, const Domain& domain_,
138  bool temporary_);
139 };
140 
141 // An argument is either an integer value, an integer domain, a
142 // reference to a variable, or an array of variable references.
143 struct Argument {
144  enum Type {
152  };
153 
155  static Argument Interval(int64 imin, int64 imax);
156  static Argument IntegerList(std::vector<int64> values);
157  static Argument DomainList(std::vector<Domain> domains);
158  static Argument IntVarRef(IntegerVariable* const var);
159  static Argument IntVarRefArray(std::vector<IntegerVariable*> vars);
160  static Argument VoidArgument();
161  static Argument FromDomain(const Domain& domain);
162 
163  std::string DebugString() const;
164 
165  // Returns true if the argument is a variable.
166  bool IsVariable() const;
167  // Returns true if the argument has only one value (integer value, integer
168  // list of size 1, interval of size 1, or variable with a singleton domain).
169  bool HasOneValue() const;
170  // Returns the value of the argument. Does DCHECK(HasOneValue()).
171  int64 Value() const;
172  // Returns true if it an integer list, or an array of integer
173  // variables (or domain) each having only one value.
174  bool IsArrayOfValues() const;
175  // Returns true if the argument is an integer value, an integer
176  // list, or an interval, and it contains the given value.
177  // It will check that the type is actually one of the above.
178  bool Contains(int64 value) const;
179  // Returns the value of the pos-th element.
180  int64 ValueAt(int pos) const;
181  // Returns the variable inside the argument if the type is INT_VAR_REF,
182  // or nullptr otherwise.
183  IntegerVariable* Var() const;
184  // Returns the variable at position pos inside the argument if the type is
185  // INT_VAR_REF_ARRAY or nullptr otherwise.
186  IntegerVariable* VarAt(int pos) const;
187 
189  std::vector<int64> values;
190  std::vector<IntegerVariable*> variables;
191  std::vector<Domain> domains;
192 };
193 
194 // A constraint has a type, some arguments, and a few tags. Typically, a
195 // Constraint is on the heap, and owned by the global Model object.
196 struct Constraint {
197  Constraint(const std::string& t, std::vector<Argument> args,
198  bool strong_propag)
199  : type(t),
200  arguments(std::move(args)),
201  strong_propagation(strong_propag),
202  active(true),
203  presolve_propagation_done(false) {}
204 
205  std::string DebugString() const;
206 
207  // Helpers to be used during presolve.
208  void MarkAsInactive();
209  // Helper method to remove one argument.
210  void RemoveArg(int arg_pos);
211  // Set as a False constraint.
212  void SetAsFalse();
213 
214  // The flatzinc type of the constraint (i.e. "int_eq" for integer equality)
215  // stored as a string.
216  std::string type;
217  std::vector<Argument> arguments;
218  // Is true if the constraint should use the strongest level of propagation.
219  // This is a hint in the model. For instance, in the AllDifferent constraint,
220  // there are different algorithms to propagate with different pruning/speed
221  // ratios. When strong_propagation is true, one should use, if possible, the
222  // algorithm with the strongest pruning.
224  // Indicates if the constraint is active. Presolve can make it inactive by
225  // propagating it, or by regrouping it. Once a constraint is inactive, it is
226  // logically removed from the model, it is not extracted, and it is ignored by
227  // presolve.
228  bool active : 1;
229 
230  // Indicates if presolve has finished propagating this constraint.
232 };
233 
234 // An annotation is a set of information. It has two use cases. One during
235 // parsing to store intermediate information on model objects (i.e. the defines
236 // part of a constraint). The other use case is to store all search
237 // declarations. This persists after model parsing.
238 struct Annotation {
239  enum Type {
248  };
249 
250  static Annotation Empty();
251  static Annotation AnnotationList(std::vector<Annotation> list);
252  static Annotation Identifier(const std::string& id);
253  static Annotation FunctionCallWithArguments(const std::string& id,
254  std::vector<Annotation> args);
255  static Annotation FunctionCall(const std::string& id);
258  static Annotation Variable(IntegerVariable* const var);
259  static Annotation VariableList(std::vector<IntegerVariable*> variables);
260  static Annotation String(const std::string& str);
261 
262  std::string DebugString() const;
263  bool IsFunctionCallWithIdentifier(const std::string& identifier) const {
264  return type == FUNCTION_CALL && id == identifier;
265  }
266  // Copy all the variable references contained in this annotation (and its
267  // children). Depending on the type of this annotation, there can be zero,
268  // one, or several.
269  void AppendAllIntegerVariables(std::vector<IntegerVariable*>* vars) const;
270 
274  std::string id;
275  std::vector<Annotation> annotations;
276  std::vector<IntegerVariable*> variables;
277  std::string string_value;
278 };
279 
280 // Information on what should be displayed when a solution is found.
281 // It follows the flatzinc specification (www.minizinc.org).
283  struct Bounds {
284  Bounds(int64 min_value_, int64 max_value_)
285  : min_value(min_value_), max_value(max_value_) {}
286  std::string DebugString() const;
289  };
290 
291  // Will output: name = <variable value>.
292  static SolutionOutputSpecs SingleVariable(const std::string& name,
294  bool display_as_boolean);
295  // Will output (for example):
296  // name = array2d(min1..max1, min2..max2, [list of variable values])
297  // for a 2d array (bounds.size() == 2).
299  const std::string& name, std::vector<Bounds> bounds,
300  std::vector<IntegerVariable*> flat_variables, bool display_as_boolean);
301  // Empty output.
303 
304  std::string DebugString() const;
305 
306  std::string name;
308  std::vector<IntegerVariable*> flat_variables;
309  // These are the starts and ends of intervals for displaying (potentially
310  // multi-dimensional) arrays.
311  std::vector<Bounds> bounds;
313 };
314 
315 class Model {
316  public:
317  explicit Model(const std::string& name)
318  : name_(name), objective_(nullptr), maximize_(true) {}
319  ~Model();
320 
321  // ----- Builder methods -----
322 
323  // The objects returned by AddVariable(), AddConstant(), and AddConstraint()
324  // are owned by the model and will remain live for its lifetime.
325  IntegerVariable* AddVariable(const std::string& name, const Domain& domain,
326  bool defined);
328  // Creates and add a constraint to the model.
329  void AddConstraint(const std::string& id, std::vector<Argument> arguments,
330  bool is_domain);
331  void AddConstraint(const std::string& id, std::vector<Argument> arguments);
333 
334  // Set the search annotations and the objective: either simply satisfy the
335  // problem, or minimize or maximize the given variable (which must have been
336  // added with AddVariable() already).
337  void Satisfy(std::vector<Annotation> search_annotations);
338  void Minimize(IntegerVariable* obj,
339  std::vector<Annotation> search_annotations);
340  void Maximize(IntegerVariable* obj,
341  std::vector<Annotation> search_annotations);
342 
343  bool IsInconsistent() const;
344 
345  // ----- Accessors and mutators -----
346 
347  const std::vector<IntegerVariable*>& variables() const { return variables_; }
348  const std::vector<Constraint*>& constraints() const { return constraints_; }
349  const std::vector<Annotation>& search_annotations() const {
350  return search_annotations_;
351  }
352 #if !defined(SWIG)
354  return util::MutableVectorIteration<Annotation>(&search_annotations_);
355  }
356 #endif
357  const std::vector<SolutionOutputSpecs>& output() const { return output_; }
358 #if !defined(SWIG)
361  }
362 #endif
363  bool maximize() const { return maximize_; }
364  IntegerVariable* objective() const { return objective_; }
365  void SetObjective(IntegerVariable* obj) { objective_ = obj; }
366 
367  // Services.
368  std::string DebugString() const;
369 
370  const std::string& name() const { return name_; }
371 
372  private:
373  const std::string name_;
374  // owned.
375  // TODO(user): use unique_ptr
376  std::vector<IntegerVariable*> variables_;
377  // owned.
378  // TODO(user): use unique_ptr
379  std::vector<Constraint*> constraints_;
380  // The objective variable (it belongs to variables_).
381  IntegerVariable* objective_;
382  bool maximize_;
383  // All search annotations are stored as a vector of Annotation.
384  std::vector<Annotation> search_annotations_;
385  std::vector<SolutionOutputSpecs> output_;
386 };
387 
388 // Stand-alone statistics class on the model.
389 // TODO(user): Clean up API to pass a Model* in argument.
391  public:
392  explicit ModelStatistics(const Model& model) : model_(model) {}
394  return constraints_per_variables_[var].size();
395  }
396  void BuildStatistics();
397  void PrintStatistics() const;
398 
399  private:
400  const Model& model_;
401  std::map<std::string, std::vector<Constraint*>> constraints_per_type_;
402  absl::flat_hash_map<const IntegerVariable*, std::vector<Constraint*>>
403  constraints_per_variables_;
404 };
405 
406 // Helper method to flatten Search annotations.
407 void FlattenAnnotations(const Annotation& ann, std::vector<Annotation>* out);
408 
409 } // namespace fz
410 } // namespace operations_research
411 
412 #endif // OR_TOOLS_FLATZINC_MODEL_H_
operations_research::fz::SolutionOutputSpecs::Bounds::Bounds
Bounds(int64 min_value_, int64 max_value_)
Definition: flatzinc/model.h:284
var
IntVar * var
Definition: expr_array.cc:1858
operations_research::fz::SolutionOutputSpecs::bounds
std::vector< Bounds > bounds
Definition: flatzinc/model.h:311
operations_research::fz::ModelStatistics::ModelStatistics
ModelStatistics(const Model &model)
Definition: flatzinc/model.h:392
operations_research::fz::Argument::Interval
static Argument Interval(int64 imin, int64 imax)
Definition: model.cc:393
operations_research::fz::Annotation::INT_VALUE
@ INT_VALUE
Definition: flatzinc/model.h:243
integral_types.h
operations_research::fz::Domain::AllInt64
static Domain AllInt64()
Definition: model.cc:41
operations_research::fz::Domain::OverlapsIntList
bool OverlapsIntList(const std::vector< int64 > &vec) const
Definition: model.cc:289
operations_research::fz::Constraint::active
bool active
Definition: flatzinc/model.h:228
operations_research::fz::Domain::IntegerList
static Domain IntegerList(std::vector< int64 > values)
Definition: model.cc:31
operations_research::fz::Argument::Value
int64 Value() const
Definition: model.cc:482
operations_research::fz::Constraint::strong_propagation
bool strong_propagation
Definition: flatzinc/model.h:223
operations_research::fz::Argument::type
Type type
Definition: flatzinc/model.h:188
operations_research::fz::Domain::SetOfAllInt64
static Domain SetOfAllInt64()
Definition: model.cc:84
operations_research::fz::Annotation::interval_min
int64 interval_min
Definition: flatzinc/model.h:272
operations_research::fz::Annotation::STRING_VALUE
@ STRING_VALUE
Definition: flatzinc/model.h:247
operations_research::fz::Annotation
Definition: flatzinc/model.h:238
operations_research::fz::Annotation::interval_max
int64 interval_max
Definition: flatzinc/model.h:273
operations_research::fz::Annotation::FunctionCallWithArguments
static Annotation FunctionCallWithArguments(const std::string &id, std::vector< Annotation > args)
Definition: model.cc:666
logging.h
operations_research::fz::Constraint::Constraint
Constraint(const std::string &t, std::vector< Argument > args, bool strong_propag)
Definition: flatzinc/model.h:197
operations_research::fz::Argument::Type
Type
Definition: flatzinc/model.h:144
operations_research::fz::Annotation::INT_VAR_REF_ARRAY
@ INT_VAR_REF_ARRAY
Definition: flatzinc/model.h:246
operations_research::fz::Domain::display_as_boolean
bool display_as_boolean
Definition: flatzinc/model.h:99
operations_research::fz::Model::Minimize
void Minimize(IntegerVariable *obj, std::vector< Annotation > search_annotations)
Definition: model.cc:862
operations_research::fz::Model
Definition: flatzinc/model.h:315
operations_research::fz::Model::objective
IntegerVariable * objective() const
Definition: flatzinc/model.h:364
operations_research::fz::Argument::IntVarRefArray
static Argument IntVarRefArray(std::vector< IntegerVariable * > vars)
Definition: model.cc:422
operations_research::fz::Annotation::annotations
std::vector< Annotation > annotations
Definition: flatzinc/model.h:275
operations_research::fz::Argument::DebugString
std::string DebugString() const
Definition: model.cc:447
value
int64 value
Definition: demon_profiler.cc:43
operations_research::fz::Model::name
const std::string & name() const
Definition: flatzinc/model.h:370
operations_research::fz::SolutionOutputSpecs
Definition: flatzinc/model.h:282
operations_research::fz::Domain::IntersectWithSingleton
bool IntersectWithSingleton(int64 value)
Definition: model.cc:139
operations_research::fz::Annotation::String
static Annotation String(const std::string &str)
Definition: model.cc:719
operations_research::fz::Annotation::Type
Type
Definition: flatzinc/model.h:239
operations_research::fz::IntegerVariable::name
std::string name
Definition: flatzinc/model.h:123
operations_research
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
Definition: dense_doubly_linked_list.h:21
operations_research::fz::Argument::IsVariable
bool IsVariable() const
Definition: model.cc:474
operations_research::fz::Model::Satisfy
void Satisfy(std::vector< Annotation > search_annotations)
Definition: model.cc:857
operations_research::fz::SolutionOutputSpecs::name
std::string name
Definition: flatzinc/model.h:306
operations_research::fz::Argument::INT_VAR_REF
@ INT_VAR_REF
Definition: flatzinc/model.h:149
operations_research::fz::Model::mutable_output
util::MutableVectorIteration< SolutionOutputSpecs > mutable_output()
Definition: flatzinc/model.h:359
operations_research::fz::Annotation::Variable
static Annotation Variable(IntegerVariable *const var)
Definition: model.cc:701
int64
int64_t int64
Definition: integral_types.h:34
operations_research::fz::Model::AddConstraint
void AddConstraint(const std::string &id, std::vector< Argument > arguments, bool is_domain)
Definition: model.cc:841
operations_research::fz::Argument::DOMAIN_LIST
@ DOMAIN_LIST
Definition: flatzinc/model.h:148
operations_research::fz::Domain::IntersectWithDomain
bool IntersectWithDomain(const Domain &domain)
Definition: model.cc:116
operations_research::fz::Argument::INT_VALUE
@ INT_VALUE
Definition: flatzinc/model.h:145
operations_research::fz::Argument::domains
std::vector< Domain > domains
Definition: flatzinc/model.h:191
operations_research::fz::Argument::HasOneValue
bool HasOneValue() const
Definition: model.cc:476
operations_research::fz::Constraint::type
std::string type
Definition: flatzinc/model.h:216
operations_research::fz::Model::maximize
bool maximize() const
Definition: flatzinc/model.h:363
operations_research::fz::Domain::SetOfBoolean
static Domain SetOfBoolean()
Definition: model.cc:102
operations_research::fz::Argument::values
std::vector< int64 > values
Definition: flatzinc/model.h:189
operations_research::fz::Domain::SetOfIntegerValue
static Domain SetOfIntegerValue(int64 value)
Definition: model.cc:90
operations_research::fz::IntegerVariable::active
bool active
Definition: flatzinc/model.h:132
operations_research::fz::Domain::is_interval
bool is_interval
Definition: flatzinc/model.h:98
operations_research::fz::Annotation::VariableList
static Annotation VariableList(std::vector< IntegerVariable * > variables)
Definition: model.cc:710
operations_research::fz::Annotation::ANNOTATION_LIST
@ ANNOTATION_LIST
Definition: flatzinc/model.h:240
operations_research::fz::Constraint::DebugString
std::string DebugString() const
Definition: model.cc:614
operations_research::fz::Annotation::FUNCTION_CALL
@ FUNCTION_CALL
Definition: flatzinc/model.h:242
operations_research::fz::Argument::variables
std::vector< IntegerVariable * > variables
Definition: flatzinc/model.h:190
operations_research::fz::Domain::IntegerValue
static Domain IntegerValue(int64 value)
Definition: model.cc:49
operations_research::fz::Model::~Model
~Model()
Definition: model.cc:821
util::MutableVectorIteration
Definition: iterators.h:156
operations_research::fz::Annotation::IsFunctionCallWithIdentifier
bool IsFunctionCallWithIdentifier(const std::string &identifier) const
Definition: flatzinc/model.h:263
operations_research::fz::Domain::values
std::vector< int64 > values
Definition: flatzinc/model.h:97
operations_research::fz::Annotation::DebugString
std::string DebugString() const
Definition: model.cc:738
string_array.h
operations_research::fz::Annotation::FunctionCall
static Annotation FunctionCall(const std::string &id)
Definition: model.cc:677
operations_research::fz::Model::variables
const std::vector< IntegerVariable * > & variables() const
Definition: flatzinc/model.h:347
operations_research::fz::IntegerVariable::temporary
bool temporary
Definition: flatzinc/model.h:128
operations_research::fz::Annotation::IntegerValue
static Annotation IntegerValue(int64 value)
Definition: model.cc:694
operations_research::fz::SolutionOutputSpecs::Bounds
Definition: flatzinc/model.h:283
operations_research::fz::Domain::Min
int64 Min() const
Definition: model.cc:245
operations_research::fz::Constraint
Definition: flatzinc/model.h:196
operations_research::fz::Argument::Var
IntegerVariable * Var() const
Definition: model.cc:574
operations_research::fz::Domain::EmptyDomain
static Domain EmptyDomain()
Definition: model.cc:108
operations_research::fz::Model::search_annotations
const std::vector< Annotation > & search_annotations() const
Definition: flatzinc/model.h:349
operations_research::fz::Argument::ValueAt
int64 ValueAt(int pos) const
Definition: model.cc:549
operations_research::fz::Model::IsInconsistent
bool IsInconsistent() const
Definition: model.cc:903
operations_research::fz::SolutionOutputSpecs::display_as_boolean
bool display_as_boolean
Definition: flatzinc/model.h:312
operations_research::fz::Argument::VOID_ARGUMENT
@ VOID_ARGUMENT
Definition: flatzinc/model.h:151
operations_research::fz::Argument::VoidArgument
static Argument VoidArgument()
Definition: model.cc:429
operations_research::fz::Annotation::id
std::string id
Definition: flatzinc/model.h:274
operations_research::fz::Argument
Definition: flatzinc/model.h:143
operations_research::fz::Model::Model
Model(const std::string &name)
Definition: flatzinc/model.h:317
operations_research::fz::Model::mutable_search_annotations
util::MutableVectorIteration< Annotation > mutable_search_annotations()
Definition: flatzinc/model.h:353
operations_research::fz::ModelStatistics::NumVariableOccurrences
int NumVariableOccurrences(IntegerVariable *var)
Definition: flatzinc/model.h:393
operations_research::fz::Argument::IntegerList
static Argument IntegerList(std::vector< int64 > values)
Definition: model.cc:401
operations_research::fz::Domain::empty
bool empty() const
Definition: model.cc:240
operations_research::fz::SolutionOutputSpecs::flat_variables
std::vector< IntegerVariable * > flat_variables
Definition: flatzinc/model.h:308
operations_research::fz::Annotation::INTERVAL
@ INTERVAL
Definition: flatzinc/model.h:244
operations_research::fz::Domain::DebugString
std::string DebugString() const
Definition: model.cc:370
operations_research::fz::Constraint::presolve_propagation_done
bool presolve_propagation_done
Definition: flatzinc/model.h:231
operations_research::fz::SolutionOutputSpecs::Bounds::DebugString
std::string DebugString() const
Definition: model.cc:776
operations_research::fz::Domain::Max
int64 Max() const
Definition: model.cc:250
operations_research::fz::Domain::SetOfInterval
static Domain SetOfInterval(int64 included_min, int64 included_max)
Definition: model.cc:96
operations_research::fz::Domain::Contains
bool Contains(int64 value) const
Definition: model.cc:265
operations_research::fz::IntegerVariable::DebugString
std::string DebugString() const
Definition: model.cc:602
operations_research::fz::SolutionOutputSpecs::VoidOutput
static SolutionOutputSpecs VoidOutput()
Definition: model.cc:802
operations_research::fz::Domain::Value
int64 Value() const
Definition: model.cc:255
operations_research::fz::Domain::OverlapsIntInterval
bool OverlapsIntInterval(int64 lb, int64 ub) const
Definition: model.cc:313
operations_research::fz::Argument::VarAt
IntegerVariable * VarAt(int pos) const
Definition: model.cc:578
operations_research::fz::Model::DebugString
std::string DebugString() const
Definition: model.cc:876
operations_research::fz::Domain::SetOfIntegerList
static Domain SetOfIntegerList(std::vector< int64 > values)
Definition: model.cc:78
operations_research::fz::IntegerVariable
Definition: flatzinc/model.h:107
operations_research::fz::Annotation::AppendAllIntegerVariables
void AppendAllIntegerVariables(std::vector< IntegerVariable * > *vars) const
Definition: model.cc:728
operations_research::fz::Model::SetObjective
void SetObjective(IntegerVariable *obj)
Definition: flatzinc/model.h:365
model
GRBmodel * model
Definition: gurobi_interface.cc:269
operations_research::fz::Argument::DomainList
static Argument DomainList(std::vector< Domain > domains)
Definition: model.cc:408
operations_research::fz::Argument::IntVarRef
static Argument IntVarRef(IntegerVariable *const var)
Definition: model.cc:415
operations_research::fz::SolutionOutputSpecs::SingleVariable
static SolutionOutputSpecs SingleVariable(const std::string &name, IntegerVariable *variable, bool display_as_boolean)
Definition: model.cc:780
operations_research::fz::Domain::OverlapsDomain
bool OverlapsDomain(const Domain &other) const
Definition: model.cc:327
operations_research::fz::SolutionOutputSpecs::MultiDimensionalArray
static SolutionOutputSpecs MultiDimensionalArray(const std::string &name, std::vector< Bounds > bounds, std::vector< IntegerVariable * > flat_variables, bool display_as_boolean)
Definition: model.cc:790
operations_research::fz::SolutionOutputSpecs::Bounds::min_value
int64 min_value
Definition: flatzinc/model.h:287
operations_research::fz::Model::AddVariable
IntegerVariable * AddVariable(const std::string &name, const Domain &domain, bool defined)
Definition: model.cc:826
operations_research::fz::Domain::is_a_set
bool is_a_set
Definition: flatzinc/model.h:101
iterators.h
operations_research::fz::ModelStatistics::PrintStatistics
void PrintStatistics() const
Definition: model.cc:920
operations_research::fz::ModelStatistics::BuildStatistics
void BuildStatistics()
Definition: model.cc:933
operations_research::fz::Domain::HasOneValue
bool HasOneValue() const
Definition: model.cc:236
operations_research::fz::Domain::Interval
static Domain Interval(int64 included_min, int64 included_max)
Definition: model.cc:58
operations_research::fz::SolutionOutputSpecs::variable
IntegerVariable * variable
Definition: flatzinc/model.h:307
operations_research::fz::Domain::Boolean
static Domain Boolean()
Definition: model.cc:68
operations_research::fz::SolutionOutputSpecs::DebugString
std::string DebugString() const
Definition: model.cc:809
operations_research::fz::IntegerVariable::Merge
bool Merge(const std::string &other_name, const Domain &other_domain, bool other_temporary)
Definition: model.cc:592
operations_research::fz::Model::output
const std::vector< SolutionOutputSpecs > & output() const
Definition: flatzinc/model.h:357
operations_research::fz::Annotation::Identifier
static Annotation Identifier(const std::string &id)
Definition: model.cc:657
operations_research::fz::Argument::IsArrayOfValues
bool IsArrayOfValues() const
Definition: model.cc:500
operations_research::fz::Annotation::Empty
static Annotation Empty()
Definition: model.cc:640
operations_research::fz::FlattenAnnotations
void FlattenAnnotations(const Annotation &ann, std::vector< Annotation > *out)
Definition: model.cc:953
operations_research::fz::Constraint::MarkAsInactive
void MarkAsInactive()
Definition: model.cc:628
operations_research::fz::Domain::IsAllInt64
bool IsAllInt64() const
Definition: model.cc:260
operations_research::fz::Constraint::RemoveArg
void RemoveArg(int arg_pos)
Definition: model.cc:624
operations_research::fz::Argument::INT_INTERVAL
@ INT_INTERVAL
Definition: flatzinc/model.h:146
operations_research::fz::Constraint::SetAsFalse
void SetAsFalse()
Definition: model.cc:633
operations_research::fz::Model::AddOutput
void AddOutput(SolutionOutputSpecs output)
Definition: model.cc:853
operations_research::fz::Annotation::AnnotationList
static Annotation AnnotationList(std::vector< Annotation > list)
Definition: model.cc:648
operations_research::fz::IntegerVariable::domain
Domain domain
Definition: flatzinc/model.h:124
operations_research::fz::Argument::IntegerValue
static Argument IntegerValue(int64 value)
Definition: model.cc:386
operations_research::fz::Constraint::arguments
std::vector< Argument > arguments
Definition: flatzinc/model.h:217
operations_research::fz::Argument::INT_VAR_REF_ARRAY
@ INT_VAR_REF_ARRAY
Definition: flatzinc/model.h:150
operations_research::fz::Annotation::type
Type type
Definition: flatzinc/model.h:271
operations_research::fz::Domain::IntersectWithInterval
bool IntersectWithInterval(int64 interval_min, int64 interval_max)
Definition: model.cc:143
operations_research::fz::Argument::INT_LIST
@ INT_LIST
Definition: flatzinc/model.h:147
operations_research::fz::Domain
Definition: flatzinc/model.h:48
operations_research::fz::Argument::Contains
bool Contains(int64 value) const
Definition: model.cc:531
operations_research::fz::Annotation::string_value
std::string string_value
Definition: flatzinc/model.h:277
operations_research::fz::Annotation::variables
std::vector< IntegerVariable * > variables
Definition: flatzinc/model.h:276
operations_research::fz::Argument::FromDomain
static Argument FromDomain(const Domain &domain)
Definition: model.cc:435
operations_research::fz::SolutionOutputSpecs::Bounds::max_value
int64 max_value
Definition: flatzinc/model.h:288
operations_research::fz::Annotation::INT_VAR_REF
@ INT_VAR_REF
Definition: flatzinc/model.h:245
operations_research::fz::Domain::RemoveValue
bool RemoveValue(int64 value)
Definition: model.cc:339
operations_research::fz::Annotation::IDENTIFIER
@ IDENTIFIER
Definition: flatzinc/model.h:241
operations_research::fz::Annotation::Interval
static Annotation Interval(int64 interval_min, int64 interval_max)
Definition: model.cc:686
operations_research::fz::Model::Maximize
void Maximize(IntegerVariable *obj, std::vector< Annotation > search_annotations)
Definition: model.cc:869
operations_research::fz::Domain::IntersectWithListOfIntegers
bool IntersectWithListOfIntegers(const std::vector< int64 > &integers)
Definition: model.cc:191
operations_research::fz::Model::constraints
const std::vector< Constraint * > & constraints() const
Definition: flatzinc/model.h:348
operations_research::fz::ModelStatistics
Definition: flatzinc/model.h:390
operations_research::fz::Model::AddConstant
IntegerVariable * AddConstant(int64 value)
Definition: model.cc:834