cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a number of methods randomly?

Creator
Creator

Hi every one,

I need to run a method for a year, each day a main method must call 4 other methods. Each of those 4 methods belongs to a different company and calls a chain of other methods in order to do some slot reservation. There are a limited number of slots available and each of the 4 companies are willing to pick as many as possible slots.

Now the problem is that, I am able to call those 4 methods one by one and it means the first company has the higher chance to get the slots, then the second company, then third and the fourth company has the lowest chance since the first called method is related to the first company and so on. How can I call them randomly each day of the year or in a way that each company has the same chance of getting the slots?

I appreciate your help in advance and hope someone has a solution for my problem. Smiley Happy

4 REPLIES

Re: How to call a number of methods randomly?

Phenom
Phenom
There is no way to run several methods "at the same time".
So you could change the order of the method calls or you could transfer a random priority with the call.
e.g. Make one central method (virtual auctioneer) for distribute the slots. The auctioneer waits until all bids are arrived (e.g. as entries in a table) and distribute the slots depend of the high of the bids (priority).

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: How to call a number of methods randomly?

Creator
Creator

Dear steffen,

 

Thank you for your reply. My model is much more complicated than what i wrote. It is not really possible to change the basic procedures. So the best option can be changing the order of 4 methods (which are called by a main method) daily, but how is it possible?

Re: How to call a number of methods randomly?

Phenom
Phenom
only an idea for a method:
write the names of the methods into a table,
dice a number between 1 and 4 (e.,g. z_uniform), read the row with the random number
start the first method (e.g. str_to_obj(tab[1,randNo]).methCall(0) ), delete the row;
then dice a number between 1 and 3 --> etc. until the table is empty


Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: How to call a number of methods randomly?

Creator
Creator

That seems a great solution for my problem. Thanks alot for your help Smiley Happy .