table f = spline({5, 100}, {10, 73}, {15, 57},  {20, 45}, {25, 35}, {35, 22}, {40, 18}, {45, 14}, {50, 10})

table g = spline({0.5, 2.00}, {0.6, 1.8}, {0.7, 1.55}, {0.8, 1.35}, {0.9, 1.15}, {1, 1.00}, {1.1, 0.875},
		 {1.2, 0.75}, {1.3, 0.65}, {1.4, 0.55}, {1.5, 0.5})

table h = spline({0,0}, {5,0}, {10,400}, {15,57}, {20,68}, {25,77}, {30,84}, {35,89}, {40,94}, {45,97}, {50,100})

param price_change_delay = 15
param init_price = 15
param desired_inventory_coverage = 4.0

state price = init_price
state inventory = f(init_price)*desired_inventory_coverage

aux demand_price_schedule = f(price)
aux demand = demand_price_schedule + ((t>=10.0)?10.0:0.0)

aux desired_inventory =  demand*desired_inventory_coverage
aux inventory_ratio = inventory/desired_inventory

aux effect_on_price = g(inventory_ratio)
aux desired_price = effect_on_price*price

aux suppy_price_schedule = h(price)

aux supply = suppy_price_schedule
aux shipments = demand

price'= (desired_price - price)/price_change_delay
inventory' = supply - shipments

//print t, price, inventory

option tstart=0, tstop=80, outstep=0.5