Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DeathMarch: Destribute tasks
import pulp
# 問題の定義(最小を探す)
problem = pulp.LpProblem('Distribute Tasks', pulp.LpMinimize)
# 変数の定義
# 名前, 労働時間下限, 労働時間上限, 型
hiyoko = pulp.LpVariable('Hiyoko', 0, None, 'Integer')
tsuyo = pulp.LpVariable('TsuyoTsuyo', 0, None, 'Integer')
manager = pulp.LpVariable('Manager', 0, None, 'Integer')
# 目的関数の定義
# 残業コストをかける
# ひよこ   : 10 x 1.2 = 12
# つよつよ  : 20 x 1.2 = 24
# マネージャー: 0
problem += 12 * (hiyoko - 160) + 24 * (tsuyo - 160) + 0 * (manager - 160)
# 制約条件の定義
# 所定労働時間
SCHEDULED = 160
problem += hiyoko >= SCHEDULED
problem += tsuyo >= SCHEDULED
problem += manager >= SCHEDULED
# 1時間で消化できるタスク量
problem += 5 * hiyoko + 10 * tsuyo + 8 * manager == 9000
# # 残業時間の制約
OVERTIME = 200
problem += hiyoko <= SCHEDULED + OVERTIME
problem += tsuyo <= SCHEDULED + OVERTIME
problem += manager <= SCHEDULED + OVERTIME
# 算出&出力
status = problem.solve()
print(pulp.LpStatus[status]) # Optimal = 最適解あり
print("ひよこ労働時間(残業): ", hiyoko.value(), " (", hiyoko.value() - 160, ")時間")
print("つよつよ労働時間(残業): ", tsuyo.value(), " (", tsuyo.value() - 160, ")時間")
print("マネージャー労働時間(残業): ", manager.value(), " (", manager.value() - 160, ")時間")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment