Difference between revisions of "User:Holp11"

From Simulace.info
Jump to: navigation, search
(Thieves)
(Customers)
Line 79: Line 79:
 
==== Customers ====
 
==== Customers ====
 
* '''Properties''': Target, visited, delay.
 
* '''Properties''': Target, visited, delay.
* '''Behavior''': Customers move randomly around the store, targeting shelves to simulate shopping behavior. Customers may decide to leave the store after a random shopping duration. The decision to leave is influenced by the leaveThreshold slider, which determines the probability of a customer targeting an exit instead of another shelf.
+
* '''Behavior''': Customers move randomly around the store, targeting shelves to simulate shopping behaviour. Customers may decide to leave the store after a random shopping duration. The decision to leave is influenced by the leaveThreshold slider, which determines the probability of a customer targeting an exit instead of another shelf. When the customer is not leaving, customer dynamically select a shelf as his target and moves toward it.
 
* '''Visual Representation''': Customers are visually represented by blue-colored agents in the simulation.
 
* '''Visual Representation''': Customers are visually represented by blue-colored agents in the simulation.
 +
* '''Spawn Mechanics''': Customers are not spawn continuously. The maximum number of customers allowed in the store is determined by the maxCustomers slider.
 +
New customers spawn is based on the customerSpawnThreshold slider, which controls the probability of a new customer appearing in each tick
 +
Customers spawn from a randomly selected exit, simulating real-world entrance behaviour.
  
 
==== Shelves ====
 
==== Shelves ====

Revision as of 22:15, 10 January 2025

Simulation of Security Efficiency in a Store

Introduction

This page details the simulation project: "Simulation of Security Efficiency in a Store: Analyzing Optimal Guard Allocation Based on Obstruction and Escape Dynamics."

  • Subject: Multi-Agent Simulation
  • Author: Bc. Petr Hollan
  • Model Type: Multi-Agent
  • Modelling Tool: NetLogo

Problem Definition

This simulation analyses how the number of guards (guardsCount) and thieves (thievesCount), as well as the way shelves are arranged (shelvesRows, shelvesColumns, shelfWidth, shelfHeight, and minSpaceBetween), affect security in a store. It focuses on the interactions between guards, thieves, and customers in a realistic retail environment.

This simulation analyses how the number of guards (guardsCount) and thieves (thievesCount), as well as the way shelves are arranged (shelvesRows, shelvesColumns, shelfWidth, shelfHeight, and minSpaceBetween), affect security in a store. It focuses on the interactions between guards, thieves, and customers in a realistic retail environment. Key factors include how far guards can see (guardVisionRange), how fast they move (guardSpeed), and how likely they are to spot thieves while stealing (spotWhileStealingThreshold) or after stealing (spotAfterStealingThreshold). The simulation also considers customer behaviour, like how many are in the store (maxCustomers) and how often new customers arrive (customerSpawnThreshold), which makes the environment more dynamic and challenging. By adjusting these settings, the simulation helps to understand how to find the right balance—how many guards are needed, how shelves should be arranged, and how to prevent theft without overspending on security.


Objective

The main goal of this simulation is to figure out how many guards are needed to prevent theft as effectively as possible without overspending. It also looks at how factors like thief behaviour, how well guards can see, and how the shelves are arranged in the store impact security. This simulation is for Mr. Ha Son Do, a dedicated store owner with over 20 years of experience running shops in Praha, Prostějov, and Zábřeh na Moravě. His stores come in different sizes, each with its own challenges. Mr. Ha Son Do wants to know if hiring more guards is worth the investment or if there are smarter ways to improve security. He’s especially concerned about how effective his guards are since many of them are older and might not be as attentive as needed.

Methodology

The simulation uses the NetLogo agent-based modelling environment to study dynamic interactions between agents in a controlled retail environment. The flexibility of NetLogo allows users to adjust input parameters and observe how agent behavior and environmental settings influence results.

Simulation Algorithm

Euclidean Distance

This method calculates the direct distance between two points (x₁, y₁) and (x₂, y₂) in Cartesian coordinates using the formula:

d = √((x₂ - x₁)² + (y₂ - y₁)²)

