import numpy as np, pandas as pd from pulp import * from ortoolpy import addvars, addbinvars from io import StringIO a = pd.read_table(StringIO("""\ 曜日\t月\t月\t月\t火\t火\t火\t水\t水\t水\t木\t木\t木\t金\t金\t金\t土\t土\t土\t日\t日\t日 時間帯\t朝\t昼\t夜\t朝\t昼\t夜\t朝\t昼\t夜\t朝\t昼\t夜\t朝\t昼\t夜\t朝\t昼\t夜\t朝\t昼\t夜 必要人数\t2\t3\t3\t2\t3\t3\t2\t3\t3\t1\t2\t2\t2\t3\t3\t2\t4\t4\t2\t4\t4 従業員0\t○\t\t\t○\t\t\t○\t\t\t○\t\t\t○\t\t\t○\t\t\t○\
![組合せ最適化でナーススケジューリング問題を解く - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/b73ccc718e999f97a2bdfcbca38343ba9a445fd5/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Farticle-ogp-background-412672c5f0600ab9a64263b751f1bc81.png%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTk3MiZoPTM3OCZ0eHQ9JUU3JUI1JTg0JUU1JTkwJTg4JUUzJTgxJTlCJUU2JTlDJTgwJUU5JTgxJUE5JUU1JThDJTk2JUUzJTgxJUE3JUUzJTgzJThBJUUzJTgzJUJDJUUzJTgyJUI5JUUzJTgyJUI5JUUzJTgyJUIxJUUzJTgyJUI4JUUzJTgzJUE1JUUzJTgzJUJDJUUzJTgzJUFBJUUzJTgzJUIzJUUzJTgyJUIwJUU1JTk1JThGJUU5JUExJThDJUUzJTgyJTkyJUU4JUE3JUEzJUUzJTgxJThGJnR4dC1hbGlnbj1sZWZ0JTJDdG9wJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmcz05NjNkODczY2U3ZGQ0ZDExZTUzNzYzOTA0MzI1ZDZmZA%26mark-x%3D142%26mark-y%3D57%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZoPTc2Jnc9NzcwJnR4dD0lNDBTYWl0b1RzdXRvbXUmdHh0LWNvbG9yPSUyMzIxMjEyMSZ0eHQtZm9udD1IaXJhZ2lubyUyMFNhbnMlMjBXNiZ0eHQtc2l6ZT0zNiZ0eHQtYWxpZ249bGVmdCUyQ3RvcCZzPTNlY2ZiNjRiMzE3N2NmMDM4MGY1ODdhMmRlMjIzNzNh%26blend-x%3D142%26blend-y%3D486%26blend-mode%3Dnormal%26s%3De32f36c4653ff378eee16bd3f47f8faf)