{"id":16082074,"url":"https://github.com/floressek/concurrentlab_algorythms","last_synced_at":"2025-04-05T11:43:59.277Z","repository":{"id":229525007,"uuid":"776957325","full_name":"Floressek/concurrentLab_algorythms","owner":"Floressek","description":"Codes from Concurrency Labs and a project that simulates a tourist attraction in a salt mine, implementing concurrent programming principles to manage visitor movement and resource allocation.","archived":false,"fork":false,"pushed_at":"2024-11-13T22:08:53.000Z","size":181,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T22:48:03.660Z","etag":null,"topics":["algorithms","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Floressek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-24T22:30:02.000Z","updated_at":"2024-11-13T22:08:57.000Z","dependencies_parsed_at":"2024-05-08T19:43:17.786Z","dependency_job_id":"2977f952-7793-4d32-b2aa-3960ff2b7323","html_url":"https://github.com/Floressek/concurrentLab_algorythms","commit_stats":null,"previous_names":["floressek/concurrentlab_algorythms"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floressek%2FconcurrentLab_algorythms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floressek%2FconcurrentLab_algorythms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floressek%2FconcurrentLab_algorythms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Floressek%2FconcurrentLab_algorythms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Floressek","download_url":"https://codeload.github.com/Floressek/concurrentLab_algorythms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332525,"owners_count":20921852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","java"],"created_at":"2024-10-09T11:25:18.567Z","updated_at":"2025-04-05T11:43:59.252Z","avatar_url":"https://github.com/Floressek.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mine Simulation Project (Concurrent Programming)\n\n## Overview 🎯\nThis project simulates a tourist attraction in a salt mine, implementing concurrent programming principles to manage visitor movement and resource allocation. The simulation recreates a real-world scenario where multiple tourists navigate through a complex mine structure with specific constraints and rules.\n\n## Project Structure 🗂️\nThe project is part of a larger repository containing different laboratory works. The main simulation project is located in the `simulation` folder, while other directories contain labs from different classes.\n\n```\n.\n├── .idea\n├── demo\n├── lab_src\n│   ├── .idea\n│   └── src\n│       ├── lab3_4\n│       ├── lab5_6\n│       ├── lab7_8\n│       ├── lab9_10\n│       └── simulation\n│           ├── Connector.java\n│           ├── Controllable.java\n│           ├── Elevator.java\n│           ├── Paintable.java\n│           ├── Plan.java\n│           ├── Room.java\n│           ├── Simulation.java\n│           ├── Visitable.java\n│           ├── Visitor.java\n│           ├── config.properties\n│           ├── .gitignore\n│           └── lab3_4.iml\n├── .gitignore\n├── LICENSE.md\n├── README.md\n└── lab3_4.iml\n```\n\n## Detailed Project Description 📋\n\n### Mine Structure\nThe mine consists of four main chambers interconnected by passages:\n- 3 standard rooms (R1, R3, R4) with capacity X visitors\n- 1 larger room (R2) with capacity 2X visitors\n- 2 elevators (E1, E2) for vertical transportation\n- Single-person bidirectional passages connecting the rooms\n\n## Movement Rules 📋\n\n1. Visitors cannot stop in passages between rooms\n2. Passages are bidirectional\n3. Passages allow only one person at a time\n4. Visitors can pass through rooms without visiting them\n5. Rooms cannot be divided into restricted access zones\n\n## Notes 📌\n\n- Each room displays a counter showing the current number of visitors\n- Green paths indicate visitor routes\n- Visitors can move either randomly (when visiting) or directly (when passing through)\n- The Pause button changes to Resume when simulation is paused\n- Multiple rapid clicks on the Restart button should be avoided to prevent unstable behavior\n\n### Visiting Plans\nThe simulation supports two distinct visiting routes:\n- **Plan A**: E1 → R1 → R2 → R3 → R4 → E2\n- **Plan B**: E2 → R4 → R3 → R2 → R1 → E1\n\n### Technical Implementation\nThe project utilizes modern Java concurrency features:\n- Virtual threads for efficient visitor simulation\n- Semaphores for room capacity management\n- Synchronized blocks for critical sections\n- Blocking queues for elevator management\n- Event-driven GUI updates\n\n## Architecture Diagrams 📊\n\n### Class Diagram\n\n\n```mermaid\nclassDiagram\n    class Paintable {\n        \u003c\u003cabstract\u003e\u003e\n        #Color color\n        +paint(Graphics g)*\n    }\n    \n    class Visitable {\n        \u003c\u003cabstract\u003e\u003e\n        #String name\n        #Rectangle area\n        #int capacity\n        #int visitorCount\n        +onEntry(Visitor v)\n        +onExit(Visitor v)\n    }\n    \n    class Room {\n        +Room(name, area, capacity)\n    }\n    \n    class Elevator {\n        -Queue upQueue\n        -Queue downQueue\n        -Queue insideQueue\n        -Direction direction\n        +move()\n        +notifyUp()\n        +notifyDown()\n    }\n    \n    class Visitor {\n        -String name\n        -Plan plan\n        -boolean visiting\n        +move()\n        +moveRandom()\n        +detectGoal()\n    }\n    \n    class Plan {\n        -List~Visitable~ visitables\n        -Point startPosition\n        -Point endPosition\n        +addVisitable()\n        +resolveNextVisitable()\n    }\n    \n    class Simulation {\n        -List~Plan~ plans\n        -List~Visitor~ visitors\n        +startSimulation()\n        +pauseSimulation()\n        +resumeSimulation()\n    }\n    \n    Paintable \u003c|-- Visitable\n    Visitable \u003c|-- Room\n    Visitable \u003c|-- Elevator\n    Paintable \u003c|-- Visitor\n    Simulation --\u003e Plan\n    Plan --\u003e Visitable\n    Visitor --\u003e Plan\n```\n\n### Sequence Diagram\n    \n```mermaid\nsequenceDiagram\n    participant V as Visitor\n    participant R as Room\n    participant E as Elevator\n    participant P as Plan\n    \n    V-\u003e\u003eP: resolveNextVisitable()\n    P--\u003e\u003eV: nextLocation\n    V-\u003e\u003eV: detectGoal()\n    V-\u003e\u003eR: onEntry()\n    R--\u003e\u003eV: acquire semaphore\n    V-\u003e\u003eV: moveRandom()/moveStraight()\n    V-\u003e\u003eR: onExit()\n    R--\u003e\u003eV: release semaphore\n    V-\u003e\u003eE: onEntry()\n    E--\u003e\u003eV: add to queue\n    E-\u003e\u003eE: move()\n    E-\u003e\u003eV: notify movement complete\n    V-\u003e\u003eE: onExit()\n```\n\n### Flowchart\n\n```mermaid\nflowchart TD\n    A[Start Simulation] --\u003e B{Create Plans}\n    B --\u003e C[Plan A]\n    B --\u003e D[Plan B]\n    C --\u003e E[Initialize Visitors]\n    D --\u003e E\n    E --\u003e F[Start Threads]\n    F --\u003e G{Movement Loop}\n    G --\u003e H[Check Goal]\n    H --\u003e I[Move Visitor]\n    I --\u003e J{Room Available?}\n    J --\u003e|Yes| K[Enter Room]\n    J --\u003e|No| L[Wait]\n    K --\u003e M[Process Visit]\n    M --\u003e N[Exit Room]\n    N --\u003e G\n    L --\u003e G\n```\n\n## Key Features 🔑\n\n### Advanced Movement System\n- **Intelligent Pathfinding**: Visitors can navigate between rooms using the shortest available path\n- **Dynamic Speed Adjustment**: Movement speed adapts based on congestion and room availability\n- **Random/Direct Movement**: Visitors can either explore rooms randomly or move directly to exits\n\n### Resource Management\n- **Thread-Safe Room Access**: Synchronized access to prevent overcrowding\n- **Smart Elevator Scheduling**: Efficient elevator algorithms to minimize wait times\n- **Queue Management**: Fair queuing system for rooms and elevators\n\n### Monitoring and Control\n- **Real-time Statistics**: Displays current visitor count and room occupancy\n- **Visual Feedback**: Color-coded paths and visitor states\n- **Interactive Controls**: Dynamic adjustment of simulation parameters\n\n## System Requirements 💻\n\n### Minimum Requirements\n- Java 21 or higher (for virtual threads support)\n- 4GB RAM\n- 1920x1080 display resolution (recommended)\n\n### Development Environment\n- IDE: IntelliJ IDEA, Eclipse, or NetBeans\n- Build System: Java Build Path\n- Required Libraries: Java Swing (included in JDK)\n\n## Performance Considerations ⚡\n\n### Optimization Techniques\n1. **Thread Pool Management**\n   - Uses virtual threads for efficient concurrency\n   - Automatic thread lifecycle management\n\n2. **Resource Utilization**\n   - Minimized synchronization overhead\n   - Efficient memory usage through object pooling\n\n3. **GUI Performance**\n   - Optimized rendering pipeline\n   - Double buffering for smooth animations\n   \n## Project Status ⌛\nThis project was completed on 06/10/2024 as part of the Concurrent Programming course (PW-12/2024) under the supervision of dr inż. Jarosław Rulka.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloressek%2Fconcurrentlab_algorythms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloressek%2Fconcurrentlab_algorythms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloressek%2Fconcurrentlab_algorythms/lists"}