import numpy as np from typing import Any, Optional, Tuple, Union def p( prices_historical: Union[np.ndarray, None], demand_historical: Union[np.ndarray, None], information_dump: Optional[Any], ) -> Tuple[float, Any]: """Return the average of the last observed prices. Parameters ---------- prices_historical : Union[np.ndarray, None] The shape is (number competitors) x (past iterations) and contains the past prices of each competitor. You are at index 0. Equal to `None` in the first time period. demand_historical : Union[np.ndarray, None] A single-dimensional array of length equal to the number of past iterations. and contains the history of your own past observed demand. Equal to `None` in the first time period. information_dump : Optional[Any] Some information object you like to pass to yourself at the next iteration Returns ------- Tuple[Tuple[float, float, float], Any] A tuple (or list) of length three (containing the prices) and the information dump. """ # Check if we are in the very first call to our function and then return random prices if demand_historical is None: random_prices = np.round(np.random.uniform(30, 80), 1) return random_prices, None # Set the price as the average prices posted last period competitor_prices = prices_historical[1:, -1] price_to_set = np.mean(competitor_prices) return price_to_set, None