In the simulation, Euclidean distance is used to determine whether a thief is within the vision range of a guard and to identify the nearest target, which is either a shelf or an exit for thieves and customers.

Bresenham’s Algorithm

Bresenham’s algorithm is used to check if a guard can see a thief by calculating a straight or diagonal line between them on the grid. The algorithm efficiently handles this by working with integer arithmetic, which makes it fast and suitable for simulations. It also takes shelves into account.

In reality, if a straight or diagonal line is blocked by an obstacle, the guard cannot detect the thief. This approach ensures that the simulation is realistic.

Model – Detailed Description

Model Limitations

  • All agents act simultaneously, which may oversimplify real-world situations.
  • Obstacles (shelves) and exits are fixed in predefined locations.
  • The model assumes a uniform decision-making process for thieves and guards, which may not capture individual variations.

Initialization

  • The store environment is initialized based on the selected size (small, medium, large).
  • Shelves, guards, and thieves are placed according to input parameters.
  • Metrics for tracking thefts, escapes, and guard performance are reset.
  • Customers can enter and exit the store through both entrances, simulating real-world customer behavior.
  • During initialization, all patches are checked for exits, and any patch containing an exit is visually marked with white to help identify the store's entry and exit points.

Simulation Execution

  • Guards patrol the store and reactively chase thieves when spotted.
  • Thieves target shelves, steal items, and attempt to escape through exits.
  • Customers move passively, simulating store traffic.
  • Obstacles (shelves) block visibility and movement, affecting interactions.
  • Thieves are not present in the store from the beginning. Instead, they spawn after the 100th tick to simulate a dynamic arrival process.
  • After the initial delay, thieves spawn every 20 ticks, maintaining a steady flow of new thieves entering the store.

Simulation Termination

The simulation ends when all thieves are either caught or have escaped.

Agents and Their Properties

Guards

  • Properties: Vision range, chasing status, speed, target, visited.
  • Behavior: Guards move around the store and pursue thieves when spotted. Guards are placed randomly during initialization on patches where there are no shelves or exits, ensuring they are positioned in open and accessible areas.
  • Vision: Guards’ vision works diagonally, allowing them to detect thieves across both straight and diagonal lines of sight, increasing the realism of their observation capabilities.
  • Visual Representation: Guards are visually represented in the simulation by yellow-colored agents.

Thieves

  • Properties: Target, stealing, visited, delay, readyToLeave, ticksOnEnter.
  • Behavior: Thieves dynamically select a shelf as their target when they are not being pursued by guards or in the process of leaving. When a thief reaches the target shelf, they begin the “stealing process”. This involves a delay (based on the stealDelay slider), after which they mark themselves as ready to leave. Once ready to leave, thieves target the nearest exit and attempt to escape. If a guard captures them during this process, they are removed from the simulation and the status is shown on the monitor.Thieves check if they are within the vision radius of a guard. If they are spotted, they might try to evade capture by adjusting their movements.
  • Visual Representation: Thieves are visually represented by red-coloured agents in the simulation.
  • Spawn Mechanics:Thieves do not spawn at the start of the simulation. Instead:

They begin spawning after 100 ticks. New thieves spawn every 20 ticks until the total number of thieves reaches the count set by the thievesCount slider. Thieves enter the store from a randomly selected exit.

Customers

  • Properties: Target, visited, delay.
  • Behavior: Customers move randomly around the store, targeting shelves to simulate shopping behaviour. Customers may decide to leave the store after a random shopping duration. The decision to leave is influenced by the leaveThreshold slider, which determines the probability of a customer targeting an exit instead of another shelf. When the customer is not leaving, customer dynamically select a shelf as his target and moves toward it.
  • Visual Representation: Customers are visually represented by blue-colored agents in the simulation.
  • Spawn Mechanics: Customers are not spawn continuously. The maximum number of customers allowed in the store is determined by the maxCustomers slider.

New customers spawn is based on the customerSpawnThreshold slider, which controls the probability of a new customer appearing in each tick Customers spawn from a randomly selected exit, simulating real-world entrance behaviour.

Shelves

  • Properties: Shelves act as obstacles, blocking both movement and visibility for guards, thieves, and customers.
  • Behavior: Shelves serve as the primary targets for thieves and customers. Thieves steal from shelves, and customers stop at shelves to simulate shopping behavior.
  • Visual Representation: Shelves are visually represented as brown-colored patches in the simulation interface.

