Named values read from an instance. More...
#include <gecode/instance.hh>
Public Member Functions | |
| Data (void) | |
| Empty data. | |
Entries | |
| int | entries (void) const |
| Return number of entries. | |
| std::string | name (int i) const |
| Return name of entry i, in the order they were defined. | |
| bool | has (const std::string &n) const |
| Test whether there is an entry n. | |
| ValueType | type (const std::string &n) const |
| Return the value type of entry n. | |
| int | depth (const std::string &n) const |
| Return the depth of entry n (0 for scalars). | |
Values | |
| int | size (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return the length of the array or row n at path. | |
| long long int | integer (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return the integer n at path. | |
| double | number (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return the number n at path (integers are converted). | |
| std::string | text (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return the string n at path. | |
| IntArgs | ints (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return all integers in the array or row n at path. | |
| ArgArray< double > | numbers (const std::string &n, const IntArgs &path=IntArgs()) const |
| Return all numbers in the array or row n at path. | |
Output | |
| void | dzn (std::ostream &os) const |
| Print all entries as MiniZinc data. | |
Detailed Description
Named values read from an instance.
Every entry has a name, a value type (see ValueType), and a depth: depth 0 is a scalar, depth 1 an array, depth 2 an array of arrays, and so on. Arrays may be ragged, that is, rows can have different lengths.
The accessors take a path of indices (from 0) that selects a row or a single value, such as d.ints("clause", {3}) for row 3 of clause or d.text("s", {1, 0, 2}); without a path they refer to the whole entry. They throw Error if the name is unknown, if the value has the wrong type or depth, if an index is out of range, or if an integer does not fit into an int.
Definition at line 406 of file instance.hh.
Constructor & Destructor Documentation
◆ Data()
Member Function Documentation
◆ entries()
| int Gecode::Instance::Data::entries | ( | void | ) | const |
◆ name()
| std::string Gecode::Instance::Data::name | ( | int | i | ) | const |
◆ has()
| bool Gecode::Instance::Data::has | ( | const std::string & | n | ) | const |
◆ type()
| ValueType Gecode::Instance::Data::type | ( | const std::string & | n | ) | const |
◆ depth()
| int Gecode::Instance::Data::depth | ( | const std::string & | n | ) | const |
◆ size()
◆ integer()
◆ number()
◆ text()
◆ ints()
◆ numbers()
◆ dzn()
| void Gecode::Instance::Data::dzn | ( | std::ostream & | os | ) | const |
Print all entries as MiniZinc data.
Rectangular arrays of up to six dimensions are printed as MiniZinc arrays, so the form depends on the data: rows that happen to have equal lengths give a two-dimensional array. Other arrays are printed as arrays of 1-tuples of arrays (MiniZinc 2.7 or later), preceded by a comment with its type, for example
where row i is x[i].1.
The documentation for this class was generated from the following files:
- gecode/instance.hh
- gecode/instance/data.cpp
