Skip to content

imjeasung/Production-Line-RL-PPO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

23 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿญ AI ๊ธฐ๋ฐ˜ ์ƒ์‚ฐ๋ผ์ธ ์ตœ์ ํ™” ์‹œ๋ฎฌ๋ ˆ์ด์…˜

๐Ÿ“‹ ํ”„๋กœ์ ํŠธ ๊ฐœ์š”

๐ŸŽฏ ํ”„๋กœ์ ํŠธ ๋ชฉ์ 

์ด ํ”„๋กœ์ ํŠธ๋Š” ์ธ๊ณต์ง€๋Šฅ(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

๐Ÿ“ ํŒŒ์ผ ๊ตฌ์กฐ ๋ฐ ์—ญํ• 

๐Ÿ”ง ํ•ต์‹ฌ ๊ตฌ์„ฑ ํŒŒ์ผ

1. config.py - ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์„ค์ • ๊ด€๋ฆฌ์ž

# ์ฃผ์š” ์„ค์ •๊ฐ’ ์˜ˆ์‹œ
MAX_MACHINES_PER_STATION = 50  # ๊ฐ ์Šคํ…Œ์ด์…˜๋ณ„ ์ตœ๋Œ€ ๊ธฐ๊ณ„ ์ˆ˜
SIMULATION_TIME = 60  # ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹œ๊ฐ„ (๋ถ„)
STATION_CONFIG = {
    'machining': {'capacity': 1, 'name': '๊ฐ€๊ณต ์Šคํ…Œ์ด์…˜'},
    'assembly': {'capacity': 1, 'name': '์กฐ๋ฆฝ ์Šคํ…Œ์ด์…˜'},  
    'inspection': {'capacity': 1, 'name': '๊ฒ€์‚ฌ ์Šคํ…Œ์ด์…˜'}
}

์—ญํ• :

  • ์ „์ฒด ์‹œ์Šคํ…œ์˜ ์„ค์ •๊ฐ’์„ ์ค‘์•™์ง‘์ค‘์‹์œผ๋กœ ๊ด€๋ฆฌ
  • ์Šคํ…Œ์ด์…˜๋ณ„ ๊ธฐ๊ณ„ ์ˆ˜, ์ž‘์—… ์‹œ๊ฐ„, ๋ถ€ํ’ˆ ํˆฌ์ž… ๊ฐ„๊ฒฉ ๋“ฑ์„ ์„ค์ •
  • ๋‹ค์–‘ํ•œ ์‹œ๋‚˜๋ฆฌ์˜ค(๋ณ‘๋ชฉ ๋ฐœ์ƒ, ๊ณ ์ˆ˜์š” ๋“ฑ) ํ”„๋ฆฌ์…‹ ์ œ๊ณต
  • ์‹คํ—˜ ์กฐ๊ฑด ๋ณ€๊ฒฝ ์‹œ ์ด ํŒŒ์ผ๋งŒ ์ˆ˜์ •ํ•˜๋ฉด ์ „์ฒด ์‹œ์Šคํ…œ์— ์ž๋™ ๋ฐ˜์˜

2. rl_environment.py - ๊ฐ•ํ™”ํ•™์Šต ํ™˜๊ฒฝ ๊ตฌํ˜„

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]))

ํ•ต์‹ฌ ๋™์ž‘ ๋กœ์ง:

  1. ์ดˆ๊ธฐํ™”: ์ƒ์‚ฐ๋ผ์ธ ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜๊ณ  ์ƒํƒœ๊ณต๊ฐ„/ํ–‰๋™๊ณต๊ฐ„ ์ •์˜
  2. step() ํ•จ์ˆ˜: AI๊ฐ€ ์„ ํƒํ•œ ๊ธฐ๊ณ„ ๋ฐฐ์น˜๋ฅผ ๋ฐ›์•„ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰
  3. ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰: SimPy๋ฅผ ์‚ฌ์šฉํ•ด ์‹ค์ œ ์ƒ์‚ฐ ๊ณผ์ •์„ ๋ชจ๋ธ๋ง
  4. ๋ณด์ƒ ๊ณ„์‚ฐ: ์ฒ˜๋ฆฌ๋Ÿ‰โ†‘, ๋น„์šฉโ†“, ๋Œ€๊ธฐ์‹œ๊ฐ„โ†“๋ฅผ ์ข…ํ•ฉํ•œ ์ ์ˆ˜ ์‚ฐ์ถœ
  5. ์ƒํƒœ ๋ฐ˜ํ™˜: ๋‹ค์Œ ์˜์‚ฌ๊ฒฐ์ •์„ ์œ„ํ•œ ํ˜„์žฌ ์ƒ์‚ฐ๋ผ์ธ ์ƒํƒœ ์ œ๊ณต

