Dynamic Pricing Game

Notebook for testing your algorithms

You can use this notebook to run your buyer/seller algorithms and compare them to the naive ones provided.

In the below code, make any necessary changes as indicated by the TODO comments.


In [1]:
import sys
import os
import matplotlib.pyplot as plt
import numpy.random as rn
import numpy as np

%matplotlib inline

# TODO: write the path to the root directory of the simulation game code below. 
# It should have a README.md file under it and 'simulation_game', 'simulation_algos', 'test directories' under it.
path_to_game_code = "<TODO-CHANGE-THIS>/DynamicPricingGame"
sys.path.append(path_to_game_code)
os.environ['PYTHONPATH'] = path_to_game_code

from simulation_game.simulation import simulate

# TODO: you need to change the name of the file and the classes!
from simulation_algos.teamname import TeamNameBuyer, TeamNameSeller

from simulation_game.buyer import MyopicBuyer
from simulation_game.seller import DummySeller

If everything works you can test your algorithms below:


In [2]:
# Set these parameters how you want for testing
price_scale = 3
mc_trials = 100
x_0 = 3
horizon = 4

# Set the seed so that you get the same random number sequences in every run (makes it easier to debug and test)
rn.seed(123)

# Create your buyer and seller objects
your_buyer = TeamNameBuyer()
your_seller = TeamNameSeller()

# Algorithms to compare your ones against. These are the simple ones that we provide for you
simple_buyer = MyopicBuyer("MyopicBuyer")
simple_seller = DummySeller("DummySeller")

# 2 teams are formed. One team is you and the other is the simple A.I.
teams = [(your_buyer, your_seller), (simple_buyer, simple_seller)]

# Simulate and print the mean revenue and consumer surplus for the two teams (where the order is the same as how
# the teams were defined)
mean_revenue, mean_cs = simulate(teams, horizon, x_0, mc_trials, price_scale)
print mean_revenue, mean_cs


[ 0.0961108  0.       ] [ 0.         0.0538892]

Good luck!