LpVariable 사전 함수

Python으로 배우는 공급망 분석

Aaren Stubberfield

Supply Chain Analytics Mgr.

단순에서 복잡으로

복잡한 제과점 예시

# 의사결정변수 정의
A = LpVariable('A', lowBound=0, cat='Integer')
B = LpVariable('B', lowBound=0, cat='Integer')
C = LpVariable('C', lowBound=0, cat='Integer')
D = LpVariable('D', lowBound=0, cat='Integer')
E = LpVariable('E', lowBound=0, cat='Integer')
F = LpVariable('F', lowBound=0, cat='Integer')
# 목적함수 정의
var_dict = {"A":A, "B":B, "C":C, "D":D, "E":E, "F":F}

# 목적함수 정의
model += lpSum([profit_by_cake[type] * var_dict[type] for type in cake_types])
Python으로 배우는 공급망 분석

LpVariable.dicts() 사용하기

LpVariable(name, indexs, lowBound=None, upBound=None, cat='Continuous')
  • name = 생성될 각 LP 변수 이름의 접두사
  • indexs = LP 변수 사전의 키로 쓰일 문자열 리스트
  • lowBound = 하한
  • upBound = 상한
  • cat = 변수 유형
    • Integer
    • Binary
    • Continuous (기본값)
Python으로 배우는 공급망 분석

리스트 컴프리헨션과 LpVariable.dicts()

  • LpVariable.dicts()는 파이썬 리스트 컴프리헨션과 자주 함께 사용됨

운송 최적화

# 의사결정변수 정의
customers = ['East','South','Midwest','West']
warehouse = ['New York','Atlanta']
transport = LpVariable.dicts("route", [(w,c) for w in warehouse for c in customers],
                              lowBound=0, cat='Integer')

# 목적함수 정의 model += lpSum([cost[(w,c)]*transport[(w,c)] for w in warehouse for c in customers])
Python으로 배우는 공급망 분석

요약

  • 복잡한 문제의 많은 LP 변수 생성
  • LpVariable.dicts()
  • 리스트 컴프리헨션과 함께 사용
Python으로 배우는 공급망 분석

이제 직접 해보세요

Python으로 배우는 공급망 분석

Preparing Video For Download...