COIN-OR::LEMON - Graph Library

Changeset 2229:4dbb6dd2dd4b in lemon-0.x for lemon


Ignore:
Timestamp:
10/02/06 18:11:00 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2969
Message:

Mersenne Twister random number generator

The code is based on the official MT19937 implementation
It is fully rewritten:

http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

todo: fixing copyright information

Location:
lemon
Files:
2 added
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • lemon/Makefile.am

    r2218 r2229  
    1313        lemon/color.cc \
    1414        lemon/eps.cc \
    15         lemon/bits/mingw32_rand.cc \
    16         lemon/bits/mingw32_time.cc
     15        lemon/bits/mingw32_time.cc \
     16        lemon/random.cc
    1717
    1818lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
     
    8787        lemon/radix_heap.h \
    8888        lemon/radix_sort.h \
     89        lemon/random.h \
    8990        lemon/refptr.h \
    9091        lemon/simann.h \
     
    113114        lemon/bits/item_writer.h \
    114115        lemon/bits/map_extender.h \
    115         lemon/bits/mingw32_rand.h \
    116116        lemon/bits/mingw32_time.h \
    117117        lemon/bits/traits.h \
  • lemon/hypercube_graph.h

    r2223 r2229  
    261261    /// dim2::Point<double> base[DIM];
    262262    /// 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();
    265265    /// }
    266266    /// HyperCubeGraph::HyperMap<dim2::Point<double> >
  • lemon/simann.h

    r2035 r2229  
    3232#include <limits>
    3333#include <lemon/time_measure.h>
    34 
    35 #ifdef WIN32
    36 #include <lemon/bits/mingw32_rand.h>
    37 #endif
     34#include <lemon/random.h>
    3835
    3936namespace lemon {
     
    242239      max_no_impr(_max_no_impr), temp(_temp), ann_fact(_ann_fact)
    243240    {
    244       srand48(time(0));
    245241    }
    246242    /// \brief This is called when a neighbouring state gets accepted.
     
    262258    bool accept() {
    263259      double cost_diff = simann->getCurrCost() - simann->getPrevCost();
    264       return (drand48() <= exp(-(cost_diff / temp)));
     260      return (rnd.getReal() <= exp(-(cost_diff / temp)));
    265261    }
    266262    /// \brief Destructor.
     
    322318    ann_fact(_ann_fact), init_ann_fact(_ann_fact), start(false)
    323319    {
    324       srand48(time(0));
    325320    }
    326321    /// \brief Does initializations before each run.
     
    371366      else {
    372367        double cost_diff = simann->getCurrCost() - simann->getPrevCost();
    373         return (drand48() <= exp(-(cost_diff / temp)));
     368        return (rnd.getReal() <= exp(-(cost_diff / temp)));
    374369      }
    375370    }
Note: See TracChangeset for help on using the changeset viewer.