Skip to main content

How to print a run's seed?

Answered

Comments

3 comments

  • Riley Clement
    • Gurobi Staff

    Hi Atieh,

     

    Anyone knows how I can i print the run's seed without setting the seed Param?

    In Python:

    print(mymodel.params.Seed)

    For other APIs you can consult the Managing Parameters section of the overview, specific to that API, in our reference manual.

     

    I would like to know what seed the program itself chose for every run i execute

    It chooses the default every time. See Seed.

    If the value of Seed is not the default then this will be stated at the beginning of the log file.

    - Riley

     

    1
  • Atieh Madani
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you, i see that the default is 0, but does it mean the actual seed that program uses is 0? the reason I am asking is because sometimes the run time is much faster than other times where everything else is the same. I just assumed that is because the seed is different in every run?

    0
  • Riley Clement
    • Gurobi Staff

    Hi Atieh,

    If you're not changing the value of Seed, then it will take it's default value of 0.  At the beginning of a Gurobi log you should see any parameters that are not taking their default, eg

    Set parameter PreDepRow to value 1
    Set parameter Method to value 2
    Set parameter Seed to value 5

    Note the run should generally be deterministic if the termination criteria is not time-based, but there are exceptions: see Is Gurobi deterministic?

    If Gurobi is running deterministically then it will take the same solution path each time, however it may run faster or slower depending on what else is being run on the machine.  A bit of variability on your local machine would be expected, as no doubt there are all manner of processes being run, but if you're using a dedicated compute environment where there would be minimal "noise" and a machine runs one job only then I would not expect to see much difference in the run times.

    Noting that you have added the "Tuner" tag to the post, I'll mention that when the tuning tool runs several trials you see the following in the tuning log:

    Solving model.mps with random seed #1 ... MIP gap 0.16%
    Solving model.mps with random seed #2 ... MIP gap 0.19%
    Solving model.mps with random seed #3 ... MIP gap 0.14%
    Solving model.mps with random seed #4 ... MIP gap 0.17%
    Solving model.mps with random seed #5 ... MIP gap 0.17%

    In this case random seed #1 is either the default of 0, or whatever was specified by the user with the Seed parameter, then the value increases by 1 with each run.  So the default seeds in the example above would be 0,1,2,3,4.

    - Riley

     

     

    0

Please sign in to leave a comment.