mslehre / MAS

Maximum Acyclic Subgraph (MAS) - Multiple Sequence Alignment (MSA) Game
1 stars 0 forks source link

random number generation #34

Closed felbecker closed 5 years ago

felbecker commented 5 years ago

I just tested the sequence simulation code (at home under windows). It does produce the same sequence every time I run the program. Also the sequences are not mutated at all. I suspect that this is a seed initialization problem. Do you get different sequences for each execution of the program on your system? Do mutations work?

I researched a bit and found that std::random_device is deterministic under MINGW/Windows, but non-deterministic under linux, which is a ugly thing as we want code to be portable and work the same on every system.

As a solution I would try to not use std::random_device and set the seed using the current system time instead:

#include <chrono>

std::mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

(and remove the line with the random device)

The issue with the mutations not working might be unrelated to this. Since you generate random doubles there, you should use std::uniform_real_distribution (https://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution) for the random mutation probability, not the random device as you currently do.

TimonKapischke commented 5 years ago

I have just tested it under Linux. After every run I get a new sequence.

TimonKapischke commented 5 years ago

Example:

TimonKapischke commented 5 years ago

The mutation works also under Linux: (Mutation probability = 1 (100%) ) seq1 TGGCATGCCCCTGACTTATCTATATCGGCG seq2 AGAAGTTGCGGAAAACCGCGGGCCGCCTTA seq3 CATGCTCACCGTTCGGACGGCCGGTGCCCG

Mutation Probability = 0.2 (20%) seq1 GCGCAATTGAGCCGTCTTATACACGGTAGC seq2 GCGTATTTGATCCGTCTCGTACACGGTAGT seq3 GCGTTAATGAACCGGCTTTTAGTCGGTAGT

TimonKapischke commented 5 years ago

I made a pull request with the new seed simulation. I hope it works under windows.

felbecker commented 5 years ago

Fixed in #35