Three random choices in limitations

  • Thread starter Thread starter Pattielli
  • Start date Start date
  • Tags Tags
    Choices Random
Click For Summary

Discussion Overview

The discussion revolves around generating random integer values for a set of variables (x, y, z, a, b, c) under specific constraints, particularly in the context of network flow problems and Kirchhoff's law. Participants explore methods for ensuring that generated values satisfy given conditions while addressing programming challenges in various coding languages.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related
  • Mathematical reasoning

Main Points Raised

  • One participant outlines the conditions for generating x, y, and z based on randomly chosen a, b, and c, emphasizing the need for x = y + z and x < a, y < b, z < c.
  • Another participant draws a parallel to Kirchhoff's law, suggesting a relationship between the flow values and the conservation of flow in the network.
  • A suggestion is made to ensure that a ≥ b + c to avoid infinite loops when generating random values.
  • Participants discuss the challenges of implementing random generation in programming languages like C++, Java, and VB, particularly in relation to checking conditions within loops.
  • One participant expresses difficulty in creating a flow matrix that satisfies the constraints of being less than the capacity matrix while adhering to Kirchhoff's law.
  • There is a request for hints or alternative methods to create the flow matrix, indicating ongoing uncertainty about the approach.

Areas of Agreement / Disagreement

Participants express various challenges and uncertainties regarding the generation of random values and the implementation of conditions, indicating that the discussion remains unresolved with multiple competing views on how to approach the problem.

Contextual Notes

Participants mention specific programming constructs and conditions that may affect the generation of values, such as the need for values to be bounded by certain criteria and the implications of Kirchhoff's law on flow values.

Who May Find This Useful

This discussion may be useful for individuals interested in programming related to network flow problems, particularly those working with random number generation under specific constraints in C++, Java, or VB.

Pattielli
Messages
296
Reaction score
0
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,
 
Computer science news on Phys.org
This is the same as Kirchoff law in Electrics ? Please help me...
Go_in=go_out1+go_out2+...go_outn
 
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:
Another clearification:

Code:
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,
 
Thank faust very much for your help,
I can code in java, vb but I haven't 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:
0  1  1  0
0  0  1  1
0  0  0  1
0  0  0  0
and here is my capacity matrix
Code:
0  12  21  0
0   0   1   2
0   0   0   1
0   0   0   0

Again Thank you
 
I still have not been able to make it work...Help me please ?
 
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?
 
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
 
Pattielli said:
Thank faust very much for your help,
I can code in java, vb but I haven't 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:
0  1  1  0
0  0  1  1
0  0  0  1
0  0  0  0
and here is my capacity matrix
Code:
0  12  21  0
0   0   1   2
0   0   0   1
0   0   0   0

Again Thank you

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
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...
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 24 ·
Replies
24
Views
3K
  • · Replies 3 ·
Replies
3
Views
799
Replies
29
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K