Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Spyder Editor
- This is a temporary script file.
- """
- from itertools import combinations
- import matplotlib.pyplot as plt
- import numpy as np
- import scipy.io
- import datetime
- import matplotlib.pyplot as plt
- # Get all combinations of [2, 1, 3]
- # and length 2
- #lista = [4, 2, 3, 1]
- fajl = scipy.io.loadmat('Greer_Ruhe_dataset.mat')
- br_zaht =15
- br_korisnika =5
- lista1 = fajl['Cost']
- lista = lista1[:br_korisnika,:br_zaht][0].tolist()
- vrijednost1 = fajl['Value']
- vrijednosti = vrijednost1[:br_korisnika, :br_zaht].tolist()
- print(lista)
- print(vrijednosti)
- #vrijednosti = [[4,7,3,5],[2,2,2,3],[3,1,4,7]]
- comb = []
- a = datetime.datetime.now()
- for i in range(1, len(lista) + 1):
- dodaj = combinations(lista, i)
- for subset in dodaj:
- comb.append(subset)
- zadovoljstvo = []
- for i in comb:
- # print(i)
- suma = 0
- # max = 0
- for num in i:
- for broj in range(len(vrijednosti)):
- suma += vrijednosti[broj][lista.index(num)]
- #print(suma)
- zadovoljstvo.append(suma)
- b = datetime.datetime.now()
- X = np.linspace(0, len(lista), len(zadovoljstvo))
- plt.plot(X,zadovoljstvo)
- #print (zadovoljstvo)
- c = b - a
- print(c.microseconds)
- #Print the obtained combinations
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement