simopt.models.amusementpark =========================== .. py:module:: simopt.models.amusementpark .. autoapi-nested-parse:: Simulate a single day of operation for an amusement park queuing problem. Module Contents --------------- .. py:data:: INF .. py:data:: PARK_CAPACITY :type: Final[int] :value: 350 .. py:data:: NUM_ATTRACTIONS :type: Final[int] :value: 7 .. py:class:: AmusementParkConfig Bases: :py:obj:`pydantic.BaseModel` Configuration for the Amusement Park model. .. py:attribute:: park_capacity :type: Annotated[int, Field(default=PARK_CAPACITY, description='The total number of tourists waiting for attractions that can be maintained through park facilities, distributed across the attractions.', ge=0)] .. py:attribute:: number_attractions :type: Annotated[int, Field(default=NUM_ATTRACTIONS, description='The number of attractions in the park.', ge=0, json_schema_extra={'isDatafarmable': False})] .. py:attribute:: time_open :type: Annotated[float, Field(default=480.0, description='The number of minutes per day the park is open.', ge=0)] .. py:attribute:: erlang_shape :type: Annotated[list[int], Field(default_factory=lambda: [2] * NUM_ATTRACTIONS, description='The shape parameter of the Erlang distribution for each attraction duration.')] .. py:attribute:: erlang_scale :type: Annotated[list[float], Field(default_factory=lambda: [1 / 9] * NUM_ATTRACTIONS, description='The rate parameter of the Erlang distribution for each attraction duration.')] .. py:attribute:: queue_capacities :type: Annotated[list[int], Field(default_factory=lambda: [50] * NUM_ATTRACTIONS, description='The capacity of the queue for each attraction based on the portion of facilities allocated.')] .. py:attribute:: depart_probabilities :type: Annotated[list[float], Field(default_factory=lambda: [0.2] * NUM_ATTRACTIONS, description='The probability that a tourist will depart the park after visiting an attraction.')] .. py:attribute:: arrival_gammas :type: Annotated[list[int], Field(default_factory=lambda: [1] * NUM_ATTRACTIONS, description='The gamma values for the poisson distributions dictating the rates at which tourists entering the park arrive at each attraction')] .. py:attribute:: transition_probabilities :type: Annotated[list[list[float]], Field(default_factory=lambda: [[0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0], [0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0], [0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0], [0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0], [0.1, 0.1, 0.1, 0.1, 0, 0.1, 0.3], [0.1, 0.1, 0.1, 0.1, 0.1, 0, 0.3], [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2]], description='The transition matrix that describes the probability of a tourist visiting each attraction after their current attraction.')] .. py:class:: AmusementParkMinDepartConfig Bases: :py:obj:`pydantic.BaseModel` Configuration model for Amusement Park Min Depart Problem. A problem configuration that minimizes the total number of departed visitors from an amusement park by optimizing queue capacities. .. py:attribute:: initial_solution :type: Annotated[tuple[int, Ellipsis], Field(default_factory=lambda: (PARK_CAPACITY - NUM_ATTRACTIONS + 1, ) + (1, ) * (NUM_ATTRACTIONS - 1), description='Initial solution from which solvers start.')] .. 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:: AmusementPark(fixed_factors: dict | None = None) Bases: :py:obj:`simopt.base.Model` Amusement Park Model. A model that simulates a single day of operation for an amusement park queuing problem based on a poisson distributed tourist arrival rate, a next attraction transition matrix, and attraction durations based on an Erlang distribution. Returns the total number and percent of tourists to leave the park due to full queues. Initialize the Amusement Park Model. .. py:attribute:: class_name_abbr :type: ClassVar[str] :value: 'AMUSEMENTPARK' Short name of the model class. .. py:attribute:: class_name :type: ClassVar[str] :value: 'Amusement Park' 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: 3 Number of RNGs used to run a simulation replication. .. py:attribute:: n_responses :type: ClassVar[int] :value: 4 Number of responses (performance measures). .. py:attribute:: arrival_model .. py:attribute:: attraction_model .. py:attribute:: destination_model .. py:attribute:: service_models :value: [] .. 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[str, float | list[float]], dict] Simulate a single replication using current model factors. :param rng_list: Random number generators used during the simulation. :type rng_list: list[MRG32k3a] :returns: A tuple containing: - dict[str, float | list[float]]: Performance metrics from the simulation: - "total_departed_tourists": Total number of tourists who left due to full queues. - "percent_departed_tourists": Percentage of tourists who left due to full queues. - "average_number_in_system": Average number of tourists in the park at a given time. - "attraction_utilization_percentages": Utilization percentage of each attraction. - dict: Gradients of the performance measures with respect to model factors. :rtype: tuple .. py:class:: AmusementParkMinDepart(name: str = '', fixed_factors: dict | None = None, model_fixed_factors: dict | None = None) Bases: :py:obj:`simopt.base.Problem` Class to make amusement park 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: 'AMUSEMENTPARK-1' Short name of the problem class. .. py:attribute:: class_name :type: ClassVar[str] :value: 'Min Total Departed Visitors for Amusement Park' 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]] 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[str, tuple] 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