Created
November 4, 2020 04:40
-
-
Save moomoo-ya/4569adcf3eb358b5e67d8f8bbc07692b to your computer and use it in GitHub Desktop.
DeathMarch: Destribute tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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