I am trying to automatically generate a large set of test data and I am struggling to understand how to generate a set of random values required.
I need to create a set of random values which occur within different ranges. The sum of the resulting values must be over or under a predetermined value depending on the test case.
For example,
Value | Minimum value | Maximum Value
A | 100 | 300
B | 200 | 500
C | 300 | 600
D | 100 | 300
If the sum of values must be greater than 800 a valid solution would be
A = 200
B = 400
C = 500
D = 100
If the sum of values must be less than 800 a valid solution would be
A = 100
B = 200
C = 300
D = 100
Can this problem only be solved using an optimisation function? Is there any other way to calculate the values of ABCD?
I am looking to solve this problem using SQL but would be interested to hear a pseudo-code approach too.
Try and try again until you get what you want.