# Three random choices in limitations

1. May 25, 2004

### Pattielli

I have six integer numbers and let's call them x,y,z,a,b and c.
All of them are to be in the [1,30] domain and satisfy the following conditions:

$$x=y+z$$

$$x<a , y<b , z<c$$

Now, if I start by "choosing a,b and c randomly first", Would you please tell me how I can randomly pick out the next three numbers (x,y,z) which still satisfy what I already mention above ?

Thank you very much,

2. May 25, 2004

### Pattielli

Go_in=go_out1+go_out2+....go_outn

3. May 25, 2004

### faust9

Randomly generate a,b, and c

test that $a \geq b+c$

if the above condition isn't true then $x<a, y<b, z<c$ when $x=y+z$ will never be true and will put your program into an endless loop.

Once you have 'a', 'b', and 'c' values that meets the conditions you can then randomly generate the 'x' , 'y', and 'z' values. Generate an 'y' value within a while loop and test to see if it meets the criteria of being less than 'b'. If it does then exit the loop. Same for 'z'. Once you have a 'y' and 'z' you can then simply add them and store the result into 'x'.

I don't know which language you're using so I can't tell you exactly how to do the above. Each language does things differently (loops are pretty standard though) so you'll have to figure the specifics out on your own. It's not that tough.

Well, good luck.

Last edited: May 25, 2004
4. May 25, 2004

### Pattielli

Another clearification:

Code (Text):
a--fa/ca-->b--fb/cb-->...
|          |
x--fx/cx-->y--fy/cy-->...
ca,cb,cx,cy are all known in advance and they capacities fi are all flows. Now i have to generate flows randomly and this "random_ness" blocks my way...
All of the capacities are stored in a vector and I already have a network...
Thank you,

5. May 25, 2004

### Pattielli

Thank faust very much for your help,
I can code in java, vb but I havent used them for long...
I like C/C++ and now I am solving this networkflow problem in C++.
I think I can manage to make a success with rand() function and do as what you told me but the problem is that I can't check the next move of the loop and randomize the x,y,z to satisfy the condition..
For example, below is my network
Code (Text):
0  1  1  0
0  0  1  1
0  0  0  1
0  0  0  0
and here is my capacity matrix
Code (Text):
0  12  21  0
0   0   1   2
0   0   0   1
0   0   0   0
Again Thank you

6. May 26, 2004

### Pattielli

I still have not been able to make it work....Help me please ?

7. May 26, 2004

### faust9

I don't understand what exactly you are trying to do. Where exactly are you having a problem? Is it the generation of random values that is troubling you or are you having trouble generating randome values that meet your criteria?

8. May 26, 2004

### Pattielli

I nowwould like to make a matrix of flows that satisfies the above conditions, each flow value will be randomly chosen. And that is the problem i am having, flow value=1~20 and smaller than cappacity on each equivalent edge

9. May 27, 2004

### faust9

Ok, I still don't know how you are using these matrices. Also, where are you having a problem? Are you having trouble generating and testing the variables or are you having trouble filling you arrays once you create your variable? How does the new criteria affect the variable tests? are you still bounded by the same criteria which you initially stated?

10. May 27, 2004

### Pattielli

Thank you,
As I already said, I used 2d vectors for storing these matrices..
Look at the capacity matrix, I now have to create another one and represent it as a flow matrix whose values are all randomly chosen between 1-20 and must satisfy the "Kirchoff" law (in=out), and that each element in flow matrix must be smaller than that in the capacity matrix (in an equivalent position I mean)....This is the way i am thinking of how to create this flow matrix, but if you have any other way to make this work and are willing to let me know, I will thank you very very much...