{"action":"created","issue":{"url":"https://api.github.com/repos/timnon/pyschedule/issues/3","repository_url":"https://api.github.com/repos/timnon/pyschedule","labels_url":"https://api.github.com/repos/timnon/pyschedule/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/timnon/pyschedule/issues/3/comments","events_url":"https://api.github.com/repos/timnon/pyschedule/issues/3/events","html_url":"https://github.com/timnon/pyschedule/issues/3","id":135941461,"number":3,"title":"How to handle big task across holidays?","user":{"login":"crayster","id":4060634,"avatar_url":"https://avatars.githubusercontent.com/u/4060634?v=3","gravatar_id":"","url":"https://api.github.com/users/crayster","html_url":"https://github.com/crayster","followers_url":"https://api.github.com/users/crayster/followers","following_url":"https://api.github.com/users/crayster/following{/other_user}","gists_url":"https://api.github.com/users/crayster/gists{/gist_id}","starred_url":"https://api.github.com/users/crayster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayster/subscriptions","organizations_url":"https://api.github.com/users/crayster/orgs","repos_url":"https://api.github.com/users/crayster/repos","events_url":"https://api.github.com/users/crayster/events{/privacy}","received_events_url":"https://api.github.com/users/crayster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-24T03:19:40Z","updated_at":"2016-02-24T10:04:12Z","closed_at":null,"body":"Hello there,\r\nI'm not sure whether CAPSLICE is supported by mip.solve, it seems YES according to the test result.\r\n\r\nAssume a simple scenario:\r\n```\r\nS = Scenario('test1', horizon=10)\r\n\r\n# only one task, consuming 7 days\r\nT1 = S.Task('T1', 7)\r\n\r\n# only one resource, not work in weekend\r\nR1 = S.Resource('R1')\r\nS += S['R1']['length'][5:7] <= 0\r\n\r\nS['T1'] += S['R1']\r\nsolvers.mip.solve(S)\r\n```\r\n\r\nExpected result is:\r\n`[(T1, R1, 0, 9)]`\r\n\r\nbut returned:\r\n`[(T1, R1, 0, 7)]`\r\n\r\nAny idea? Thank you very much!"},"comment":{"url":"https://api.github.com/repos/timnon/pyschedule/issues/comments/188173066","html_url":"https://github.com/timnon/pyschedule/issues/3#issuecomment-188173066","issue_url":"https://api.github.com/repos/timnon/pyschedule/issues/3","id":188173066,"user":{"login":"timnon","id":5597397,"avatar_url":"https://avatars.githubusercontent.com/u/5597397?v=3","gravatar_id":"","url":"https://api.github.com/users/timnon","html_url":"https://github.com/timnon","followers_url":"https://api.github.com/users/timnon/followers","following_url":"https://api.github.com/users/timnon/following{/other_user}","gists_url":"https://api.github.com/users/timnon/gists{/gist_id}","starred_url":"https://api.github.com/users/timnon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timnon/subscriptions","organizations_url":"https://api.github.com/users/timnon/orgs","repos_url":"https://api.github.com/users/timnon/repos","events_url":"https://api.github.com/users/timnon/events{/privacy}","received_events_url":"https://api.github.com/users/timnon/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T10:04:12Z","updated_at":"2016-02-24T10:04:12Z","body":"thanks for the valuable feedback. The main problem is that tasks are non-preemptive by default, that means that they cannot be split into two parts. If a task with length 7 starts in some period x, then it needs to run for 7 consecutive periods starting with x.\r\n\r\nFor the scenario above, you could split T1 into 7 tasks of length 1:\r\n\r\n```python\r\nfrom pyschedule import Scenario, solvers\r\nS = Scenario('test1', horizon=10)\r\n\r\n# 7 tasks, each consuming one day\r\nn_days = 7\r\ntasks = [ S.Task('T_%i'%i) for i in range(n_days) ]\r\n# order tasks\r\nS += [ tasks[i] < tasks[i+1] for i in range(n_days-1) ]\r\n\r\n# only one resource, not work in weekend\r\nR1 = S.Resource('R1')\r\nS += S['R1']['length'][5:7] <= 0\r\n\r\n# all tasks need the same resource\r\nfor T in tasks:\r\n\tT += S['R1']\r\n\r\n# finish tasks as soon as possible\r\nS.use_flowtime_objective()\r\n\r\nsolvers.mip.solve(S)\r\nprint(S.solution())\r\n```\r\n\r\nreturns\r\n\r\n```python\r\n[(T_0, R1, 0, 1), (T_1, R1, 1, 2), (T_2, R1, 2, 3), (T_3, R1, 3, 4), \r\n(T_4, R1, 4, 5), (T_5, R1, 7, 8), (T_6, R1, 8, 9)]\r\n```\r\nI added the usage of the flowtime objective to ensure that tasks are pushed to the beginning of the planning horizon as much as possible.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}