simopt.models.hotel =================== .. py:module:: simopt.models.hotel .. autoapi-nested-parse:: Simulate expected revenue for a hotel. Module Contents --------------- .. py:class:: HotelConfig Bases: :py:obj:`pydantic.BaseModel` Configuration model for Hotel simulation. A model that simulates business of a hotel with Poisson arrival rate. .. py:attribute:: num_products :type: Annotated[int, Field(default=56, description='number of products: (rate, length of stay)', gt=0)] .. py:attribute:: lambda_ :type: Annotated[list[float], Field(default_factory=lambda: [x / 168 for x in _double_up([1, 2, 3, 2, 1, 0.5, 0.25, 1, 2, 3, 2, 1, 0.5, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 2, 3, 1, 2, 1])], description='arrival rates for each product', alias='lambda')] .. py:attribute:: num_rooms :type: Annotated[int, Field(default=100, description='hotel capacity', gt=0)] .. py:attribute:: discount_rate :type: Annotated[int, Field(default=100, description='discount rate', gt=0)] .. py:attribute:: rack_rate :type: Annotated[int, Field(default=200, description='rack rate (full price)', gt=0)] .. py:attribute:: product_incidence :type: Annotated[list[list[int]], Field(default_factory=lambda: [_gen_binary_list([0, 14, 42]), _gen_binary_list([2, 24, 30]), _gen_binary_list([4, 10, 2, 20, 20]), _gen_binary_list([6, 8, 4, 8, 2, 16, 12]), _gen_binary_list([8, 6, 6, 6, 4, 6, 2, 12, 6]), _gen_binary_list([10, 4, 8, 4, 6, 4, 4, 4, 2, 8, 2]), _gen_binary_list([12, 2, 10, 2, 8, 2, 6, 2, 4, 2, 2, 4])], description='incidence matrix')] .. py:attribute:: time_limit :type: Annotated[list[int], Field(default_factory=lambda: [27] * 14 + [51] * 12 + [75] * 10 + [99] * 8 + [123] * 6 + [144] * 4 + [168] * 2, description='time after which orders of each product no longer arrive (e.g. Mon night stops at 3am Tues or t=27)')] .. py:attribute:: time_before :type: Annotated[int, Field(default=168, description='hours before t=0 to start running (e.g. 168 means start at time -168)', gt=0)] .. py:attribute:: runlength :type: Annotated[int, Field(default=168, description='runlength of simulation (in hours) after t=0', gt=0)] .. py:attribute:: booking_limits :type: Annotated[tuple[int, Ellipsis], Field(default_factory=lambda: tuple([100] * 56), description='booking limits')] .. py:class:: HotelRevenueConfig Bases: :py:obj:`pydantic.BaseModel` Configuration model for Hotel Revenue Problem. Max Revenue for Hotel Booking simulation-optimization problem. .. py:attribute:: initial_solution :type: Annotated[tuple[int, Ellipsis], Field(default_factory=lambda: tuple([0 for _ in range(56)]), description='initial solution')] .. py:attribute:: budget :type: Annotated[int, Field(default=100, description='max # of replications for a solver to take', gt=0, json_schema_extra={'isDatafarmable': False})] .. py:class:: Hotel(fixed_factors: dict | None = None) Bases: :py:obj:`simopt.base.Model` A model that simulates business of a hotel with Poisson arrival rate. Initialize the Hotel model. :param fixed_factors: Fixed factors for the model. Defaults to None. :type fixed_factors: dict, optional .. py:attribute:: class_name_abbr :type: ClassVar[str] :value: 'HOTEL' Short name of the model class. .. py:attribute:: class_name :type: ClassVar[str] :value: 'Hotel Booking' Long name of the model class. .. py:attribute:: config_class :type: ClassVar[type[pydantic.BaseModel]] Configuration class for the model. .. py:attribute:: n_rngs :type: ClassVar[int] :value: 1 Number of RNGs used to run a simulation replication. .. py:attribute:: n_responses :type: ClassVar[int] :value: 1 Number of responses (performance measures). .. py:attribute:: arrival_model .. py:method:: before_replicate(rng_list: list[mrg32k3a.mrg32k3a.MRG32k3a]) -> None Prepare the model just before generating a replication. :param rng_list: RNGs used to drive the simulation. :type rng_list: list[MRG32k3a] :raises NotImplementedError: If the subclass does not implement this hook. .. py:method:: replicate() -> tuple[dict, dict] Simulate a single replication for the current model factors. :param rng_list: Random number generators used to simulate the replication. :type rng_list: list[MRG32k3a] :returns: A tuple containing: - responses (dict): Performance measures of interest, including: - "revenue": Expected revenue. - gradients (dict): A dictionary of gradient estimates for each response. :rtype: tuple[dict, dict] .. py:class:: HotelRevenue(name: str = '', fixed_factors: dict | None = None, model_fixed_factors: dict | None = None) Bases: :py:obj:`simopt.base.Problem` Base class to implement simulation-optimization problems. Initialize a problem object. :param name: Name of the problem. :type name: str :param fixed_factors: Dictionary of user-specified problem factors. :type fixed_factors: dict | None :param model_fixed_factors: Subset of user-specified non-decision factors passed to the model. :type model_fixed_factors: dict | None .. py:attribute:: class_name_abbr :type: ClassVar[str] :value: 'HOTEL-1' Short name of the problem class. .. py:attribute:: class_name :type: ClassVar[str] :value: 'Max Revenue for Hotel Booking' Long name of the problem class. .. py:attribute:: config_class :type: ClassVar[type[pydantic.BaseModel]] Configuration class for problem. .. py:attribute:: model_class :type: ClassVar[type[simopt.base.Model]] Simulation model class for problem. .. py:attribute:: n_objectives :type: ClassVar[int] :value: 1 Number of objectives. .. py:attribute:: n_stochastic_constraints :type: ClassVar[int] :value: 0 Number of stochastic constraints. .. py:attribute:: minmax :type: ClassVar[tuple[int, Ellipsis]] :value: (1,) Indicators of maximization (+1) or minimization (-1) for each objective. .. py:attribute:: constraint_type :type: ClassVar[simopt.base.ConstraintType] Description of constraints types. .. py:attribute:: variable_type :type: ClassVar[simopt.base.VariableType] Description of variable types. .. py:attribute:: gradient_available :type: ClassVar[bool] :value: False Indicates whether the solver provides direct gradient information. .. py:attribute:: optimal_value :type: ClassVar[float | None] :value: None Optimal objective function value (if known). .. py:attribute:: optimal_solution :type: tuple | None :value: None Optimal solution if known; defaults to None. .. py:attribute:: model_default_factors :type: ClassVar[dict] Default values for overriding model-level default factors. .. py:attribute:: model_decision_factors :type: ClassVar[set[str]] Set of keys for factors that are decision variables. .. py:property:: dim :type: int Number of decision variables. .. py:property:: lower_bounds :type: tuple Lower bound for each decision variable. .. py:property:: upper_bounds :type: tuple Upper bound for each decision variable. .. py:method:: vector_to_factor_dict(vector: tuple) -> dict Convert a vector of variables to a dictionary with factor keys. :param vector: A vector of values associated with decision variables. :type vector: tuple :returns: Dictionary with factor keys and associated values. :rtype: dict .. py:method:: factor_dict_to_vector(factor_dict: dict) -> tuple Convert a dictionary with factor keys to a vector of variables. :param factor_dict: Dictionary with factor keys and associated values. :type factor_dict: dict :returns: Vector of values associated with decision variables. :rtype: tuple .. py:method:: replicate(_x: tuple) -> simopt.base.RepResult Replicate the problem for a given solution. :param x: The solution to evaluate. :type x: tuple .. py:method:: check_deterministic_constraints(_x: tuple) -> bool Check if a solution `x` satisfies the problem's deterministic constraints. :param x: A vector of decision variables. :type x: tuple :returns: True if the solution satisfies all deterministic constraints; False otherwise. :rtype: bool .. py:method:: get_random_solution(rand_sol_rng: mrg32k3a.mrg32k3a.MRG32k3a) -> tuple Generate a random solution for starting or restarting solvers. :param rand_sol_rng: Random number generator used to sample the solution. :type rand_sol_rng: MRG32k3a :returns: A tuple representing a randomly generated vector of decision variables. :rtype: tuple