Last active
February 13, 2020 04:16
-
-
Save ikatsov/91bccbb863e317d9990182a1ea70098b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find_optimal_price_t(p_baseline, price_grid, t): # evalutes all possible price schedules | |
| p_grid = np.tile(p_baseline, (len(price_grid), 1)) # derived from the baseline by | |
| p_grid[:, t] = price_grid # changing the price at time t | |
| profit_grid = np.array([ profit_response(p) for p in p_grid ]) | |
| return price_grid[ np.argmax(profit_grid) ] | |
| p_opt = np.repeat(price_opt_const, T) # start with the constant price schedule | |
| for t in range(T): # and optimize one price at a time | |
| price_t = find_optimal_price_t(p_opt, price_grid, t) | |
| p_opt[t] = price_t | |
| print(f'Achieved profit is {profit_response(p_opt)}') | |
| plt.plot(range(len(p_opt)), p_opt, c='red') | |
| #> Achieved profit is 2903637.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment