simopt.models.amusementpark

Simulate a single day of operation for an amusement park queuing problem.

Module Contents

simopt.models.amusementpark.INF
simopt.models.amusementpark.PARK_CAPACITY: Final[int] = 350
simopt.models.amusementpark.NUM_ATTRACTIONS: Final[int] = 7
class simopt.models.amusementpark.AmusementParkConfig

Bases: pydantic.BaseModel

Configuration for the Amusement Park model.

park_capacity: 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)]
number_attractions: Annotated[int, Field(default=NUM_ATTRACTIONS, description='The number of attractions in the park.', ge=0, json_schema_extra={'isDatafarmable': False})]
time_open: Annotated[float, Field(default=480.0, description='The number of minutes per day the park is open.', ge=0)]
erlang_shape: Annotated[list[int], Field(default_factory=lambda: [2] * NUM_ATTRACTIONS, description='The shape parameter of the Erlang distribution for each attraction duration.')]
erlang_scale: Annotated[list[float], Field(default_factory=lambda: [1 / 9] * NUM_ATTRACTIONS, description='The rate parameter of the Erlang distribution for each attraction duration.')]
queue_capacities: 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.')]
depart_probabilities: 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.')]
arrival_gammas: 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')]
transition_probabilities: 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.')]
class simopt.models.amusementpark.AmusementParkMinDepartConfig

Bases: 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.

initial_solution: Annotated[tuple[int, Ellipsis], Field(default_factory=lambda: (PARK_CAPACITY - NUM_ATTRACTIONS + 1, ) + (1, ) * (NUM_ATTRACTIONS - 1), description='Initial solution from which solvers start.')]
budget: Annotated[int, Field(default=100, description='Max # of replications for a solver to take.', gt=0, json_schema_extra={'isDatafarmable': False})]
class simopt.models.amusementpark.AmusementPark(fixed_factors: dict | None = None)

Bases: 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.

class_name_abbr: ClassVar[str] = 'AMUSEMENTPARK'

Short name of the model class.

class_name: ClassVar[str] = 'Amusement Park'

Long name of the model class.

config_class: ClassVar[type[pydantic.BaseModel]]

Configuration class for the model.

n_rngs: ClassVar[int] = 3

Number of RNGs used to run a simulation replication.

n_responses: ClassVar[int] = 4

Number of responses (performance measures).

arrival_model
attraction_model
destination_model
service_models = []
before_replicate(rng_list: list[mrg32k3a.mrg32k3a.MRG32k3a]) None

Prepare the model just before generating a replication.

Parameters:

rng_list (list[MRG32k3a]) – RNGs used to drive the simulation.

Raises:

NotImplementedError – If the subclass does not implement this hook.

replicate() tuple[dict[str, float | list[float]], dict]

Simulate a single replication using current model factors.

Parameters:

rng_list (list[MRG32k3a]) – Random number generators used during the simulation.

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.

Return type:

tuple

class simopt.models.amusementpark.AmusementParkMinDepart(name: str = '', fixed_factors: dict | None = None, model_fixed_factors: dict | None = None)

Bases: simopt.base.Problem

Class to make amusement park simulation-optimization problems.

Initialize a problem object.

Parameters:
  • name (str) – Name of the problem.

  • fixed_factors (dict | None) – Dictionary of user-specified problem factors.

  • model_fixed_factors (dict | None) – Subset of user-specified non-decision factors passed to the model.

class_name_abbr: ClassVar[str] = 'AMUSEMENTPARK-1'

Short name of the problem class.

class_name: ClassVar[str] = 'Min Total Departed Visitors for Amusement Park'

Long name of the problem class.

config_class: ClassVar[type[pydantic.BaseModel]]

Configuration class for problem.

model_class: ClassVar[type[simopt.base.Model]]

Simulation model class for problem.

n_objectives: ClassVar[int] = 1

Number of objectives.

n_stochastic_constraints: ClassVar[int] = 0

Number of stochastic constraints.

minmax: ClassVar[tuple[int, Ellipsis]]

Indicators of maximization (+1) or minimization (-1) for each objective.

constraint_type: ClassVar[simopt.base.ConstraintType]

Description of constraints types.

variable_type: ClassVar[simopt.base.VariableType]

Description of variable types.

gradient_available: ClassVar[bool] = False

Indicates whether the solver provides direct gradient information.

optimal_value: ClassVar[float | None] = None

Optimal objective function value (if known).

optimal_solution: tuple | None = None

Optimal solution if known; defaults to None.

model_default_factors: ClassVar[dict]

Default values for overriding model-level default factors.

model_decision_factors: ClassVar[set[str]]

Set of keys for factors that are decision variables.

property dim: int

Number of decision variables.

property lower_bounds: tuple

Lower bound for each decision variable.

property upper_bounds: tuple

Upper bound for each decision variable.

vector_to_factor_dict(vector: tuple) dict[str, tuple]

Convert a vector of variables to a dictionary with factor keys.

Parameters:

vector (tuple) – A vector of values associated with decision variables.

Returns:

Dictionary with factor keys and associated values.

Return type:

dict

factor_dict_to_vector(factor_dict: dict) tuple

Convert a dictionary with factor keys to a vector of variables.

Parameters:

factor_dict (dict) – Dictionary with factor keys and associated values.

Returns:

Vector of values associated with decision variables.

Return type:

tuple

replicate(_x: tuple) simopt.base.RepResult

Replicate the problem for a given solution.

Parameters:

x (tuple) – The solution to evaluate.

check_deterministic_constraints(x: tuple) bool

Check if a solution x satisfies the problem’s deterministic constraints.

Parameters:

x (tuple) – A vector of decision variables.

Returns:

True if the solution satisfies all deterministic constraints;

False otherwise.

Return type:

bool

get_random_solution(rand_sol_rng: mrg32k3a.mrg32k3a.MRG32k3a) tuple

Generate a random solution for starting or restarting solvers.

Parameters:

rand_sol_rng (MRG32k3a) – Random number generator used to sample the solution.

Returns:

A tuple representing a randomly generated vector of decision

variables.

Return type:

tuple