3. simple_agent_v1.py - AI ์—์ด์ „ํŠธ ํ•™์Šต ์‹œ์Šคํ…œ

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)

ํ•ต์‹ฌ ๋™์ž‘ ๋กœ์ง:

  1. ๋ชจ๋ธ ์ดˆ๊ธฐํ™”: PPO ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ์ •์ฑ… ๋„คํŠธ์›Œํฌ ์ƒ์„ฑ
  2. ๊ฒฝํ—˜ ์ˆ˜์ง‘: ํ™˜๊ฒฝ๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•˜๋ฉฐ (์ƒํƒœ, ํ–‰๋™, ๋ณด์ƒ) ๋ฐ์ดํ„ฐ ์ถ•์ 
  3. ์ •์ฑ… ์—…๋ฐ์ดํŠธ: ์ˆ˜์ง‘๋œ ๊ฒฝํ—˜์„ ๋ฐ”ํƒ•์œผ๋กœ ์‹ ๊ฒฝ๋ง ๊ฐ€์ค‘์น˜ ์ตœ์ ํ™”
  4. ์„ฑ๋Šฅ ํ‰๊ฐ€: ํ•™์Šต๋œ ๋ชจ๋ธ๊ณผ ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ• ์„ ํƒ ๋ฐฉ์‹์˜ ์„ฑ๋Šฅ ๋น„๊ต
  5. ๋ชจ๋ธ ์ €์žฅ: ํ•™์Šต ์™„๋ฃŒ๋œ AI ๋ชจ๋ธ์„ ํŒŒ์ผ๋กœ ์ €์žฅ

PPO ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์„ ํƒ ์ด์œ :

  • ์•ˆ์ •์ ์ธ ํ•™์Šต ์„ฑ๋Šฅ
  • ์—ฐ์†์ /์ด์‚ฐ์  ํ–‰๋™๊ณต๊ฐ„ ๋ชจ๋‘ ์ง€์›
  • ์‚ฐ์—… ํ˜„์žฅ์—์„œ ๊ฒ€์ฆ๋œ ์‹ ๋ขฐ์„ฑ

4. training_analysis_v1.py - ์„ฑ๋Šฅ ๋ถ„์„ ๋ฐ ์‹œ๊ฐํ™” ๋„๊ตฌ

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
            })

ํ•ต์‹ฌ ๋™์ž‘ ๋กœ์ง:

  1. ๋ฐ์ดํ„ฐ ์ˆ˜์ง‘: AI์™€ ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•์„ ๊ฐ๊ฐ 100ํšŒ์”ฉ ์‹คํ–‰ํ•˜์—ฌ ์„ฑ๋Šฅ ๋ฐ์ดํ„ฐ ์ถ•์ 
  2. ํ†ต๊ณ„ ๋ถ„์„: ํ‰๊ท , ์ค‘๊ฐ„๊ฐ’, ํ‘œ์ค€ํŽธ์ฐจ ๋“ฑ ๊ธฐ์ˆ ํ†ต๊ณ„๋Ÿ‰ ๊ณ„์‚ฐ
  3. ๋น„๊ต ๋ถ„์„: AI ๋Œ€๋น„ ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•์˜ ์„ฑ๋Šฅ ๊ฐœ์„ ๋ฅ ์„ ๋ฐฑ๋ถ„์œจ๋กœ ์‚ฐ์ถœ
  4. ์‹œ๊ฐํ™”: 4๊ฐœ ์ฐจํŠธ(์ฒ˜๋ฆฌ๋Ÿ‰, ๋น„์šฉ, ๋Œ€๊ธฐ์‹œ๊ฐ„, ์ „๋žต๋ถ„ํฌ)๋กœ ๊ฒฐ๊ณผ ํ‘œ์‹œ
  5. ๋ณด๊ณ ์„œ ์ƒ์„ฑ: ํ„ฐ๋ฏธ๋„๊ณผ ๊ทธ๋ž˜ํ”„๋ฅผ ํ†ตํ•œ ์ข…ํ•ฉ ์„ฑ๊ณผ ๋ฆฌํฌํŠธ ์ œ๊ณต

๐Ÿ”„ ์ „์ฒด ์‹œ์Šคํ…œ ๋™์ž‘ ํ๋ฆ„

1๋‹จ๊ณ„: ํ™˜๊ฒฝ ์„ค์ • ๋ฐ ์ดˆ๊ธฐํ™”

