Guest User

Untitled

a guest
Jan 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. :- use_module(library(lists)).
  2. :- use_module(library(clpfd)).
  3.  
  4. %% P13 - Prova modelo algures no grupo do fb
  5. % attend(+, -, -)
  6. attend(FilmList, Goings, Worth) :-
  7. length(FilmList, N),
  8. length(Goings, N),
  9. domain(Goings, 0, 1),
  10.  
  11. length(Tasks, N),
  12. generateTasks(FilmList, Goings, Tasks),
  13. Machines = [machine(1, 1), machine(0, 1000)],
  14. cumulatives(Tasks, Machines, [bound(upper)]),
  15.  
  16. getWorthsList(FilmList, WorthsList),
  17. scalar_product(WorthsList, Goings, #=, Worth),
  18.  
  19. append(Goings, [Worth], Vars),
  20.  
  21. labeling([maximize(Worth)], Vars).
  22.  
  23. generateTasks([], [], []).
  24. generateTasks([(S,D,_) | Films], [G | Goings], [task(S, D, _, G, 1) | Tasks]) :-
  25. generateTasks(Films, Goings, Tasks).
  26.  
  27. getWorthsList([], []).
  28. getWorthsList([(_,_,Worth) | Films], [Worth | WorthsList]) :-
  29. getWorthsList(Films, WorthsList).
  30.  
  31. % attend([(1,3,2), (1,4,4), (4,4,3)], Goings, Worth).
  32. % attend([(1,3,2), (1,4,4), (4,4,1)], Goings, Worth).
  33. % attend([(1,3,3), (1,4,4), (3,5,5), (4,1,1), (4,4,3), (5,4,3), (6,3,1), (8,3,3)], Goings, Worth).
Add Comment
Please, Sign In to add comment