Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class ModelRandomGenerator
Note: This documentation is automatically generated.
The model "singleton" random engine used in the solver.
In test, we usually set use_absl_random() so that the sequence is changed at
each invocation. This way, clients do not relly on the wrong assumption that
a particular optimal solution will be returned if they are many equivalent
ones.
This is just used to display ABSL_RANDOM_SALT_OVERRIDE in the log so that
it is possible to reproduce a failure more easily while looking at a solver
log.
TODO(user): I didn't find a cleaner way to log this.
We seed the strategy at creation only. This should be enough for our use
case since the SatParameters is set first before the solver is created. We
also never really need to change the seed afterwards, it is just used to
diversify solves with identical parameters on different Model objects.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eModelRandomGenerator\u003c/code\u003e is a singleton random engine used within the solver, primarily for diversification of solutions.\u003c/p\u003e\n"],["\u003cp\u003eIn testing environments, \u003ccode\u003euse_absl_random()\u003c/code\u003e is typically employed to alter the random sequence with each invocation, preventing reliance on specific optimal solutions when multiple equivalents exist.\u003c/p\u003e\n"],["\u003cp\u003eThe random seed is established during the creation of the \u003ccode\u003eModelRandomGenerator\u003c/code\u003e and remains constant thereafter, serving to differentiate solutions across distinct \u003ccode\u003eModel\u003c/code\u003e objects with identical parameters.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eLogSalt\u003c/code\u003e aids in reproducibility of solver failures by logging the \u003ccode\u003eABSL_RANDOM_SALT_OVERRIDE\u003c/code\u003e value.\u003c/p\u003e\n"]]],["The `ModelRandomGenerator` class provides a singleton random engine for the solver. In testing, `use_absl_random()` is enabled to alter the sequence on each invocation, preventing reliance on specific optimal solutions. The `LogSalt` method displays the `ABSL_RANDOM_SALT_OVERRIDE` in logs for reproducibility. `ModelRandomGenerator` is seeded at creation, ensuring diversified solutions across different `Model` objects with identical parameters. It takes as input `Model* model` and the seed is not meant to be modified.\n"],null,["# ModelRandomGenerator\n\nC++ Reference: class ModelRandomGenerator\n=========================================\n\n\nNote: This documentation is automatically generated.\nThe model \"singleton\" random engine used in the solver. \n\nIn test, we usually set use_absl_random() so that the sequence is changed at each invocation. This way, clients do not relly on the wrong assumption that a particular optimal solution will be returned if they are many equivalent ones.\n\n| Method ||\n|------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`LogSalt`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L146) | Return type: `void ` This is just used to display ABSL_RANDOM_SALT_OVERRIDE in the log so that it is possible to reproduce a failure more easily while looking at a solver log. TODO(user): I didn't find a cleaner way to log this. |\n| [`ModelRandomGenerator`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/util.h#L131) | Return type: `explicit ` Arguments: `Model* model` We seed the strategy at creation only. This should be enough for our use case since the SatParameters is set first before the solver is created. We also never really need to change the seed afterwards, it is just used to diversify solves with identical parameters on different Model objects. |"]]