COIN-OR::LEMON - Graph Library

Opened 9 years ago

Closed 7 years ago

#602 closed enhancement (done)

Platform independent pseudo random sequences

Reported by: Alpar Juttner Owned by: Alpar Juttner
Priority: major Milestone: LEMON 1.4 release
Component: core Version: hg main
Keywords: Cc:
Revision id:

Description

LEMON's random generator is based on the Mersenne Twister algoritm and it is optimized to 32 and 64 bit architecture. This is fine, except when someone want to obtain reproducible results (for a given initial seed) on each platform. The attached patch provides the following solution to this.

The original Random class becomes a template and goes to the _random_bits namespace, then three typedefs are defined:

  • Random is exactly the same as the class Random was before,
  • Random32 is the 32 bit version (on all platform) and
  • Random64 is the 64 bit version (on all platform).

This solution is fully backward compatible and the only drawback I can see is the documentation - one has to visit the template version to see the detailed API.

What do you think, is the documentation is acceptable in this form? If not, what would be a better solution?

Attachments (3)

602-db1d342a1087.patch (39.1 KB) - added by Alpar Juttner 9 years ago.
602-026829fdb6d4.patch (7.6 KB) - added by Peter Kovacs 7 years ago.
602-04f57dad1b07.patch (7.6 KB) - added by Peter Kovacs 7 years ago.

Download all attachments as: .zip

Change History (9)

Changed 9 years ago by Alpar Juttner

Attachment: 602-db1d342a1087.patch added

comment:1 Changed 8 years ago by Alpar Juttner

Type: defectenhancement

comment:2 Changed 7 years ago by Peter Kovacs

I do like this changeset, we should merge it to the main branch.

I also added a patch [026829fdb6d4] with javadoc improvements (it is on the top of the proposed patch).

Last edited 7 years ago by Peter Kovacs (previous) (diff)

Changed 7 years ago by Peter Kovacs

Attachment: 602-026829fdb6d4.patch added

comment:3 Changed 7 years ago by Alpar Juttner

I cannot apply 602-026829fdb6d4.patch with --exact, mercurial says this patch is corrupt.

Changed 7 years ago by Peter Kovacs

Attachment: 602-04f57dad1b07.patch added

comment:4 in reply to:  3 Changed 7 years ago by Peter Kovacs

Replying to alpar:

I cannot apply 602-026829fdb6d4.patch with --exact, mercurial says this patch is corrupt.

Strange. I can reproduce the issue, but I do not understand its cause. It seems that if I export a changeset after it was modified (e.g. hg commit --amend), then it cannot be imported with --exact. But if I import it without --exact, it works and a new hash ID is added to the commit. If I export this new version, then it can be imported with --exact. I do not understand why this happens. (I use Mercurial 4.3.1 on Ubuntu 17.10)

I recreated the patch as [04f57dad1b07] and tested it, it should work correctly.

Version 0, edited 7 years ago by Peter Kovacs (next)

comment:5 Changed 7 years ago by Alpar Juttner

Yes, now it works. Thanks.

comment:6 Changed 7 years ago by Alpar Juttner

Resolution: done
Status: newclosed

Changesets [db1d342a1087] and [04f57dad1b07] are pushed to the main branch.

Note: See TracTickets for help on using tickets.