from typing import Any, Optional, Tuple, Union import numpy as np def p( current_selling_season: int, selling_period_in_current_season: int, prices_historical_in_current_season: Union[np.ndarray, None], demand_historical_in_current_season: Union[np.ndarray, None], competitor_has_capacity_current_period_in_current_season: bool, information_dump=Optional[Any], ) -> Tuple[float, Any]: """Determine which price to set for the next period. Parameters ---------- current_selling_season : int The current selling season (1, 2, 3, ...). selling_period_in_current_season : int The period in the current season (1, 2, ..., 1000). prices_historical_in_current_season : Union[np.ndarray, None] A two-dimensional array of historical prices. The rows index the competitors and the columns index the historical selling periods. Equal to `None` if `selling_period_in_current_season == 1`. demand_historical_in_current_season : Union[np.ndarray, None] A one-dimensional array of historical (own) demand. Equal to `None` if `selling_period_in_current_season == 1`. competitor_has_capacity_current_period_in_current_season : bool `False` if competitor is out of stock information_dump : Any, optional To keep a state (e.g., a trained model), by default None Examples -------- >>> prices_historical_in_current_season.shape == (2, selling_period_in_current_season - 1) True >>> demand_historical_in_current_season.shape == (selling_period_in_current_season - 1, ) True Returns ------- Tuple[float, Any] The price and a the information dump (with, e.g., a state of the model). """ if selling_period_in_current_season == 1: # Randomize in the first period of the season price = np.random.uniform(1, 10) else: # Set the price that my competitor set in the previous period price = prices_historical_in_current_season[1, -1] return price, None