Study regulations#

Create a study plan based on study regulations.

This encodings are used in the paper for study regulations in ICLP 2024.

Usage#

$ clinguin client-server --domain-files study_regulations/{encoding.lp,instance.lp} --ui-files study_regulations/ui.lp -c n=4

Domain Files#

instance.lp#
#const n = 4.

% b, f, a, o and p               % c
in((bm1;bm2;bm3),b).             map(c,(bm1;bm2;bm3),9).
in((fm1;fm2;fm3),f).             map(c,(fm1;fm2;fm3),6).
in((am11;am12;am21),a).          map(c,(am11;am12;am21),6).
in((am22;am31;am32),a).          map(c,(am22;am31;am32),6).
in(E,o) :- in(E,(f;a)).          map(c,(pm1;pm2;pm3),12).
in((pm1;pm2;pm3),p).             map(c,im,15).
                                 map(c,msc,30).

% m                              % s
in(E,m) :- in(E,(b;f;a;p)).      map(s,bm1,w;s,bm2,s;s,bm3,w).
in((im;msc),m).                  map(s,(fm1;fm2;fm3),w).
                                 map(s,(am11;am12;am21),e).
                                 map(s,(am22;am31;am32),e).
% e                              map(s,(pm1;pm2;pm3),e).
in(fm1,e).                       map(s,(im1;msc1),e).

                                 % l and u
                                 map(l,b,27;l,o,24;l,p,24;l,m,120).
                                 map(u,b,27;u,o,24;u,p,24;u,m,120).

% global constraints
card(e,leq,2).  equal(int(s,f),e).
sum(int(H,s),c,bw,(L,U)) :- H = (b;o;p;m), map(l,H,L), map(u,H,U).
in(im,gc3). in(msc,gc3). subseteq(gc3,s).

% temporal constraints
empty(int(s(I),s(J)))       :- I = 1..n, J = 1..n, I < J.
empty(int(m(w),s(2*K  )))   :- K = 1..n, 1 <= 2*K,   2*K   <= n.
empty(int(m(s),s(2*K-1)))   :- K = 1..n, 1 <= 2*K-1, 2*K-1 <= n.
in(msc,tc4). sum(before(tc4),c,geq,90).
encoding.lp#
% generate
{ in(E,s(I)) } :- in(E,m), I=1..n.

% s = s(1) U ... U s(n)
in(E,s) :- in(E,s(I)).

% m(w) and m(s)
in(E,m(X)) :- X = (s;w), in(E,m), map(s,E,X).

% additional sets
set(A) :-      empty(A).
set(A) :- subseteq(A,B).    set(A) :-   equal(A,B).
set(B) :- subseteq(A,B).    set(B) :-   equal(A,B).
set(A) :-   card(A,R,L).    set(A) :- sum(A,M,R,L).
%
set(A) :- set( int(A,B)).   set(B) :- set(int(A,B)).
set(A) :- set(before(A)).
%
in( E, int(A,B)) :- set( int(A,B)), in(E,A), in(E,B).
in(E1,before(A)) :- set(before(A)), in(E1,s(I)), in(E2,A), in(E2,s(J)), I < J.

% constraints
:- empty(A), in(E,A).
%
:- subseteq(A,B), in(E,A), not in(E,B).
%
:- equal(A,B), in(E,A), not in(E,B).
:- equal(A,B), not in(E,A), in(E,B).
%
:- card(A,leq,U), not { in(E,A) } U.
%
:- sum(A,F,bw,(L,U)), not L #sum{ V,E : in(E,A), map(F,E,V) } U.
:- sum(A,F,geq,   L), not L #sum{ V,E : in(E,A), map(F,E,V) }.

% display
% #show.
% #show (M,I) : in(M,s(I)).

UI Files#

ui.lp#
semester(1..n).

elem(w, window, root).
attr(w, flex_direction, row).

    elem(s(I), container, w):-semester(I).
    attr(s(I), order, I):-semester(I).

    elem(s_t(I), container, s(I)):-semester(I).
    attr(s_t(I), order, 1):-semester(I).
    attr(s_t(I), class, ("bg-primary";"bg-opacity-50";"fw-bold";"p-2";"m-1")):-semester(I).

        elem(s_l(I), label, s_t(I)):-semester(I).
        attr(s_l(I), label, @concat("Semester ",I)):-semester(I).
        attr(s_l(I), order, 1):-semester(I).

        elem(s_dd(I), dropdown_menu, s_t(I)):-semester(I).
        attr(s_dd(I), order, 2):-semester(I).
        attr(s_dd(I), selected, "Assign module"):-semester(I).
        attr(s_dd(I), class, ("btn-sm";"btn-info")):-semester(I).

            elem(s_ddi(I,E), dropdown_menu_item, s_dd(I)):-_any(in(E,s(I))), not _all(in(E,s(I))).
            attr(s_ddi(I,E), label, E):-_any(in(E,s(I))), not _all(in(E,s(I))).
            when(s_ddi(I,E), click, call, add_assumption(in(E,s(I)),true)):-_any(in(E,s(I))), not _all(in(E,s(I))).

    elem(s_modules(I), container, s(I)):-semester(I).
    attr(s_modules(I), class, ("bg-white")):-semester(I).
    attr(s_modules(I), order, 2):-semester(I).

        shown_module(E,I):-_all(in(E,s(I))).
        shown_module(E,I):-in(E,s(I)),_clinguin_browsing.

        elem(s_module(I,E), container, s_modules(I)):-shown_module(E,I).
        attr(s_module(I,E), height, C*10):-shown_module(E,I), map(c,E,C).
        attr(s_module(I,E), class, ("bg-info";"bg-opacity-50";
                                    "d-flex";"flex-row";"justify-content-between";"align-items-center";
                                    "p-2";"m-1")):-shown_module(E,I).

            elem(s_module_l(I,E), label, s_module(I,E)):-shown_module(E,I).
            attr(s_module_l(I,E), label, E):-shown_module(E,I).

            elem(s_module_b(I,E), button, s_module(I,E)):-_clinguin_assume(in(E,s(I)),true).
            attr(s_module_b(I,E), icon, "fa-times"):-_clinguin_assume(in(E,s(I)),true).
            attr(s_module_b(I,E), class, ("btn-sm";"btn-outline")):-_clinguin_assume(in(E,s(I)),true).
            when(s_module_b(I,E), click, call, remove_assumption(in(E,s(I)))):-_clinguin_assume(in(E,s(I)),true).


elem(menu_bar, menu_bar, w).
attr(menu_bar, title, "Study Regulations").
attr(menu_bar, icon, "fa-graduation-cap").

elem(menu_bar_next, button, menu_bar).
attr(menu_bar_next, label, "Next").
attr(menu_bar_next, icon, "fa-forward-step").
when(menu_bar_next, click, call, next_solution).