mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
Seed the randomizer once, not every time.
This bit of mira code used to re-seed the randomizer on every call, instead of just once on startup. The result of time(NULL) was used as a seed, meaning that every such call to the randomizer within the same second would return the same value.
This commit is contained in:
parent
55a4789a8b
commit
10bd942127
@ -46,6 +46,7 @@ namespace mpi = boost::mpi;
|
||||
#include "moses/FF/PhrasePairFeature.h"
|
||||
#include "moses/FF/WordPenaltyProducer.h"
|
||||
#include "moses/LM/Base.h"
|
||||
#include "util/random.hh"
|
||||
|
||||
using namespace Mira;
|
||||
using namespace std;
|
||||
@ -54,6 +55,7 @@ namespace po = boost::program_options;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
util::rand_init();
|
||||
size_t rank = 0;
|
||||
size_t size = 1;
|
||||
#ifdef MPI_ENABLE
|
||||
|
@ -38,10 +38,6 @@ template <class T> bool from_string(T& t, const std::string& s, std::ios_base& (
|
||||
|
||||
struct RandomIndex {
|
||||
ptrdiff_t operator()(ptrdiff_t max) {
|
||||
// TODO: Don't seed the randomizer here. If this function gets called
|
||||
// multiple times in the same second, it will return the same value on
|
||||
// each of those calls.
|
||||
util::rand_init();
|
||||
return util::rand_excl(max);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user