Changeset 2229:4dbb6dd2dd4b in lemon-0.x
- Timestamp:
- 10/02/06 18:11:00 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2969
- Files:
-
- 2 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/Makefile.am
r2218 r2229 13 13 lemon/color.cc \ 14 14 lemon/eps.cc \ 15 lemon/bits/mingw32_ rand.cc \16 lemon/ bits/mingw32_time.cc15 lemon/bits/mingw32_time.cc \ 16 lemon/random.cc 17 17 18 18 lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) … … 87 87 lemon/radix_heap.h \ 88 88 lemon/radix_sort.h \ 89 lemon/random.h \ 89 90 lemon/refptr.h \ 90 91 lemon/simann.h \ … … 113 114 lemon/bits/item_writer.h \ 114 115 lemon/bits/map_extender.h \ 115 lemon/bits/mingw32_rand.h \116 116 lemon/bits/mingw32_time.h \ 117 117 lemon/bits/traits.h \ -
lemon/hypercube_graph.h
r2223 r2229 261 261 /// dim2::Point<double> base[DIM]; 262 262 /// for (int k = 0; k < DIM; ++k) { 263 /// base[k].x = rand () / (RAND_MAX + 1.0);264 /// base[k].y = rand () / (RAND_MAX + 1.0);263 /// base[k].x = random.getReal(); 264 /// base[k].y = random.getReal(); 265 265 /// } 266 266 /// HyperCubeGraph::HyperMap<dim2::Point<double> > -
lemon/simann.h
r2035 r2229 32 32 #include <limits> 33 33 #include <lemon/time_measure.h> 34 35 #ifdef WIN32 36 #include <lemon/bits/mingw32_rand.h> 37 #endif 34 #include <lemon/random.h> 38 35 39 36 namespace lemon { … … 242 239 max_no_impr(_max_no_impr), temp(_temp), ann_fact(_ann_fact) 243 240 { 244 srand48(time(0));245 241 } 246 242 /// \brief This is called when a neighbouring state gets accepted. … … 262 258 bool accept() { 263 259 double cost_diff = simann->getCurrCost() - simann->getPrevCost(); 264 return ( drand48() <= exp(-(cost_diff / temp)));260 return (rnd.getReal() <= exp(-(cost_diff / temp))); 265 261 } 266 262 /// \brief Destructor. … … 322 318 ann_fact(_ann_fact), init_ann_fact(_ann_fact), start(false) 323 319 { 324 srand48(time(0));325 320 } 326 321 /// \brief Does initializations before each run. … … 371 366 else { 372 367 double cost_diff = simann->getCurrCost() - simann->getPrevCost(); 373 return ( drand48() <= exp(-(cost_diff / temp)));368 return (rnd.getReal() <= exp(-(cost_diff / temp))); 374 369 } 375 370 } -
test/graph_utils_test.h
r1956 r2229 51 51 typedef typename Graph::EdgeIt EdgeIt; 52 52 Graph graph; 53 srand(time(0));54 53 for (int i = 0; i < 10; ++i) { 55 54 graph.addNode(); … … 58 57 typename DescriptorMap<Graph, Node>::InverseMap invNodes(nodes); 59 58 for (int i = 0; i < 100; ++i) { 60 int src = (int)(rand() / (RAND_MAX + 1.0) *invNodes.size());61 int trg = (int)(rand() / (RAND_MAX + 1.0) *invNodes.size());59 int src = rnd.getInt(invNodes.size()); 60 int trg = rnd.getInt(invNodes.size()); 62 61 graph.addEdge(invNodes[src], invNodes[trg]); 63 62 } -
test/heap_test.h
r1956 r2229 46 46 47 47 for (int i = 0; i < n; ++i) { 48 v[i] = r and() % 1000;48 v[i] = rnd.getInt(1000); 49 49 heap.push(i, v[i]); 50 50 } … … 66 66 67 67 for (int i = 0; i < n; ++i) { 68 v[i] = r and() % 1000;68 v[i] = rnd.getInt(1000); 69 69 heap.push(i, v[i]); 70 70 } 71 71 for (int i = 0; i < n; ++i) { 72 v[i] += r and() % 1000;72 v[i] += rnd.getInt(1000); 73 73 heap.increase(i, v[i]); 74 74 } -
test/test_tools.h
r2198 r2229 28 28 #include <lemon/concept_check.h> 29 29 #include <lemon/concept/graph.h> 30 31 #include <lemon/random.h> 30 32 31 33 using namespace lemon; … … 177 179 } 178 180 179 int _urandom_init() {180 int seed = time(0);181 srand(seed);182 return seed;183 }184 185 181 int urandom(int n) { 186 static int seed = _urandom_init(); 187 ignore_unused_variable_warning(seed); 188 return (int)(rand() / (1.0 + RAND_MAX) * n); 182 return rnd.getInt(n); 189 183 } 190 184
Note: See TracChangeset
for help on using the changeset viewer.