52 #include <boost/random.hpp>
53 #include <boost/functional/hash.hpp>
64 void replace(std::string & str, std::string
const & from,
65 std::string
const & to);
67 void replaceAll(std::string & str, std::string
const & from,
68 std::string
const & to);
70 char ** cStringArrayAlloc(std::vector<std::string>
const & sv);
75 template<
typename T> std::string
to_string(T
const & num)
77 std::ostringstream oss;
91 bool operator()(BDD
const & bdd1, BDD
const & bdd2)
const
93 return bdd1.getNode() < bdd2.getNode();
103 using pwbdd = std::pair<T,BDD>;
104 bool operator()(pwbdd
const & p1, pwbdd
const & p2)
const
106 return std::tuple<T,DdNode *>(p1.first, p1.second.getNode()) <
107 std::tuple<T,DdNode *>(p2.first, p2.second.getNode());
114 template<
typename T1,
typename T2>
117 size_t operator()(std::pair<T1,T2>
const & p)
const
119 size_t seed = std::hash<T1>()(p.first);
120 boost::hash_combine(seed, std::hash<T2>()(p.second));
126 template<
typename T,
typename Comp>
128 std::map<T,unsigned,Comp>
const & m)
131 return std::vector< std::set<T, Comp> >{};
133 unsigned maxindex = 0;
134 for (
auto const & e : m) {
135 if (e.second > maxindex)
138 std::vector< std::set<T, Comp> > partition(maxindex+1);
139 for (
auto const & e : m) {
140 partition[e.second].insert(e.first);
145 using RandomEngine = std::mt19937;
148 RandomEngine &
urng();
160 template <
typename Iterator>
161 typename std::iterator_traits<Iterator>::value_type
162 sample_discrete_distribution(Iterator first, Iterator last)
164 using Distribution = boost::random::discrete_distribution<>;
165 using Parameter = Distribution::param_type;
166 thread_local
static Distribution dist{};
167 return dist(
urng(), Parameter{first, last});
171 int sample_discrete_distribution(std::vector<double>
const & weights);
174 template <
typename IntType>
177 using Distribution = boost::random::uniform_int_distribution<IntType>;
178 using Parameter =
typename Distribution::param_type;
179 thread_local
static Distribution dist{};
180 return dist(
urng(), Parameter{low, hi});
184 std::chrono::time_point<std::chrono::system_clock>
stopwatch();
187 void printElapsedTag(std::ostream & os = std::cout);
196 bool is_prefix(std::string
const & str, std::string
const & pre);