Problem this random seed()
Hello everyone, i am using the MMK.py example from a SimPy tutorial, which can be found here: http://heather.cs.ucdavis.edu/~matloff/156/PLN/DESimIntro.pdf I have made very little changes to the code and i have upload it here: http://codeviewer.org/view/code:30d3 The problem is that i am executing the main() function in lines 83 and 90, but i do not receive the same result, although the random seed is used in the G class. Any idea please, how can i solve it ? Thanks, Nicholas. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
@eli m : The problem is that i execute on lines 83 and 90 the main() and although the seed value is the same, equal to 12345, i receive different results from lines 85 and 92. @alex23: I changed the code, http://codeviewer.org/view/code:30d4, but i still receive have the same problem. The results are different. Any help please -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
@eli m : The problem is that i execute on lines 83 and 90 the main() and although the seed value is the same, equal to 12345, i receive different results from lines 85 and 92. @alex23: I changed the code, http://codeviewer.org/view/code:30d4, but i still receive have the same problem. The results are different. Any idea please -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
Thank you @sven ! I thought that the time was reset automatically after calling the second main. Yes, i checked the values and they are the same. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
Sorry, my previous reply was completely wrong. The time is initialized through the initialize() to 0. So, each time i call main() the simulation time is initialized to 0. I changed the code in order to print and check the values of G.Rnd.expovariate(MachineClass.SrvRate) and G.Rnd.expovariate(ArrivalClass.ArvRate) here is the code and the changes i made : http://codeviewer.org/view/code:30d8 The values are not the same. The result i take is the following: Result from main() call No. 1 is 0.0452927906737 Result from main() call No. 2 is 0.0588336669949 2 First time Execution of Main Main [0.07267291894782457, 0.019146562687989536, 0.034780398625615376, 0.005528912370370478, 0.023636815811338075] [0.13472907136407936, 0.0025553071735785462, 0.08868344131130483, 0.05381286556098766, 0.044091180681591464] Second time Execution of Main [0.0335704752213292, 0.1321512230812724, 0.16025979406301488, 0.029210377271523574, 0.006680846943670858] [0.20642889529587374, 0.047894131266223446, 0.10958802111803392, 0.02393344456847461, 0.13280785022932287] -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
Probably a better code : http://codeviewer.org/view/code:30d9 I run the program once using comment in line 39 and then using comment in line 62. The results are not the same. The problem is with the Random. Although, i use seed value equal to 12345, i do not take the same results. :[ Any idea please -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
OK, i changed the code again. Delete the G class (The purpose of G class was to refer to global variables). Add Rnd.seed(12345) in main() function. The new code : http://codeviewer.org/view/code:30da i print the Rnd.expovariate(ArrivalClass.ArvRate). The output i get be executing the above code is the following : --- 0.134729071364 0.00255530717358 0.0886834413113 Result = 0.0571622124959 0.134729071364 0.00255530717358 0.0886834413113 Result = 0.0453791550084 --- So, the problem is probably with time (which is what @Stev mentioned before). But i still cant understand the reason. From the SimPy documentation : http://simpy.sourceforge.net/SimPyDocs/Manuals/SManual.html it says for the initialize(): "The initialize statement initialises global simulation variables and sets the software clock to 0.0. It must appear in your program before any SimPy process objects are activated." Any idea why that happens ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
Τη Τρίτη, 19 Μαρτίου 2013 3:57:30 π.μ. UTC+2, ο χρήστης NZach έγραψε: > Hello everyone, > > > > i am using the MMK.py example from a SimPy tutorial, which can be found here: > http://heather.cs.ucdavis.edu/~matloff/156/PLN/DESimIntro.pdf > > > > I have made very little changes to the code and i have upload it here: > > http://codeviewer.org/view/code:30d3 > > > > The problem is that i am executing the main() function in lines 83 and 90, > but > > i do not receive the same result, although the random seed is used in the G > > class. > > > > Any idea please, how can i solve it ? > > > > > > Thanks, > > > > Nicholas. Yes, sorry, I meant @sven not @Stev. The problem with the random number is solved. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem this random seed()
Τη Τρίτη, 19 Μαρτίου 2013 5:23:47 μ.μ. UTC+2, ο χρήστης NZach έγραψε: > Τη Τρίτη, 19 Μαρτίου 2013 3:57:30 π.μ. UTC+2, ο χρήστης NZach έγραψε: > > > Hello everyone, > > > > > > > > > > > > i am using the MMK.py example from a SimPy tutorial, which can be found > > here: http://heather.cs.ucdavis.edu/~matloff/156/PLN/DESimIntro.pdf > > > > > > > > > > > > I have made very little changes to the code and i have upload it here: > > > > > > http://codeviewer.org/view/code:30d3 > > > > > > > > > > > > The problem is that i am executing the main() function in lines 83 and 90, > > but > > > > > > i do not receive the same result, although the random seed is used in the > > G > > > > > > class. > > > > > > > > > > > > Any idea please, how can i solve it ? > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > Nicholas. > > > > Yes, sorry, I meant @sven not @Stev. > > > > The problem with the random number is solved. Thank you very much for the replies. I will check what the now() prints and probably if i wont find any solution i will create new topic. -- http://mail.python.org/mailman/listinfo/python-list
