Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Three random choices in limitations

  1. May 25, 2004 #1
    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:

    [tex]x=y+z[/tex]

    [tex]x<a , y<b , z<c[/tex]

    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. jcsd
  3. May 25, 2004 #2
    This is the same as Kirchoff law in Electrics ? Please help me...
    Go_in=go_out1+go_out2+....go_outn
     
  4. May 25, 2004 #3
    Randomly generate a,b, and c

    test that [itex] a \geq b+c[/itex]

    if the above condition isn't true then [itex]x<a, y<b, z<c[/itex] when [itex]x=y+z[/itex] 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
  5. May 25, 2004 #4
    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...
    Now you already see how it is...please give me some hints...
    Thank you,
     
  6. May 25, 2004 #5
    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
     
  7. May 26, 2004 #6
    I still have not been able to make it work....Help me please ?
     
  8. May 26, 2004 #7
    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?
     
  9. May 26, 2004 #8
    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
     
  10. May 27, 2004 #9
    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?
     
  11. May 27, 2004 #10
    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...

    Do you have any instructions? Please help...
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Three random choices in limitations
Loading...