config.py โ†’ ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ํŒŒ๋ผ๋ฏธํ„ฐ ์„ค์ •
rl_environment.py โ†’ ๊ฐ•ํ™”ํ•™์Šต ํ™˜๊ฒฝ ๊ตฌ์„ฑ

2๋‹จ๊ณ„: AI ํ•™์Šต ๊ณผ์ •

1. ๋žœ๋ค ๊ธฐ๊ณ„ ๋ฐฐ์น˜๋กœ ์‹œ์ž‘
2. ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰ โ†’ ๊ฒฐ๊ณผ ๊ด€์ฐฐ
3. ๋ณด์ƒ์„ ๋ฐ”ํƒ•์œผ๋กœ ์ •์ฑ… ๊ฐœ์„ 
4. 500,000ํšŒ ๋ฐ˜๋ณต ํ•™์Šต

3๋‹จ๊ณ„: ์„ฑ๋Šฅ ๊ฒ€์ฆ

ํ•™์Šต๋œ AI vs ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ• ์„ ํƒ ๋ฐฉ์‹
โ†’ 200ํšŒ ํ…Œ์ŠคํŠธ ์‹คํ–‰
โ†’ ํ†ต๊ณ„์  ์œ ์˜์„ฑ ๊ฒ€์ฆ
โ†’ ๊ฒฐ๊ณผ ์‹œ๊ฐํ™”

๐Ÿš€ ์‹คํ–‰ ๋ฐฉ๋ฒ•

1. ์˜์กด์„ฑ ์„ค์น˜

pip install gymnasium stable-baselines3 simpy matplotlib seaborn pandas numpy

2. AI ํ•™์Šต ์‹คํ–‰

python simple_agent_v1.py
  • ํ•™์Šต ์‹œ๊ฐ„: ์•ฝ 30-120๋ถ„ (์ปดํ“จํ„ฐ ์„ฑ๋Šฅ์— ๋”ฐ๋ผ)
  • ๊ฒฐ๊ณผ: my_production_ai.zip ๋ชจ๋ธ ํŒŒ์ผ ์ƒ์„ฑ

3. ์„ฑ๋Šฅ ๋ถ„์„ ์‹คํ–‰

python training_analysis_v1.py
  • AI vs ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ• ๋น„๊ต ๊ฒฐ๊ณผ๋ฅผ ํ„ฐ๋ฏธ๋„๊ณผ ๊ทธ๋ž˜ํ”„๋กœ ํ™•์ธ production_ai_learning_curves

4. ์„ค์ • ๋ณ€๊ฒฝ (์„ ํƒ์‚ฌํ•ญ)

# config.py์—์„œ ๋‹ค์–‘ํ•œ ์‹คํ—˜ ์กฐ๊ฑด ์„ค์ • ๊ฐ€๋Šฅ
MAX_MACHINES_PER_STATION = 30  # ๊ธฐ๊ณ„ ์ˆ˜ ์ œํ•œ ๋ณ€๊ฒฝ
apply_scenario('bottleneck_assembly')  # ๋ณ‘๋ชฉ ์‹œ๋‚˜๋ฆฌ์˜ค ์ ์šฉ

๐Ÿ“ˆ ์ฃผ์š” ์„ฑ๊ณผ ์ง€ํ‘œ ํ•ด์„

์Šคํฌ๋ฆฐ์ƒท 2025-06-08 222249

๐ŸŽฏ ์ฒ˜๋ฆฌ๋Ÿ‰ (Throughput)

  • ์˜๋ฏธ: ์‹œ๊ฐ„๋‹น ์™„์„ฑํ’ˆ ์ƒ์‚ฐ ๊ฐœ์ˆ˜
  • AI ์„ฑ๊ณผ: ์‹œ๊ฐ„๋‹น ์ƒ์‚ฐ๋Ÿ‰ 100.9๊ฐœ (๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•: 89.3๊ฐœ/์‹œ๊ฐ„)
  • ๋น„์ฆˆ๋‹ˆ์Šค ์ž„ํŒฉํŠธ: 13.0% ์ƒ์‚ฐ์„ฑ ํ–ฅ์ƒ โ†’ ๋งค์ถœ ์ง๊ฒฐ

