# Algorithm Design for Scheme Implementation

Based on the above analysis of four-stage Stackelberg game, we present an iteration algorithm to implement our scheme. For the cloud resource, it can update its cloud resource price to obtain a maximum utility and then announce this price to all brokers. Since the media cloud is not aware of the duration of each adjustment, the media cloud sets a waiting time Twmc for the next strategy update. Similarly, as each broker is not aware of the duration of each evolution, it sets a waiting Tw,b for the next strategy to update the size of the purchased cloud resource and the price to charge users. In the evolutionary game, each user randomly selects a broker to connect initially, and then changes his strategy to maximize his own utility. If a users utility is lower than the average utility of his community, this user may change his connection with a probability, denoted by

where Uj is the average utility of community j. When all users in the same community obtain an equal utility, the evolution will be completed. We present the algorithm by Algorithm 1.

Algorithm 1: Resource allocation iteration algorithm

• 1: Initially, the media cloud announces the price p(0) to all brokers.
• 2: Repeat
• 3: while t < Tw>mc do
• 4: Each broker randomly determines the size of leased resource Ei and the price pi.
• 5: Repeat.
• 6: while t < Tw,b do
• 7: Each user randomly makes connection.
• 8: Repeat.
• 9: Compute each user’s utility by (5.22).
• 10: Exchange connection information with each other in the community.
• 11: Calculate the average utility Uj by (5.28).
• 12: if Uj > Ui, j then
• 13: Change the connection with probability в.
• 14: else
• 15: Maintain the connection.
• 16: end if
• 17: Until all users in the same community have the equal utility.
• 18: end while
• 19: Update cloud resource size Ei ) and the cloud resource price pi ) by equations (5.36)-(5.39).
• 20: т = т + 1
• 21: Until Ei and pi are both unchanged.
• 22: end while
• 23: Update the price p(t) by Eqs. (5.41), (5.42).
• 24: t = t + 1
• 25: Until p is unchanged.