Code Monkey home page Code Monkey logo

Comments (10)

timnon avatar timnon commented on August 31, 2024 1

Yes, i think i understood the problem, like in the example above, having two green or red courses in parallel would be ok, but not a mix of red and green

from pyschedule.

timnon avatar timnon commented on August 31, 2024

Hi,
unfortunately, i dont think that this is possible at the moment, but will be in the future. It is already possible to allow a resource to process things in parallel, like in the following example. The one thing missing is to restrict the parallel processing to one type of task. This requires the adding of capacity constraints, sth that is high on my todo list. I will try to add this in the next days since there seems to be use cases.

from pyschedule import Scenario, solvers, plotters, alt

S = Scenario('parallel_courses',horizon=20)

#size 2 means teacher can do two things in parallel
Teacher = S.Resource('T',size=2) 

Courses_English = S.Tasks('CE',num=10,completion_time_cost=1,plot_color='red')
Courses_Math = S.Tasks('CM',num=10,completion_time_cost=1,plot_color='green')

Courses_English += Teacher
Courses_Math += Teacher

if solvers.mip.solve(S,time_limit=600,msg=1):
    plotters.matplotlib.plot(S,show_task_labels=True)
else:
    print('no solution found')

There is no way to restrict that only Math or English classes are processed in parallel (at the moment), so the result might look like this:

screen shot 2018-08-13 at 08 17 07

from pyschedule.

kindlyfire avatar kindlyfire commented on August 31, 2024

restrict the parallel processing to one type of task

I'd need parallel processing of groups of multiple types of tasks. Eg., he can do [Task1, Task2] at the same time and [Task3, Task4] at the same time, but not [Task1, Task3]

from pyschedule.

kindlyfire avatar kindlyfire commented on August 31, 2024

That's totally it

from pyschedule.

kindlyfire avatar kindlyfire commented on August 31, 2024

Is there any way I could help ? I saw you created the add_capacities branch and made a commit, is there any way of testing ?

from pyschedule.

timnon avatar timnon commented on August 31, 2024

The add_capacities branch is indeed the branch with the required features. It would be great if you could test this branch. It is now possible to do the following

from pyschedule import Scenario, solvers, plotters, alt

horizon = 20
S = Scenario('parallel_courses',horizon=horizon)

#size 2 means teacher can do two things in parallel
Teacher = S.Resource('T',size=2)

Courses_English = S.Tasks('CE',num=10,completion_time_cost=1,plot_color='red',english=1)
Courses_Math = S.Tasks('CM',num=10,completion_time_cost=1,plot_color='green',math=1)

Courses_English += Teacher
Courses_Math += Teacher

# NEW FEATURES: adding capacities and .max
S += Teacher['english'][0:horizon:1].max + Teacher['math'][0:horizon:1].max <= 1

if solvers.mip.solve(S,time_limit=600,msg=1):
    plotters.matplotlib.plot(S,show_task_labels=True)
else:
    print('no solution found')

To explain: Teacher['english'][0:horizon:1].max gives the sequence of capacity slices

Teacher['english'][0:1].max, Teacher['english'][1:2].max, ... , Teacher['english'][horizon-1:horizon].max

and e.g. Teacher['english'][0:1].max is the maximum english-param of any task in period 0 (this is the python slice notation of all periods t with 0 <= t < 1). Since all english course have english=1, this just measures if there is any english course scheduled on resource Teacher in period 0. Therefore, Teacher['english'][0:1].max + Teacher['math'][0:1].max is 2 if both an english and a math course are scheduled on resource Teacher in period 0, the case we want to avoid by using the constraint <= 1. The final result is hence correct, there are either two english courses or two math courses scheduled in each period:

figure_1

from pyschedule.

kindlyfire avatar kindlyfire commented on August 31, 2024

I think I got how to do it, though I have a question. The way I see this is that it is implemented as a black-list, "can't do that and that at the same time", although I'm looking to make it a whitelist: "cant do two things at the same time, except for these two specific courses". Is there a way I can achieve that ?

I know I could implement a white-list as a black-list (add a constraint for EVERY course except two of them), but that would add a lot of constraints, growing what I guess is exponentially, when the number of classes goes up.

from pyschedule.

timnon avatar timnon commented on August 31, 2024

Regarding a whitelist: the scheduling rules need to get translated to constraints for a solver, and a solver needs to know what is not allowed, basically the inverse of what is allowed. Thats why only giving a “blacklist“ works.

Did you get your example running anyway?

from pyschedule.

kindlyfire avatar kindlyfire commented on August 31, 2024

I haven't been able to get it implemented yet. I will do so in the next days.

from pyschedule.

timnon avatar timnon commented on August 31, 2024

adding capacities and max-capacities are now in the master branch

from pyschedule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.