User:Holp11
Contents
- 1 Simulation of Security Efficiency in a Store
- 1.1 Introduction
- 1.2 Problem Definition
- 1.3 Methodology
- 1.4 Model – Detailed Description
- 1.5 Simulation Results with Analysis
- 1.6 Conclusion
- 1.7 References
- 1.8 Downloadable Files
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.The dimensions of shelves are defined by the shelfWidth and shelfHeight sliders. The number of shelves is controlled by the shelvesRows and shelvesColumns sliders, and the spacing between shelves is determined by the minSpaceBetween slider.
- Behavior: Shelves serve as the primary targets for thieves and customers. Thieves steal from shelves, and customers stop at shelves to simulate shopping behaviour. Shelves also affect guard vision, as they block line-of-sight diagonally and straight.
- 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.
Exits are predefined during initialization and visually marked with white patches for easy identification.
- Behaviour: Once thieves finish stealing, they target the nearest exit and try to escape. Customers leave the store by targeting exits after shopping, simulating real-world behaviour.
- Visual Representation: Exits are represented by white patches in the simulation interface.
Input Parameters of the Model
- World Size: Small, medium, or large.
Small word size equals to approx 76,5 square meters. Because 4x4 patches equal to 1 square meters. Medium word size equals to approx. 117,5 square meters. Large word size equals to approx. 166,5 square meters. All these three world options were requested by Mr. Ha Son Do due to the fact that he has multiple stores.
- Number of Guards: It is adjustable, but based on the request from Mr. Ha Son Do, it can be set between 1 and 10.
In a small world, having 10 guards may result in immediate detection of thieves, effectively breaking the purpose of the simulation. .
- Number of Thieves: It is adjustable, but based on the request from Mr. Ha Son Do, it can be set between 1 and 15.
- Guard Vision Range: Based on an interview with the owner, it can be set between 5 and 20.
A problem might occur with a very high number of vision range in medium or small world, because the guards may cover almost the entire store, making the shelves totally irrelevant.
- Steal Delay: Time required for a thief to steal from a shelf. Based on an interview with the owner, it can be set between 5 and 80. Realistically speaking, very low number of Steal Delay would make guards ineffective, as thieves can steal and escape quickly.
On the other side, very high number might discourage thieves entirely, as the simulation would overly favour the guards.
- Spot While Stealing Threshold: The probability of a guard spotting a thief while the thief is actively stealing items from a shelf.
A value of 0 means a guard will never spot a thief while stealing. A value of 1 means a guard will always spot a thief while stealing. In the simulation it can be set from 0.7 to 1.0 The range for this parameter (0.7–1.0) was determined based on an interview with Mr. Ha Son Do. During the interview. He mentioned that most of the guards in the store pay attention to the people close to the shelves.
- Spot After Stealing Threshold: The probability of a guard spotting a thief after the thief has completed stealing and is moving toward the exit.
A value of 0 means a guard will never spot a thief after stealing. A value of 1 means a guard will always spot a thief after stealing. A value 0.05 would make guards almost unable to spot thieves after stealing, making the simulation too easy for thieves. The range for this parameter (0.05–0.2) was determined based on an interview with Mr. Ha Son Do. During the interview. He mentioned that most of the guards in the stores are older and tend to pay less attention while working. This behaviour was taken into account to make the simulation reflect real-world conditions.
- Leave Threshold: The probability that a thief will decide to leave the store after completing a theft.
A value of 0 means the thief will not leave voluntarily. A value of 1 means the thief will immediately attempt to leave the store after stealing. A possible problem while setting this simulation might happen here as well. Setting a value 0.2 would mean that the thieves are less likely to leave the store voluntarily after stealing. This would make the scenario very unrealistic where thieves stay in the store and are increasing the likelihood of being caught. On the other hand, a value 0.8 would mean that the thieves try to leave the store immediately after stealing. This would result in a scenario where guards have very low chance to interact with thieves and would make the guard´s presence almost ineffective. In the simulation it can be set from 0.2 to 0.8.
- Customer Spawn Threshold: The threshold controls the frequency of customer spawns in the store.
A value of 0 means no new customers will spawn during the simulation. A value of 1 means customers will spawn at every possible opportunity. A problem might happen while setting 0.9 in a small world, because it would make the store overcrowded, so the interaction between guards and thieves would be very unrealistic. On the other hand, having 0.1 may create almost an empty store. In the simulation it can be set from 0.1 to 0.9.
- Display Padding: Adjusts the amount of padding around the displayed simulation world for better visualization.
Higher values increase the space around the world, making the environment visually easier to observe. In the simulation it can be set from 2 to 8.
- Shelf Width: Determines the width of the shelves in the store.
Higher values make shelves wider, creating more obstacles. The problem might occur while setting high values of the parameter Width and Height. For example when having width 16 and height 8, it would block most of the store, making movement nearly impossible and creating unrealistic scenarios where thieves and guards struggle to navigate. In the simulation it can be set from 4 to 16.
- Shelf Height: Determines the height of the shelves in the store.
Higher values make shelves taller, blocking more visibility. In the simulation it can be set from 2 to 8.
- Min Space Between Shelves: Sets the minimum space between shelves.
Lower values place shelves closer together, making the area more crowded. Higher values create more open space, allowing easier movement. The problems might happen when setting both extremes. Because the low values for example 2–3 make the store too crowded, blocking movement. But on the other side, high values make the store too open, reducing the main challenge of obstacle. In the simulation it can be set from 2 to 10.
- Shop Delay: The threshold adjusts the delay between simulation ticks to control the speed of the simulation visually.
Very low delays might make the simulation too fast to observe meaningful interactions. But on the other hand, very high delays would make the simulation too slow, reducing user engagement. In the simulation it can be set from 5 to 30.
- Guard Speed: Describes how fast guards move across the store
A low speed can make guards ineffective in catching thieves. But on the other hand, High speed might result in guards constantly chasing thieves and reducing the challenge. In the simulation, if the speed was set more than 3, it would make the guards almost like supermen. In the simulation it can be set from 1 to 4.
- Maximum Customers: Sets the maximum number of customers allowed in the store.
Too many customers in a small world can create overcrowding and unrealistic movement. On the side, very few customers make the store feel empty and less realistic. In the simulation it can be set from 1 to 30.
- Shelves Rows:Determines the number of horizontal rows of shelves in the store.
Setting the values faces some problems as well. When setting very low number, it would reduce the number of obstacles, creating a very open store. It would make the thieves more powerful because they could move more easily between shelves On the other hand, Too many Rows would make the store overcrowded, especially in smaller world, making it difficult for all agents to move. In the simulation it can be set like this: In a Small store from 1 to 3 rows. In a Medium store from 1 to 5 rows. And in the Large store from 1 to 7 rows.
- Shelves Columns: Determines the number of vertical rows of shelves in the store.
Setting the values faces some problems as well. When setting very low number, it would reduce the number of obstacles, creating a very open store. It would make the guards more powerful due to minimal obstacles in their patrol paths. On the other hand, Too Many Rows would make the store Overcrowded, especially in smaller world, making it difficult for all agents to move. In the simulation it can be set like this: In a Small and medium store from 1 to 2 columns. And in a Large store from 1 to 3 columns.
Simulation Controls
- Setup: Initializes the simulation environment.
- Go: Starts or pauses the simulation loop.
Tracked Indicators
- Captured Thieves: Definition: The total number of thieves caught by guards during the simulation.
Displayed Value: The number is shown in the box labelled "Captured thieves". Usage: Tracks guard efficiency in stopping thefts. .
- Captured Thieves Percentage: Definition: The percentage of thieves caught out of the total number of thieves in the simulation.
Displayed Value: Shown in "Captured thieves percentage" Calculation: Captured Thieves Percentage = (Captured Thieves / Total Thieves) × 100
- Escaped Thieves: Definition: The total number of thieves who successfully left the store after stealing.
Displayed Value: Shown in the box labelled "Escaped thieves" Usage: Tracks how many thieves bypass guards and successfully exit.
- Escaped Thieves Percentage: Definition: The percentage of thieves who escaped out of the total number of thieves in the simulation.
Displayed Value: Shown in "Escaped thieves percentage" Calculation: Escaped Thieves Percentage = (Escaped Thieves / Total Thieves) × 100 .
- People in Shop (Graph): Definition: A real-time graph showing the number of thieves, customers, and guards in the shop over time.
Displayed Value:
Red Line: Number of thieves in the shop Blue Line: Number of customers in the shop Yellow Line: Number of guards in the
- Thieves : Definition: The current count of thieves present in the shop at any given time.
Displayed Value: Shown in the box labelled "Thieves"
- Customers: Definition: The current count of customers present in the shop at any given time.
Displayed Value: Shown in the box labelled "Customers"
- Guards:Definition: The total number of guards present in the shop, fixed as per the simulation parameters.
Displayed Value: Shown in the box labelled "Guards"
- Conflicts: Definition: The total number of interactions between guards and thieves (guards spotting or chasing thieves).
Displayed Value: Shown in the box labelled "Conflicts"
- 'Thieves Average Time in Shop: Definition: The average time thieves spend in the shop before being captured or escaping.
Displayed Value: Shown in "Thieves average time in shop" Calculation: Thieves Average Time = Total Time Thieves Spend in Shop / (Captured Thieves + Escaped Thieves)
- Use of Guards Percentage: Definition: Represents how effectively guards are being utilized in the simulation, likely based on the time they spend actively chasing thieves.
Displayed Value: Shown in "Use of guards percentage" Calculation: Use of Guards Percentage = (Active Guard Time (Chasing Thieves) / Total Guard Time) × 100
Simulation User Interface
The user interface provides sliders for adjusting parameters, monitors for real-time metrics, and plots to visualize dynamics over time.
- Sliders: Users can control key parameters such as the number of guards, thieves, and customers, as well as properties like vision range, guard speed, and shelf dimensions.
- Monitors: Displays real-time metrics such as the number of captured thieves, escaped thieves, and conflicts.
- Graphs: Visualizes the number of guards, thieves, and customers in the shop over time using color-coded lines (yellow for guards, red for thieves, and blue for customers).
- Colour Indicators:Guards are represented in yellow, thieves in red, customers in blue, and shelves in brown, allowing users to easily differentiate agents and obstacles
Simulation Results with Analysis
Small World, Guard Speed 2, and 2 Guards
Analysis: In the first screenshot, 2 thieves were captured (40%), while 3 thieves escaped (60%). This suggests improved guard effectiveness in the second scenario. Conflicts, representing guard-thief interactions, increased slightly from 8 in the first screenshot to 9 in the second screenshot. This indicates a marginally more active engagement between guards and thieves. Thieves spent an average of 28 ticks in the shop in the first screenshot, but this dropped to 22 ticks in the second. Guard efficiency, measured by the percentage of time guards actively engaged with thieves, was low in both cases. It increased from 1.6% in the first screenshot to 4.8% in the second. With 5 customers in the shop, the guards faced challenges in differentiating between thieves and shoppers. This complexity likely affected the guard´s overall performance, especially in the first screenshot.
3 Guards
Analysis: In Screenshot 1, the caught 60% of the thieves. However, in Screenshot 2, they only managed to capture 20%, which shows that their performance wasn’t consistent. This difference might be because of how the guards were positioned or the random movements of the thieves. The guards were clearly more active in Screenshot 1, with 26 conflicts recorded. In Screenshot 2, there were only 5 conflicts, which means the guards either didn’t spot the thieves as often or weren’t as engaged. On average, thieves spent less time in the shop in Screenshot 1 (20.2 ticks) compared to Screenshot 2 (25.6 ticks). This shows that guards in Screenshot 1 were better at interrupting the thieves’ activities and making them leave sooner. In Screenshot 1, only 2 thieves escaped (40%), while in Screenshot 2, 4 thieves escaped (80%). This suggests that the guards in Screenshot 1 were more effective at preventing thefts.
3 Guards and 10 Customers
In both screenshots, only 40% of thieves were caught, while 60% escaped. Despite having three guards, the thieves still managed to evade capture more often than not, highlighting how challenging it is to achieve full coverage of the shop. The number of conflicts (instances where guards spotted thieves) were higher in Screenshot 2 (15) compared to Screenshot 1 (11). This could be due to differences in how the guards and thieves moved or interacted. On average, thieves spent about 25-26 ticks in the shop before either being captured or escaping. This suggests that guards were relatively quick to respond but could benefit from slight improvements in speed or strategy. The guard's efficiency was low in both scenarios, with values of 5.8% and 4.2%. This indicates that while guards were active, they weren't being utilized to their full potential, possibly due to their positioning or the number of customers in the shop. The presence of up to 10 customers likely added complexity to the simulation. With more people in the shop, guards might have had a harder time distinguishing thieves from customers, leading to more escapes.
Large World
In both simulations, 60% of thieves were captured, while 40% escaped, even with six guards patrolling the shop. This shows that the guards were effective to some extent. The number of conflicts changed. In Screenshot 1, there were 19 conflicts, while Screenshot 2 had 28 conflicts. This suggests that guards were more engaged in the second simulation, but it didn’t result in a better capture rate. This could indicate inefficiencies in how guards respond after spotting thieves. Thieves spent more time in the shop in the second simulation, with an average of 33.6 ticks compared to 24.6 ticks in the first. The guard's efficiency also showed a notable difference. In Screenshot 1, efficiency was 5.9%, while in Screenshot 2, it improved to 18.3%. Having up to 20 customers in the store added complexity to the guards’ task. With so many people, guards struggled to differentiate between thieves and customers. This could explain why the escape rate remained consistent despite the increased guard activity in the second scenario.
Second Large World
In the first screenshot, 2 thieves were caught, while 4 escaped. In the second screenshot, guards performed significantly better, capturing 4 thieves with only 2 escaping. This improvement suggests better guard effectiveness, potentially due to better positioning . Conflicts more than doubled, rising from 10 in the first screenshot to 21 in the second screenshot. This indicates that guards were more actively engaging with thieves, which contributed to the higher capture rate. The average time thieves spent in the shop decreased from 44 ticks in the first screenshot to 31.33 ticks in the second screenshot. This shows that guards were quicker at detecting and responding to thieves in the second scenario. Despite the improvements, guard efficiency was very low in both screenshots—1.8% in the first screenshot and 3.8% in the second screenshot With 15 customers in the store, guards faced difficulties distinguishing between thieves and shoppers. This added complexity likely led to lower capture rates and efficiency, especially in the first screenshot.
Conclusion
This simulation revealed valuable insights into improving store security by analysing 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, in a 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. Additionally, thieves spent an average of 22 to 44 ticks in the store, depending on factors like steal delay. Shorter delays allowed thieves to escape faster, while longer ones gave guards more chances. Store layout and customer traffic were also crucial factors. 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. Similarly, high customer traffic, with spawn thresholds between 0.30 and 0.50, made it more difficult for guards to distinguish thieves from shoppers, often increasing escape rates. While the exact numbers and percentages may vary depending on specific scenarios, this simulation proved to be a useful tool for testing different security strategies. For Mr. Ha Son Do, it emphasizes the importance of placing guards strategically, optimizing store layouts, and focusing on guard training to improve theft prevention in a cost-effective and adaptable way.
References
- Bresenham's Algorithm
- Euclidean Distance
- [http://www.robotomie.cz/pocitadlo/pridej_zaznam.php?nazev=obsah/netlogo/netlogo.zip