그림자 가격과 슬랙 연습 pt2
이 연습에서는 앞으로 4개월간의 회사 생산 계획을 다룹니다. 목표는 고객 수요를 충족하면서도 생산 비용(고정 + 변동)과 보관 비용을 최소화하기 위해 각 달에 얼마나 생산할지 결정하는 것입니다. 매달 생산 능력과 수요에 대한 제약이 있습니다.
이 연습은 강의의 일부입니다
Python으로 배우는 공급망 분석
연습 안내
샘플 코드 하단 근처의 코드를 완성해, 제약 조건의 슬랙을 보여주는 Pandas DataFrame을 생성하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
model = LpProblem("Production Planning", LpMinimize)
time = [1, 2, 3, 4]
s = LpVariable.dicts("stock_in", [0, 1, 2, 3, 4], lowBound=0, cat="Integer")
x = LpVariable.dicts("prod_in", time, lowBound=0, cat="Integer")
y = LpVariable.dicts("plant_on_", time, lowBound=0, cat="Binary")
model += lpSum([d.loc[t,"unit_prod"]*x[t] + d.loc[t,"unit_inv"]*s[t]
+ d.loc[t,"fixed_setup"]*y[t] for t in time])
s[0] = 100
for t in time:
model += s[t-1] + x[t] == d.loc[t,"demand"] + s[t]
model += x[t] <= d.loc[t,"prod_cap"]*y[t]
model.solve()
# Print the Constraint Slack
o = [{'name':name, 'slack':____}
for ____, c in ____]
print(____)