Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor
  4.  
  5. This is a temporary script file.
  6. """
  7.  
  8. from itertools import combinations
  9. import matplotlib.pyplot as plt
  10. import numpy as np
  11. import scipy.io
  12. import datetime
  13.  
  14. import matplotlib.pyplot as plt
  15. # Get all combinations of [2, 1, 3]
  16. # and length 2
  17. #lista = [4, 2, 3, 1]
  18. fajl = scipy.io.loadmat('Greer_Ruhe_dataset.mat')
  19.  
  20. br_zaht =15
  21. br_korisnika =5
  22. lista1 = fajl['Cost']
  23. lista = lista1[:br_korisnika,:br_zaht][0].tolist()
  24.  
  25. vrijednost1 = fajl['Value']
  26. vrijednosti = vrijednost1[:br_korisnika, :br_zaht].tolist()
  27.  
  28. print(lista)
  29. print(vrijednosti)
  30. #vrijednosti = [[4,7,3,5],[2,2,2,3],[3,1,4,7]]
  31. comb = []
  32. a = datetime.datetime.now()
  33. for i in range(1, len(lista) + 1):
  34. dodaj = combinations(lista, i)
  35. for subset in dodaj:
  36. comb.append(subset)
  37. zadovoljstvo = []
  38. for i in comb:
  39. # print(i)
  40. suma = 0
  41. # max = 0
  42. for num in i:
  43. for broj in range(len(vrijednosti)):
  44. suma += vrijednosti[broj][lista.index(num)]
  45.  
  46. #print(suma)
  47. zadovoljstvo.append(suma)
  48. b = datetime.datetime.now()
  49.  
  50. X = np.linspace(0, len(lista), len(zadovoljstvo))
  51. plt.plot(X,zadovoljstvo)
  52. #print (zadovoljstvo)
  53. c = b - a
  54. print(c.microseconds)
  55. #Print the obtained combinations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement