I have written a code in which I need an array having numbers between 2 to 5 and the total sum of the array should be 100. I am getting the below error:
*Solver failed when solving following set of constraints
The constraints are written in such a way that the size can be different everytime the array is randomized. So, that reason should not be throwing the error. Need more inputs.
From section 18.4 of the LRM:
If a dynamic array’s size is not constrained, then the array shall not be resized and all the array
elements shall be randomized.
In this case, the array is of size 0, and since the size isn’t constrained, it remains 0 and you get no elements in the array.
So how do I get away from this problem? Basically I need an array having element values between 2 to 5 (including both) and the total sum of that array has to be equal to 100.
Try constraining the size of the array, say, array.size > 19 and array.size < 51 (if all elements are 2, min size needed is 50 and if all the elements are 5 the min size is 20)