๐Ÿ’ฐ ์šด์˜๋น„์šฉ (Cost)

  • ์˜๋ฏธ: ๊ธฐ๊ณ„ ์šด์˜์— ํ•„์š”ํ•œ ์ด ๋น„์šฉ
  • AI ์„ฑ๊ณผ: AI์˜ ํ‰๊ท  ์šด์˜ ๋น„์šฉ์€ $3,760์œผ๋กœ, ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•์˜ ํ‰๊ท  ๋น„์šฉ($7,828) ๋Œ€๋น„ 52.0% ๋‚ฎ์•˜์Šต๋‹ˆ๋‹ค. ํŠนํžˆ AI๋Š” ๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•์ด ์ตœ๋Œ€ ์ƒ์‚ฐ๋Ÿ‰์„ ๊ธฐ๋กํ–ˆ์„ ๋•Œ์˜ ์ตœ์ € ๋น„์šฉ๋ณด๋‹ค๋„ 25.1% ๋” ๋‚ฎ์€ ๋น„์šฉ ํšจ์œจ์„ฑ์„ ๋ณด์˜€์Šต๋‹ˆ๋‹ค.
  • ๋น„์ฆˆ๋‹ˆ์Šค ์ž„ํŒฉํŠธ: 52.0% ๋น„์šฉ ์ ˆ๊ฐ โ†’ ์ˆ˜์ต์„ฑ ๊ฐœ์„ 

โฑ๏ธ ๋Œ€๊ธฐ์‹œ๊ฐ„ (Wait Time)

  • ์˜๋ฏธ: ๋ถ€ํ’ˆ์ด ๊ฐ ๊ณต์ •์—์„œ ๋Œ€๊ธฐํ•˜๋Š” ํ‰๊ท  ์‹œ๊ฐ„
  • AI ์„ฑ๊ณผ: ํ‰๊ท  0.16๋ถ„ (๋ชฌํ…Œ ์นด๋ฅผ๋กœ ๋ฐฉ๋ฒ•: 2.09๋ถ„)
  • ๋น„์ฆˆ๋‹ˆ์Šค ์ž„ํŒฉํŠธ: 92.3% ๋Œ€๊ธฐ์‹œ๊ฐ„ ๋‹จ์ถ• โ†’ ๊ณ ๊ฐ ๋งŒ์กฑ๋„ ํ–ฅ์ƒ

๐ŸŽ“ ํ•™์Šต ๊ฐ€์น˜

๊ธฐ์ˆ ์  ํ•™์Šต ํฌ์ธํŠธ

  1. ๊ฐ•ํ™”ํ•™์Šต ์‹ค์ „ ์ ์šฉ: ์ด๋ก ์„ ์‹ค์ œ ๋ฌธ์ œ์— ์ ์šฉํ•˜๋Š” ๊ฒฝํ—˜
  2. ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ๋ชจ๋ธ๋ง: ๋ณต์žกํ•œ ์‹œ์Šคํ…œ์„ ์ˆ˜ํ•™์ ์œผ๋กœ ๋ชจ๋ธ๋งํ•˜๋Š” ๋Šฅ๋ ฅ
  3. ์„ฑ๋Šฅ ์ตœ์ ํ™”: ๋‹ค๋ชฉ์  ์ตœ์ ํ™” ๋ฌธ์ œ ํ•ด๊ฒฐ ๊ฒฝํ—˜
  4. ๋ฐ์ดํ„ฐ ๋ถ„์„: ์‹คํ—˜ ๊ฒฐ๊ณผ๋ฅผ ๊ณผํ•™์ ์œผ๋กœ ๋ถ„์„ํ•˜๋Š” ๋ฐฉ๋ฒ•๋ก 

๐Ÿ”ฎ ํ–ฅํ›„ ๊ฐœ์„  ๋ฐฉํ–ฅ

๊ฐœ์„  ์‚ฌํ•ญ

  • ๋” ๋ณต์žกํ•œ ์ƒ์‚ฐ๋ผ์ธ (4๊ฐœ ์ด์ƒ ์Šคํ…Œ์ด์…˜) ์ง€์›
  • ์‹ค์‹œ๊ฐ„ ์ˆ˜์š” ๋ณ€๋™ ๋ฐ˜์˜
  • ๊ธฐ๊ณ„ ๊ณ ์žฅ/์œ ์ง€๋ณด์ˆ˜ ์ƒํ™ฉ ๋ชจ๋ธ๋ง
  • ๋‹ค์–‘ํ•œ ์ œํ’ˆ ํƒ€์ž… ๋™์‹œ ์ƒ์‚ฐ

๐Ÿ“ž ์—ฐ๋ฝ์ฒ˜ ๋ฐ ์ถ”๊ฐ€ ์ •๋ณด

์ด ํ”„๋กœ์ ํŠธ์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ๋ฌธ์˜๋Š” ์–ธ์ œ๋“  ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค!


