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])
LpVariable(name, indexs, lowBound=None, upBound=None, cat='Continuous')
name = 생성될 각 LP 변수 이름의 접두사indexs = LP 변수 사전의 키로 쓰일 문자열 리스트lowBound = 하한upBound = 상한cat = 변수 유형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])
LpVariable.dicts()Python으로 배우는 공급망 분석