javascriptpythonprologdata-sciencedata-science-experience

LF Framework to solve Data Science Issue


i'm looking for a framework that is able to solve the following Data Science issue:

I have several Teachers that can work for X amount of hours a week and have several subject that they can teach.

In a school, every subject needs a specific amount of hours per week. Some more than others

Lets say one teacher can do 2-3 hours just so you get my point^^

The Solution im looking for is a Framework or Algoritm that is filled (trained) with the data and then is able to distribute the teachers so all the subjects are capped or at least as close as possible. That means maybe Teacher 2 needs to teach only Math and Teacher 5 needs to teach 50% Sport and 50% English or 30% Math / 40% Sport / 30% English.

Someone mentioned Prolog but im not sure if it can handle this kind of problem? Maybe im wrong?

Is there something that is fitting for my problem or am i destined to code that algorithm from scratch on my own?

Thanks in advance.


Solution

  • An simple program to show constraint solving for this specific example in gnu-prolog:

    soln(X) :-
        X = [T1M, T2M, T2E, T3S, T3A, T3E, T4M, T4A, T5S, T5M, T5E],
        fd_domain(X, 0, 10),
    
        %% subject constraints
        T1M + T2M + T4M + T5M #= 12,
        T2E + T3E + T5E #= 8,
        T4A + T3A #= 4,
        T3S + T5S #= 2,
    
        %% teacher constraints b/w 2 and 8 hrs
        2 #=< T1M, T1M #=< 8,
        2 #=< T2M + T2E, T2M + T2E #=< 8,
        2 #=< T3S + T3E + T3A, T3S + T3E + T3A #=< 8,
        2 #=< T4M + T4A, T4M + T4A #=< 8,
        2 #=< T5S + T5M + T5E, T5S + T5M + T5E #=< 8,
        fd_labeling(X).
    

    with a few solutions

    | ?- soln(X).
    
    X = [2,0,2,0,0,6,4,4,2,6,0] ? ;
    
    X = [2,0,2,0,1,5,5,3,2,5,1] ? ;
    
    X = [2,0,2,0,1,6,4,3,2,6,0] ? ;
    
    X = [2,0,2,0,1,6,5,3,2,5,0] ? ;
    
    X = [2,0,2,0,2,4,6,2,2,4,2] ? ;
    
    X = [2,0,2,0,2,5,5,2,2,5,1] ? ;
    
    X = [2,0,2,0,2,5,6,2,2,4,1] ? ;
    
    X = [2,0,2,0,2,6,4,2,2,6,0] ? ;
    
    X = [2,0,2,0,2,6,5,2,2,5,0] ? ;
    
    X = [2,0,2,0,2,6,6,2,2,4,0] ? ;
    
    X = [2,0,2,0,3,3,7,1,2,3,3] ? ;
    
    X = [2,0,2,0,3,4,6,1,2,4,2] ? ;
    
    X = [2,0,2,0,3,4,7,1,2,3,2] ? 
    

    Each solution X = ... gives the distribution for hours for T1M, T2M, T2E, T3S, T3A, T3E, T4M, T4A, T5S, T5M, T5E respectively.