%% PLANIFICATOR A RUTELOR DE ZBORURI AERIENE :- op( 50, xfy, :). % ruta( Loc1, Loc2, Zi, Ruta): % Ruta este o secventă de zboruri in ziua Zi, care incepe de la Loc1 şi se incheie la Loc2 ruta( L1, L2, Zi, [ L1 / L2 / Fnum / Deptime ] ) :- % Zbor direct zbor( L1, L2, 21, Fnum, Dept1me, _). % Deptime - timp plecare ruta( L1, L2, Zi, [ (L1 / L3 / Fnuml / DeL1) | RestRuta] ) :- % Zbor indirect ruta( L3, L2, Zi, RestRuta), zbor( L1, L3, Z1, Fnum1, DeL1, Arr1), deptime( RestRuta, DeL2), % Deptime of Route - timpul de plecare pentru Ruta. transfer( Arr1, DeL2). % Suficient timp pentru transfer zbor( Loc1, Loc2, Zi, Fnum, Deptime, Arrt1me) :- %%Arrtime - timpul de aterizare orarzboruri( Loc1, Loc2, ZborLisc), member( Deptime / Arrtime / Fnum / ZiList , ZborList), zborZi( Zi, ZiList). zborZi(Zi, ZiList) :- member( Zi, ZiList). zborZi( Zi, toatezilele) :- member( Zi, [luni,marti,miercuri,joi,vineri,sambata,duminica] ). deptime( [ L1 / L2 / Fnum / Dep | _], Dep). transfer( Hours1:Mins1, Hours2:Mins2) :- 60 * (Hours2 - Hours1) + Mins2 - Mins1 >= 40. member( X, [X | L] ). member( X, [Y | L] ) :- member( X, L). % BAZA DE DATE ZBOR (EVIDENTA TUTUROR ZBORURILOR) orarzboruri( london , edinburgh, [ 9:40 / 10:50 / ba4732 / toatezilele, 11:40 / 12:50 / ba4752 / toatezilele, 18:40 / 19:50 / ba4822 / [luni,marti,miercuri,joi,vineri] ] ). orarzboruri( london, bucuresti, [ 13:20 / 16:20 / jL212 / [luni,marti,miercuri,vineri,duminica], 16:30 / 19:30 / ba473 / [luni,miercuri,joi,sambata] ] ). orarzboruri( london, zurich, [ 9:10 / 11:45 / ba614 / toatezilele, 14:45 / 17:20 / sr805 / toatezilele ] ). orarzboruri( london, milano, [ 8:30 / 11:20 / ba510 / toatezilele, 11:00 / 13:50 / az459 / toatezilele ] ). orarzboruri( bucuresti, zurich, [ 11:30 / 12:40 / jL322 / [marti,joi] ] ). orarzboruri( bucuresti, london, [ 11:10 / 12:20 / jL212 / [luni,marti,miercuri,vineri,duminica], 20:30 / 21:30 / ba473 / [luni,miercuri,joi,sambata] ] ). orarzboruri( milano, london, [ 9:10 / 10:00 / az458 / toatezilele, 17:00 / 21:00 / cm2100 / toatezilele ] ). orarzboruri( milano, zurich, [ 9:25 / 10:15 / sr621 / toatezilele, 19:00 / 22:00 / st8801 / toatezilele ] ). orarzboruri( zurich, bucuresti, [ 13:30 / 14:40 / jL323 / [marti,joi] ] ). orarzboruri( zurich, london, [ 9:00 / 9:40 / ba613 / [luni,marti,miercuri,joi,vineri,sambata], 15:30 / 23:30 / cs73 / [luni,miercuri,joi,sambata] ] ). orarzboruri( zurich, milano, [ 7:55 / 8:45 / sr620 / toatezilele ] ). query3(City1,City2,City3,FN1,FN2,FN3,FN4) :- permutare( [milano,bucuresti,zurich],[City1,City2,City3]), zbor( london, City1, marti, FN1, DeL1, Arr1), zbor( City1, City2, miercuri, FN2, DeL2, Arr2), zbor( City2, City3, joi, FN3, DeL3, Arr3), zbor( City3, london, vineri, FN4, Dep4, Arr4). conc([], L, L). conc([X|L1],L2, [X|L3]) :- conc(L1,L2,L3). permutare( [], []). permutare( L, [X | P]) :- del( X, L, L1), permutare( Ll, P). del( X, [X|L], L). del( X, [Y|L], [Y|L1]). del( X, L, L1).