In reply to dave_59:
Hi Dave,
I don’t want to open a new thread because it is very similar to this one.
I have a situation where one element (or more) has to be of specific value (19).
I tried your solution but I don’t get good results. I don’t get any element with specified value, more like normal randomization.
rand int max_def[];
rand int max_nesting_depth; // randomized to 19
rand bit force_max_nesting_depth; // randomized to 1
if (force_max_nesting_depth) {
max_def.sum() with (int'(item == max_nesting_depth)) == 1;
}
I have other constraints for max_def, but randomization should fail if there is no solution to randomization.