์ด ํ”„๋กœ์ ํŠธ๋Š” AI ๊ธฐ์ˆ ์˜ ์‹ค์šฉ์  ๊ฐ€์น˜๋ฅผ ์ž…์ฆํ•˜๊ณ , ์ œ์กฐ์—… ํ˜์‹ ์— ๊ธฐ์—ฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋ชฉ์ ์œผ๋กœ ๊ฐœ๋ฐœ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿญ AI-Powered Production Line Optimization Simulation

๐Ÿ“‹ Project Overview

๐ŸŽฏ Project Purpose

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.

๐Ÿค– Core Concept

  • 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

๐Ÿ“Š Key Performance Results (Actual Execution)

  • 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)

๐Ÿ› ๏ธ Technology Stack

Core Technologies

  • Reinforcement Learning: PPO (Proximal Policy Optimization) Algorithm
  • Simulation: SimPy (Discrete Event Simulation Library)
  • AI Framework: Stable-Baselines3
  • Data Analysis: Pandas, NumPy, Matplotlib, Seaborn

Development Environment

  • Language: Python 3.8+
  • Key Libraries: gymnasium, stable-baselines3, simpy, matplotlib, seaborn

๐Ÿ“ File Structure and Roles

๐Ÿ”ง Core Components

1. config.py - Simulation Configuration Manager

# 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

2. rl_environment.py - Reinforcement Learning Environment Implementation

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:

  1. Initialization: Set up production line environment and define state/action spaces
  2. step() Function: Receive AI's machine allocation choice and execute simulation
  3. Simulation Execution: Model actual production processes using SimPy
  4. Reward Calculation: Calculate comprehensive score considering throughputโ†‘, costโ†“, wait timeโ†“
  5. State Return: Provide current production line status for next decision-making

3. simple_agent_v1.py - AI Agent Training System

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:

  1. Model Initialization: Create policy network using PPO algorithm
  2. Experience Collection: Accumulate (state, action, reward) data through environment interaction
  3. Policy Update: Optimize neural network weights based on collected experience
  4. Performance Evaluation: Compare performance between trained model and Monte Carlo method selection
  5. 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

4. training_analysis_v1.py - Performance Analysis and Visualization Tool

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:

  1. Data Collection: Execute AI and Monte Carlo method 100 times each to accumulate performance data
  2. Statistical Analysis: Calculate descriptive statistics (mean, median, standard deviation)
  3. Comparative Analysis: Calculate AI performance improvement rates as percentages
  4. Visualization: Display results through 4 charts (throughput, cost, wait time, strategy distribution)
  5. Report Generation: Provide comprehensive performance reports via terminal and graphs

๐Ÿ”„ Overall System Workflow

Stage 1: Environment Setup and Initialization

config.py โ†’ Set simulation parameters
rl_environment.py โ†’ Configure reinforcement learning environment

Stage 2: AI Learning Process

1. Start with random machine allocation
2. Execute simulation โ†’ Observe results
3. Improve policy based on rewards
4. Repeat learning for 500,000 iterations

Stage 3: Performance Validation

Trained AI vs Monte Carlo method selection approach
โ†’ Execute 200 test runs
โ†’ Statistical significance verification
โ†’ Result visualization

๐Ÿš€ How to Run

1. Install Dependencies

pip install gymnasium stable-baselines3 simpy matplotlib seaborn pandas numpy

2. Execute AI Training

python simple_agent_v1.py
  • Training time: Approximately 30-120 minutes (depending on computer performance)
  • Result: Generates my_production_ai.zip model file

3. Execute Performance Analysis

python training_analysis_v1.py
  • View AI vs Monte Carlo method comparison results in terminal and graphs

production_ai_learning_curves

4. Configuration Changes (Optional)

# 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

๐Ÿ“ˆ Key Performance Metrics Interpretation

์Šคํฌ๋ฆฐ์ƒท 2025-06-08 222249

๐ŸŽฏ Throughput

  • 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

๐Ÿ’ฐ Operating Cost

  • 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

โฑ๏ธ Wait Time

  • 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

๐ŸŽ“ Learning Value

Technical Learning Points

  1. Practical Reinforcement Learning Application: Experience applying theory to real problems
  2. Simulation Modeling: Ability to mathematically model complex systems
  3. Performance Optimization: Experience solving multi-objective optimization problems
  4. Data Analysis: Methodology for scientifically analyzing experimental results

๐Ÿ”ฎ Future Improvement Directions

Improvement Items

  • Support for more complex production lines (4+ stations)
  • Real-time demand fluctuation reflection
  • Machine failure/maintenance situation modeling
  • Simultaneous production of various product types

๐Ÿ“ž Contact and Additional Information

Inquiries about this project are always welcome!


This project was developed to demonstrate the practical value of AI technology and contribute to manufacturing innovation.