Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  rand() function problem

    Posted Thu February 01, 2018 06:16 AM

    Originally posted by: memo85


    Hi. 

    I use the rand() function in my model to generate a random set for using problem parameters. In Opl documentation, it says that the rand function generates the pseudorandom number and then it can be possible to generate same values. But when I run the model each time, rand() function generates the same values so I can not investigate the effect of the randomness on the solution. How can the different values generate in each run by using rand function? Or is there a different way to generate random function in OPL? 

     

    Thank you in advance. 


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: rand() function problem

    Posted Mon February 05, 2018 09:39 AM

    Originally posted by: ol


    Hello,

    you can use srand(int seed) to give a seed to the pseudo random generator.

    Regards,

    ol


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: rand() function problem

    Posted Mon February 05, 2018 02:19 PM

    Originally posted by: memo85


    Thank you ol. I have tried your suggestion, but the problem is still going on. The function gives the same values for each run. However, I would like to generate the different values. 

    Regards.

    Mehmet.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: rand() function problem

    Posted Mon February 05, 2018 02:36 PM

    Originally posted by: ol


    you need to change the seed at each new run.

    (to automatize the change, for instance, you can take the time, or you can write in a file a counter of the runs and use this counter as a seed)

    Regards

    ol


    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: rand() function problem

    Posted Tue February 06, 2018 01:46 AM

    Originally posted by: memo85


    Thank you ol. The function generates the values by changing the seed. 

    Regards. 

    Mehmet.


    #ConstraintProgramming-General
    #DecisionOptimization