Exits

  • Properties: Exits are fixed patches where thieves attempt to escape the store, and customers leave after shopping.
  • Behavior: Once thieves finish stealing, they target the nearest exit and try to escape.
  • Visual Representation: Exits are represented by white patches in the simulation interface.

Input Parameters of the Model

  • World Size: Small, medium, or large.
  • Number of Guards: Adjustable (1–10).
  • Number of Thieves: Adjustable (1–15).
  • Guard Vision Range: 5–20.
  • Steal Delay: 5–80 ticks.
  • Spot While Stealing Threshold: 0.7–1.0.
  • Spot After Stealing Threshold: 0.05–0.2.
  • Leave Threshold: 0.2–0.8.
  • Customer Spawn Threshold: 0.1–0.9.
  • Display Padding: 2–8.
  • Shelf Dimensions: Width (4–16) and Height (2–8).
  • Min Space Between Shelves: 2–10.
  • Shop Delay: 5–30 ticks.
  • Guard Speed: 1–4.
  • Maximum Customers: 1–30.

Simulation Controls

  • Setup: Initializes the simulation environment.
  • Go: Starts or pauses the simulation loop.

Tracked Indicators

  • Captured Thieves: Total number of thieves caught by guards.
  • Captured Thieves Percentage: Percentage of thieves caught.
  • Escaped Thieves: Total number of thieves who successfully left the store after stealing.
  • Escaped Thieves Percentage: Percentage of thieves who escaped.
  • People in Shop (Graph): Real-time graph showing the number of thieves, customers, and guards in the shop over time.
  • Thieves Average Time in Shop: Average time thieves spend in the shop before being captured or escaping.
  • Use of Guards Percentage: Represents how effectively guards are being utilized.

Simulation User Interface

  • Sliders: Control parameters such as the number of guards, thieves, and customers, as well as properties like vision range, guard speed, and shelf dimensions.
  • Monitors: Display real-time metrics such as the number of captured thieves, escaped thieves, and conflicts.
  • Graphs: Visualize the number of guards, thieves, and customers in the shop over time using color-coded lines.

Simulation Results with Analysis

Small World, Guard Speed 2, and 2 Guards

  • Captured Thieves: 40%
  • Escaped Thieves: 60%
  • Conflicts: 9 interactions
  • Average Time in Shop: 22 ticks

3 Guards

  • Captured Thieves: 60%
  • Escaped Thieves: 40%
  • Conflicts: 26 interactions
  • Average Time in Shop: 20.2 ticks

3 Guards and 10 Customers

  • Captured Thieves: 40%
  • Escaped Thieves: 60%
  • Conflicts: 15 interactions
  • Average Time in Shop: 25–26 ticks

Large World

  • Captured Thieves: 60%
  • Escaped Thieves: 40%
  • Conflicts: 19–28 interactions
  • Average Time in Shop: 24.6–33.6 ticks

Second Large World

  • Captured Thieves: 2–4
  • Escaped Thieves: 2–4
  • Conflicts: 10–21 interactions
  • Average Time in Shop: 31.33–44 ticks

Conclusion

This simulation revealed valuable insights into improving store security by analyzing how guards, thieves, customers, and store layouts interact. Preventing theft isn’t just about hiring more guards—it’s about making smarter, targeted changes to store operations. For example:

  • Small Store: With two guards, only 40% of thieves were caught while 60% escaped, leading to a guard efficiency of just 1.8%. Increasing the guard count to three improved capture rates to 60% and raised efficiency to 3.8%, but escapes still occurred.
  • Store Layout: Narrow shelves with minimal spacing made it harder for guards to see, while wider shelves created blind spots thieves could exploit. Balancing shelf spacing is key to ensuring guards can patrol effectively without disrupting the shopping experience.
  • Customer Traffic: High customer traffic made it more difficult for guards to distinguish thieves from shoppers, often increasing escape rates.

Possible Model Extensions

  • Adding more realistic guard and thief behaviors.
  • Introducing dynamic shelf arrangements.
  • Simulating multiple store scenarios simultaneously.

References

Downloadable Files