Adding user defined random generator#22
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an option for the user to build
NormalizedBw,SawtoothBw,NormalizedDelayPerPacket, andLogNormalizedDelayPerPacketwith a custom random generator.Description
StdRngwhich is the currently used random generator is not portable, meaning that on different architectures, or in the future, the randomly generated sequence could be differentI kept the default behavior, using
StdRng, but added functions ending by_with_rng(build_with_rngfor all andbuild_truncated_with_rngfor normal laws) that let the user choose the random generator.I modified the following types by making them parameterized (with
StdRngas the default type):NormalizedBwbecameNormalizedBw<Rng = StdRng>SawtoothBwNormalizedDelayPerPacketLogNormalizedDelayPerPacketI added the functions:
build_with_rng<Rng: RngCore + SeedableRng>(self) -> Self<Rng>for :NormalizedBwSawtoothBwNormalizedDelayPerPacketLogNormalizedDelayPerPacketbuild_truncated_with_rng<Rng: RngCore + SeedableRng(mut self) -> Self<Rng>for:NormalizedBwNormalizedDelayPerPacketI also added some documentation for the config of the models.
How Has This Been Tested
I tested (on Ubuntu 24.04) using the unit test and doc test included (I added several doc tests), and I'm open to adding additional ones.
Types of changes
Checklist