์ด ํ๋ก์ ํธ๋ ์ธ๊ณต์ง๋ฅ(AI)์ ํ์ฉํ ์ต์ ํ ๊ธฐ๋ฒ์ ์์ฐ๋ผ์ธ ์๋ฎฌ๋ ์ด์ ์ ์ ์ฉํ์ฌ, ๊ธฐ์กด์ ๊ฒฝํ์ ๋๋ ๋ฌด์์์ ์์ฌ๊ฒฐ์ ๋ฐฉ์ ๋๋น AI์ ํจ๊ณผ๋ฅผ ์ ์ฆํ๋ ๊ฒ์ด ๋ชฉํ์ ๋๋ค.
- ๋ฌธ์ : ์์ฐ๋ผ์ธ์์ ๊ฐ ๊ณต์ (๊ฐ๊ณตโ์กฐ๋ฆฝโ๊ฒ์ฌ)์ ๋ช ๋์ ๊ธฐ๊ณ๋ฅผ ๋ฐฐ์นํด์ผ ์ต์ ์ ์ฑ๊ณผ๋ฅผ ๋ผ ์ ์์๊น?
- AI์ ์ญํ : ์ค์๊ฐ์ผ๋ก ์์ฐ ์ํฉ์ ๋ถ์ํ๊ณ , ์ฒ๋ฆฌ๋์ ์ต๋ํํ๋ฉด์ ๋น์ฉ๊ณผ ๋๊ธฐ์๊ฐ์ ์ต์ํํ๋ ์ต์ ์ ๊ธฐ๊ณ ๋ฐฐ์น ์ ๋ต์ ํ์ต
- ๊ฒ์ฆ ๋ฐฉ๋ฒ: AI ๋ฐฉ์ vs ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ ์ฑ๋ฅ์ ์์น์ ์ผ๋ก ๋น๊ต
- ์ฒ๋ฆฌ๋: AI๊ฐ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ๋๋น 13.0% ํฅ์ (์๊ฐ๋น ์์ฐ๋: AI 100.9๊ฐ vs ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ 89.3๊ฐ)
- ์ด์๋น์ฉ: AI๊ฐ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ๋๋น 52.0% ์ ๊ฐ (AI $3,760 vs ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ $7,828)
- ๋๊ธฐ์๊ฐ: AI๊ฐ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ๋๋น 92.3% ๋จ์ถ (AI 0.16๋ถ vs ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ 2.09๋ถ)
- ์ ์ฒด ๋ณด์: AI๊ฐ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ๋๋น 101.8% ํฅ์ (AI 123.7 vs ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ 61.3)
- ๊ฐํํ์ต: PPO (Proximal Policy Optimization) ์๊ณ ๋ฆฌ์ฆ
- ์๋ฎฌ๋ ์ด์ : SimPy (์ด์ฐ์ฌ๊ฑด ์๋ฎฌ๋ ์ด์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ)
- AI ํ๋ ์์ํฌ: Stable-Baselines3
- ๋ฐ์ดํฐ ๋ถ์: Pandas, NumPy, Matplotlib, Seaborn
- ์ธ์ด: Python 3.8+
- ์ฃผ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ:
gymnasium
,stable-baselines3
,simpy
,matplotlib
,seaborn
# ์ฃผ์ ์ค์ ๊ฐ ์์
MAX_MACHINES_PER_STATION = 50 # ๊ฐ ์คํ
์ด์
๋ณ ์ต๋ ๊ธฐ๊ณ ์
SIMULATION_TIME = 60 # ์๋ฎฌ๋ ์ด์
์๊ฐ (๋ถ)
STATION_CONFIG = {
'machining': {'capacity': 1, 'name': '๊ฐ๊ณต ์คํ
์ด์
'},
'assembly': {'capacity': 1, 'name': '์กฐ๋ฆฝ ์คํ
์ด์
'},
'inspection': {'capacity': 1, 'name': '๊ฒ์ฌ ์คํ
์ด์
'}
}
์ญํ :
- ์ ์ฒด ์์คํ ์ ์ค์ ๊ฐ์ ์ค์์ง์ค์์ผ๋ก ๊ด๋ฆฌ
- ์คํ ์ด์ ๋ณ ๊ธฐ๊ณ ์, ์์ ์๊ฐ, ๋ถํ ํฌ์ ๊ฐ๊ฒฉ ๋ฑ์ ์ค์
- ๋ค์ํ ์๋๋ฆฌ์ค(๋ณ๋ชฉ ๋ฐ์, ๊ณ ์์ ๋ฑ) ํ๋ฆฌ์ ์ ๊ณต
- ์คํ ์กฐ๊ฑด ๋ณ๊ฒฝ ์ ์ด ํ์ผ๋ง ์์ ํ๋ฉด ์ ์ฒด ์์คํ ์ ์๋ ๋ฐ์
class ProductionLineEnv(gym.Env):
def __init__(self):
# ํ๋๊ณต๊ฐ: ๊ฐ ์คํ
์ด์
์ ๋ฐฐ์นํ ๊ธฐ๊ณ ์ (1~50๋)
self.action_space = spaces.MultiDiscrete([MAX_MACHINES_PER_STATION] * 3)
# ์ํ๊ณต๊ฐ: [์ฒ๋ฆฌ๋, ํ๊ท ๋๊ธฐ์๊ฐ, ๊ฐ ์คํ
์ด์
๊ฐ๋๋ฅ ]
self.observation_space = spaces.Box(low=np.array([0, 0, 0, 0, 0]),
high=np.array([np.inf, np.inf, 100, 100, 100]))
ํต์ฌ ๋์ ๋ก์ง:
- ์ด๊ธฐํ: ์์ฐ๋ผ์ธ ํ๊ฒฝ์ ์ค์ ํ๊ณ ์ํ๊ณต๊ฐ/ํ๋๊ณต๊ฐ ์ ์
- step() ํจ์: AI๊ฐ ์ ํํ ๊ธฐ๊ณ ๋ฐฐ์น๋ฅผ ๋ฐ์ ์๋ฎฌ๋ ์ด์ ์คํ
- ์๋ฎฌ๋ ์ด์ ์คํ: SimPy๋ฅผ ์ฌ์ฉํด ์ค์ ์์ฐ ๊ณผ์ ์ ๋ชจ๋ธ๋ง
- ๋ณด์ ๊ณ์ฐ: ์ฒ๋ฆฌ๋โ, ๋น์ฉโ, ๋๊ธฐ์๊ฐโ๋ฅผ ์ข ํฉํ ์ ์ ์ฐ์ถ
- ์ํ ๋ฐํ: ๋ค์ ์์ฌ๊ฒฐ์ ์ ์ํ ํ์ฌ ์์ฐ๋ผ์ธ ์ํ ์ ๊ณต
class SimpleProductionAgent:
def train(self, total_timesteps):
self.model = PPO("MlpPolicy", self.env,
learning_rate=0.0003,
n_steps=1024,
batch_size=64)
self.model.learn(total_timesteps=total_timesteps)
ํต์ฌ ๋์ ๋ก์ง:
- ๋ชจ๋ธ ์ด๊ธฐํ: PPO ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ์ ์ฑ ๋คํธ์ํฌ ์์ฑ
- ๊ฒฝํ ์์ง: ํ๊ฒฝ๊ณผ ์ํธ์์ฉํ๋ฉฐ (์ํ, ํ๋, ๋ณด์) ๋ฐ์ดํฐ ์ถ์
- ์ ์ฑ ์ ๋ฐ์ดํธ: ์์ง๋ ๊ฒฝํ์ ๋ฐํ์ผ๋ก ์ ๊ฒฝ๋ง ๊ฐ์ค์น ์ต์ ํ
- ์ฑ๋ฅ ํ๊ฐ: ํ์ต๋ ๋ชจ๋ธ๊ณผ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ์ ํ ๋ฐฉ์์ ์ฑ๋ฅ ๋น๊ต
- ๋ชจ๋ธ ์ ์ฅ: ํ์ต ์๋ฃ๋ AI ๋ชจ๋ธ์ ํ์ผ๋ก ์ ์ฅ
PPO ์๊ณ ๋ฆฌ์ฆ ์ ํ ์ด์ :
- ์์ ์ ์ธ ํ์ต ์ฑ๋ฅ
- ์ฐ์์ /์ด์ฐ์ ํ๋๊ณต๊ฐ ๋ชจ๋ ์ง์
- ์ฐ์ ํ์ฅ์์ ๊ฒ์ฆ๋ ์ ๋ขฐ์ฑ
def run_performance_analysis(self, num_episodes=100):
# AI vs Monte Carlo method ์์ด์ ํธ ์ฑ๋ฅ ๋ฐ์ดํฐ ์์ง
for agent_type in ['AI', 'Monte Carlo method']:
for i in range(num_episodes):
# ๊ฐ ์ํผ์๋๋ณ ์ฑ๋ฅ ์งํ ๊ธฐ๋ก
agent_data.append({
'Agent': agent_type,
'Reward': reward,
'Throughput': info['throughput'],
'Cost': info['total_cost'],
'WaitTime': avg_wait_time
})
ํต์ฌ ๋์ ๋ก์ง:
- ๋ฐ์ดํฐ ์์ง: AI์ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ ๊ฐ๊ฐ 100ํ์ฉ ์คํํ์ฌ ์ฑ๋ฅ ๋ฐ์ดํฐ ์ถ์
- ํต๊ณ ๋ถ์: ํ๊ท , ์ค๊ฐ๊ฐ, ํ์คํธ์ฐจ ๋ฑ ๊ธฐ์ ํต๊ณ๋ ๊ณ์ฐ
- ๋น๊ต ๋ถ์: AI ๋๋น ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ ์ฑ๋ฅ ๊ฐ์ ๋ฅ ์ ๋ฐฑ๋ถ์จ๋ก ์ฐ์ถ
- ์๊ฐํ: 4๊ฐ ์ฐจํธ(์ฒ๋ฆฌ๋, ๋น์ฉ, ๋๊ธฐ์๊ฐ, ์ ๋ต๋ถํฌ)๋ก ๊ฒฐ๊ณผ ํ์
- ๋ณด๊ณ ์ ์์ฑ: ํฐ๋ฏธ๋๊ณผ ๊ทธ๋ํ๋ฅผ ํตํ ์ข ํฉ ์ฑ๊ณผ ๋ฆฌํฌํธ ์ ๊ณต
config.py โ ์๋ฎฌ๋ ์ด์
ํ๋ผ๋ฏธํฐ ์ค์
rl_environment.py โ ๊ฐํํ์ต ํ๊ฒฝ ๊ตฌ์ฑ
1. ๋๋ค ๊ธฐ๊ณ ๋ฐฐ์น๋ก ์์
2. ์๋ฎฌ๋ ์ด์
์คํ โ ๊ฒฐ๊ณผ ๊ด์ฐฐ
3. ๋ณด์์ ๋ฐํ์ผ๋ก ์ ์ฑ
๊ฐ์
4. 500,000ํ ๋ฐ๋ณต ํ์ต
ํ์ต๋ AI vs ๋ชฌํ
์นด๋ฅผ๋ก ๋ฐฉ๋ฒ ์ ํ ๋ฐฉ์
โ 200ํ ํ
์คํธ ์คํ
โ ํต๊ณ์ ์ ์์ฑ ๊ฒ์ฆ
โ ๊ฒฐ๊ณผ ์๊ฐํ
pip install gymnasium stable-baselines3 simpy matplotlib seaborn pandas numpy
python simple_agent_v1.py
- ํ์ต ์๊ฐ: ์ฝ 30-120๋ถ (์ปดํจํฐ ์ฑ๋ฅ์ ๋ฐ๋ผ)
- ๊ฒฐ๊ณผ:
my_production_ai.zip
๋ชจ๋ธ ํ์ผ ์์ฑ
python training_analysis_v1.py
# config.py์์ ๋ค์ํ ์คํ ์กฐ๊ฑด ์ค์ ๊ฐ๋ฅ
MAX_MACHINES_PER_STATION = 30 # ๊ธฐ๊ณ ์ ์ ํ ๋ณ๊ฒฝ
apply_scenario('bottleneck_assembly') # ๋ณ๋ชฉ ์๋๋ฆฌ์ค ์ ์ฉ
- ์๋ฏธ: ์๊ฐ๋น ์์ฑํ ์์ฐ ๊ฐ์
- AI ์ฑ๊ณผ: ์๊ฐ๋น ์์ฐ๋ 100.9๊ฐ (๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ: 89.3๊ฐ/์๊ฐ)
- ๋น์ฆ๋์ค ์ํฉํธ: 13.0% ์์ฐ์ฑ ํฅ์ โ ๋งค์ถ ์ง๊ฒฐ
- ์๋ฏธ: ๊ธฐ๊ณ ์ด์์ ํ์ํ ์ด ๋น์ฉ
- AI ์ฑ๊ณผ: AI์ ํ๊ท ์ด์ ๋น์ฉ์ $3,760์ผ๋ก, ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ ํ๊ท ๋น์ฉ($7,828) ๋๋น 52.0% ๋ฎ์์ต๋๋ค. ํนํ AI๋ ๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ์ด ์ต๋ ์์ฐ๋์ ๊ธฐ๋กํ์ ๋์ ์ต์ ๋น์ฉ๋ณด๋ค๋ 25.1% ๋ ๋ฎ์ ๋น์ฉ ํจ์จ์ฑ์ ๋ณด์์ต๋๋ค.
- ๋น์ฆ๋์ค ์ํฉํธ: 52.0% ๋น์ฉ ์ ๊ฐ โ ์์ต์ฑ ๊ฐ์
- ์๋ฏธ: ๋ถํ์ด ๊ฐ ๊ณต์ ์์ ๋๊ธฐํ๋ ํ๊ท ์๊ฐ
- AI ์ฑ๊ณผ: ํ๊ท 0.16๋ถ (๋ชฌํ ์นด๋ฅผ๋ก ๋ฐฉ๋ฒ: 2.09๋ถ)
- ๋น์ฆ๋์ค ์ํฉํธ: 92.3% ๋๊ธฐ์๊ฐ ๋จ์ถ โ ๊ณ ๊ฐ ๋ง์กฑ๋ ํฅ์
- ๊ฐํํ์ต ์ค์ ์ ์ฉ: ์ด๋ก ์ ์ค์ ๋ฌธ์ ์ ์ ์ฉํ๋ ๊ฒฝํ
- ์๋ฎฌ๋ ์ด์ ๋ชจ๋ธ๋ง: ๋ณต์กํ ์์คํ ์ ์ํ์ ์ผ๋ก ๋ชจ๋ธ๋งํ๋ ๋ฅ๋ ฅ
- ์ฑ๋ฅ ์ต์ ํ: ๋ค๋ชฉ์ ์ต์ ํ ๋ฌธ์ ํด๊ฒฐ ๊ฒฝํ
- ๋ฐ์ดํฐ ๋ถ์: ์คํ ๊ฒฐ๊ณผ๋ฅผ ๊ณผํ์ ์ผ๋ก ๋ถ์ํ๋ ๋ฐฉ๋ฒ๋ก
- ๋ ๋ณต์กํ ์์ฐ๋ผ์ธ (4๊ฐ ์ด์ ์คํ ์ด์ ) ์ง์
- ์ค์๊ฐ ์์ ๋ณ๋ ๋ฐ์
- ๊ธฐ๊ณ ๊ณ ์ฅ/์ ์ง๋ณด์ ์ํฉ ๋ชจ๋ธ๋ง
- ๋ค์ํ ์ ํ ํ์ ๋์ ์์ฐ
์ด ํ๋ก์ ํธ์ ๋ํ ์ถ๊ฐ ๋ฌธ์๋ ์ธ์ ๋ ํ์ํฉ๋๋ค!
์ด ํ๋ก์ ํธ๋ AI ๊ธฐ์ ์ ์ค์ฉ์ ๊ฐ์น๋ฅผ ์ ์ฆํ๊ณ , ์ ์กฐ์ ํ์ ์ ๊ธฐ์ฌํ๊ณ ์ ํ๋ ๋ชฉ์ ์ผ๋ก ๊ฐ๋ฐ๋์์ต๋๋ค.
This project aims to apply AI-powered optimization techniques to production line simulation and demonstrate the effectiveness of AI compared to traditional empirical or Monte Carlo method decision-making approaches.
- Problem: How many machines should be deployed at each production stage (MachiningโAssemblyโInspection) to achieve optimal performance?
- AI's Role: Analyze production situations in real-time and learn optimal machine allocation strategies that maximize throughput while minimizing costs and wait times
- Validation Method: Quantitative performance comparison between AI approach vs. Monte Carlo method
- Throughput: AI achieved 13.0% improvement over Monte Carlo method (AI 100.9 units/hour vs Monte Carlo method 89.3 units/hour)
- Operating Cost: AI achieved 52.0% cost reduction compared to Monte Carlo method (AI $3,760 vs Monte Carlo method $7,828)
- Wait Time: AI achieved 92.3% wait time reduction compared to Monte Carlo method (AI 0.16 min vs Monte Carlo method 2.09 min)
- Overall Reward: AI achieved 101.8% improvement over Monte Carlo method (AI 123.7 vs Monte Carlo method 61.3)
- Reinforcement Learning: PPO (Proximal Policy Optimization) Algorithm
- Simulation: SimPy (Discrete Event Simulation Library)
- AI Framework: Stable-Baselines3
- Data Analysis: Pandas, NumPy, Matplotlib, Seaborn
- Language: Python 3.8+
- Key Libraries:
gymnasium
,stable-baselines3
,simpy
,matplotlib
,seaborn
# Key configuration examples
MAX_MACHINES_PER_STATION = 50 # Maximum machines per station
SIMULATION_TIME = 60 # Simulation time (minutes)
STATION_CONFIG = {
'machining': {'capacity': 1, 'name': 'Machining Station'},
'assembly': {'capacity': 1, 'name': 'Assembly Station'},
'inspection': {'capacity': 1, 'name': 'Inspection Station'}
}
Role:
- Centralized management of system-wide configuration values
- Configuration of machine counts per station, work times, part arrival intervals, etc.
- Provides various scenario presets (bottlenecks, high demand, etc.)
- Changes to this file automatically reflect across the entire system
class ProductionLineEnv(gym.Env):
def __init__(self):
# Action space: Number of machines to deploy at each station (1~50 units)
self.action_space = spaces.MultiDiscrete([MAX_MACHINES_PER_STATION] * 3)
# State space: [throughput, avg_wait_time, utilization_rate_per_station]
self.observation_space = spaces.Box(low=np.array([0, 0, 0, 0, 0]),
high=np.array([np.inf, np.inf, 100, 100, 100]))
Core Operation Logic:
- Initialization: Set up production line environment and define state/action spaces
- step() Function: Receive AI's machine allocation choice and execute simulation
- Simulation Execution: Model actual production processes using SimPy
- Reward Calculation: Calculate comprehensive score considering throughputโ, costโ, wait timeโ
- State Return: Provide current production line status for next decision-making
class SimpleProductionAgent:
def train(self, total_timesteps):
self.model = PPO("MlpPolicy", self.env,
learning_rate=0.0003,
n_steps=1024,
batch_size=64)
self.model.learn(total_timesteps=total_timesteps)
Core Operation Logic:
- Model Initialization: Create policy network using PPO algorithm
- Experience Collection: Accumulate (state, action, reward) data through environment interaction
- Policy Update: Optimize neural network weights based on collected experience
- Performance Evaluation: Compare performance between trained model and Monte Carlo method selection
- Model Saving: Save trained AI model to file
PPO Algorithm Selection Rationale:
- Stable learning performance
- Support for both continuous and discrete action spaces
- Proven reliability in industrial applications
def run_performance_analysis(self, num_episodes=100):
# Collect AI vs Monte Carlo method agent performance data
for agent_type in ['AI', 'Monte Carlo method']:
for i in range(num_episodes):
# Record performance metrics for each episode
agent_data.append({
'Agent': agent_type,
'Reward': reward,
'Throughput': info['throughput'],
'Cost': info['total_cost'],
'WaitTime': avg_wait_time
})
Core Operation Logic:
- Data Collection: Execute AI and Monte Carlo method 100 times each to accumulate performance data
- Statistical Analysis: Calculate descriptive statistics (mean, median, standard deviation)
- Comparative Analysis: Calculate AI performance improvement rates as percentages
- Visualization: Display results through 4 charts (throughput, cost, wait time, strategy distribution)
- Report Generation: Provide comprehensive performance reports via terminal and graphs
config.py โ Set simulation parameters
rl_environment.py โ Configure reinforcement learning environment
1. Start with random machine allocation
2. Execute simulation โ Observe results
3. Improve policy based on rewards
4. Repeat learning for 500,000 iterations
Trained AI vs Monte Carlo method selection approach
โ Execute 200 test runs
โ Statistical significance verification
โ Result visualization
pip install gymnasium stable-baselines3 simpy matplotlib seaborn pandas numpy
python simple_agent_v1.py
- Training time: Approximately 30-120 minutes (depending on computer performance)
- Result: Generates
my_production_ai.zip
model file
python training_analysis_v1.py
- View AI vs Monte Carlo method comparison results in terminal and graphs
# Various experimental conditions can be set in config.py
MAX_MACHINES_PER_STATION = 30 # Change machine count limit
apply_scenario('bottleneck_assembly') # Apply bottleneck scenario
- Meaning: Number of finished products per hour
- AI Performance: 100.9 units/hour (Monte Carlo method: 89.3 units/hour)
- Business Impact: 13.0% productivity improvement โ Direct revenue impact
- Meaning: Total cost required for machine operation
- AI Performance: AI's average operating cost was $3,760, which was 52.0% lower than the Monte Carlo method method's average cost ($7,828). Notably, AI demonstrated 25.1% better cost efficiency than the Monte Carlo method method's 'lowest cost' when it achieved 'maximum production'.
- Business Impact: 52.0% cost reduction โ Profitability improvement
- Meaning: Average time parts wait at each process
- AI Performance: Average 0.16 minutes (Monte Carlo method: 2.09 minutes)
- Business Impact: 92.3% wait time reduction โ Customer satisfaction improvement
- Practical Reinforcement Learning Application: Experience applying theory to real problems
- Simulation Modeling: Ability to mathematically model complex systems
- Performance Optimization: Experience solving multi-objective optimization problems
- Data Analysis: Methodology for scientifically analyzing experimental results
- Support for more complex production lines (4+ stations)
- Real-time demand fluctuation reflection
- Machine failure/maintenance situation modeling
- Simultaneous production of various product types
Inquiries about this project are always welcome!
This project was developed to demonstrate the practical value of AI technology and contribute to manufacturing innovation.