-
Solving relationships...
Hi,
I am working on a program and am wondering if someone can point me in the right direction with a certain concept.
I would like my program to use a trial and error method of finding values for a series of variables which are related to one another by greater-than/less-than's in a series of predetermined rules.
So my basic idea is that the program will randomly choose one of the variables to generate a random value for. It will then check the value of this variable against the other variables in terms of the greater-than/less-than rules, and if the value does not break any rules, it will keep that value and move onto generating a value for the next variable, etc.
My first concern is that I need to be able to store null values for each variable's value until it is determined in the above sequence.
Here is an example:
Variable1 = 5
Variable2 = NULL
Variable3 = NULL
Variable1 < Variable2 < Variable3
GENERATE RANDOM VALUE FOR Variable2
If Variable1 > Variable2, then regenerate Variable2.
If Variable2 > Variable3, then regenerate Variable2.
So, as you can see, Variable3 needs to be kept NULL here, rather than having a default value of zero or something.
How do I go about this?
Also, can anyone point me to some text that might discuss these types of programming issues.
Thanks
-
My suggestion is to "know where you are". IOW: when generating variable2, you know variable3 hasn't been assigned yet, so don't even try checking it since it doesn't matter.