FactoryMind is a factory scheduling simulator and decision-support dashboard. It allows operators to step through complex scheduling environments, compare the decisions made by different scheduling strategies, and manually intervene when necessary.
The core of FactoryMind is a custom Gymnasium-based simulator representing a factory floor. The environment tracks multiple workers and tasks over a set timeframe, simulating constraints like worker health, fatigue, resting times, and task progress.
Key capabilities:
- State Management: Tracks the exact status of up to 10 workers (Available, Working, Resting, Fatigued) and 20 tasks (Available, InProgress, Paused, Completed).
- Manual Stepping: Unlike typical auto-advancing simulations, FactoryMind is built for analysis. The user manually triggers the next step, allowing for deep inspection of the current state and proposed actions.
- Strategy Benchmarking: At any given step, the simulator evaluates what three different strategies would do:
- A trained Reinforcement Learning (RL) model
- A Greedy algorithm (optimizing for immediate reward)
- A rule-based Heuristic algorithm
- Human-in-the-Loop (HITL): Operators are not forced to follow the AI. They can select any of the algorithmic recommendations or define a custom action (assigning a specific worker to a specific task) to override the system.
The primary intelligence behind FactoryMind is the "eScheduler" model, a Reinforcement Learning agent trained using Maskable Proximal Policy Optimization (MaskablePPO).
Neural Network Design The model utilizes a custom Multi-Layer Perceptron (MLP) architecture configured for deep feature extraction:
- Input Layer: A flattened 1D array of 171 features representing the raw state vector (worker statuses, task statuses, health bars, timers).
- Hidden Layers: A dense [512, 512, 512] network structure. This depth and width allow the model to learn complex, non-linear relationships between worker fatigue levels and task completion requirements over long time horizons.
- Output Layer: A discrete action space of 220 possible choices (representing which worker is assigned to which task, plus rest options).
Action Masking Since not all actions are valid in every state (e.g., assigning a fatigued worker to a new task), the environment provides action masks. The MaskablePPO algorithm uses these masks to zero-out the probability of selecting invalid actions during both training and inference.
FactoryMind integrates local Large Language Models to provide plain-English explanations of the algorithmic decisions.
By running ollama locally (using the lightweight llama3.2:1b model), the dashboard can analyze the current environment state, compare the RL model's choice against the greedy and heuristic baselines, and generate a concise explanation of why the RL model made its specific choice. This ensures the reasoning is transparent and actionable for non-technical managers.
- Python 3.10+
- Ollama (for local LLM explanations)
-
Install dependencies:
pip install fastapi uvicorn stable-baselines3 sb3-contrib numpy gymnasium torch
-
Start the local LLM (Optional, for explanations):
# In a separate terminal ollama serve ollama pull llama3.2:1b -
Run the backend server:
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
-
Access the dashboard: Open a web browser and navigate to
http://localhost:8000.
The current iteration of FactoryMind demonstrates effective single-agent scheduling with human oversight. Future development will focus on expanding the complexity and autonomy of the system:
- Multi-Agent Systems: Transitioning from a single centralized eScheduler to a multi-agent reinforcement learning (MARL) setup, where distinct agents manage specific sectors or groups of workers, negotiating tasks collaboratively.
- Dynamic Environment Variables: Introducing unpredictable elements like machine breakdowns, supply chain delays, or dynamic priority shifts during a simulation episode.
- Continuous Online Learning: Allowing the RL model to slowly update its policy based on the manual Human-in-the-Loop interventions made by expert operators, learning from human intuition over time.