Skip to content

uniform_on_restart is not inlcude the int: high value. #208

@kieronqtran

Description

@kieronqtran

Describe the bug

The function uniform_on_restart doesn't return the upper bound value in the runtime, which is expected to return a random number x between lower and upper (lower <= x <= upper, but the actual result is lower <= x < upper.

This is happened becasue Rnd _random input domain is [lower_bound, upper_bound) and + 1 to correct set to [lower_bound, upper_bound], and it is effect to uniform_on_restart constraints. Which can be found in this PR #207

To Reproduce

Run these MiniZinc model with -restart constant and -restart-scale 5

include "experimental/on_restart.mzn";
var 1..3: nbh_size ::output = uniform_on_restart(1..3);
---
nbh_size = 1;
% time elapsed: 67msec
----------
nbh_size = 2;
% time elapsed: 73msec
----------
include "experimental/on_restart.mzn";
var 1..3: nbh_size ::output = uniform_on_restart(1, 3);
---
nbh_size = 1;
% time elapsed: 67msec
----------
nbh_size = 2;
% time elapsed: 73msec
----------

The work around:

include "experimental/on_restart.mzn";
var 1..3: nbh_size ::output = uniform_on_restart(1, 4);
nbh_size3 = 2;
% time elapsed: 59msec
----------
nbh_size3 = 1;
% time elapsed: 65msec
----------
nbh_size3 = 3;
% time elapsed: 66msec
----------

Gecode and Platform Configuration

Gecode 6.3.0 on MacOS Tahoe 26.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions