45 static std::string DefaultFormatter(
const L& x) {
52 using std::map<L,
size_t>::operator=;
58 Assignment(std::initializer_list<std::pair<const L, size_t>> init)
59 : std::map<L, size_t>{init} {}
61 void print(
const std::string& s =
"Assignment: ",
62 const std::function<std::string(L)>& labelFormatter =
63 &DefaultFormatter)
const {
64 std::cout << s <<
": ";
65 for (
const typename Assignment::value_type& keyValue : *
this) {
66 std::cout <<
"(" << labelFormatter(keyValue.first) <<
", "
67 << keyValue.second <<
")";
69 std::cout << std::endl;
73 return (*
this == other);
88 template <
typename Derived = Assignment<L>>
90 const std::vector<std::pair<L, size_t>>& keys) {
91 std::vector<Derived> allPossValues;
95 values[key.first] = 0;
97 allPossValues.push_back(values);
99 for (j = 0; j < keys.size(); j++) {
100 L idx = keys[j].first;
102 if (values[idx] < keys[j].second)
break;
106 if (j == keys.size())
break;
108 return allPossValues;
std::pair< Key, size_t > DiscreteKey
Key type for discrete variables.
Definition DiscreteKey.h:36
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Template to create a binary predicate.
Definition Testable.h:111
An assignment from labels to value index (size_t).
Definition Assignment.h:37
static std::vector< Derived > CartesianProduct(const std::vector< std::pair< L, size_t > > &keys)
Get Cartesian product consisting all possible configurations.
Definition Assignment.h:89