updating for individual projecet

This commit is contained in:
Kamila Bobkowska 2020-05-02 15:23:05 +00:00
parent d98a738d48
commit 3c058cf50e

24
Main.py
View File

@ -6,7 +6,8 @@ import collections
import alg
from models.dumpster import trash
from models.Garbagetruck import GarbageTruck
import numbering
from sklearn.datasets import load_digits
#heuristics for finding the closest dumpster
def closest(GT, D):
@ -96,6 +97,16 @@ a = createDumpstersAndDump(20,size+1)
TheDump = np.reshape(a[-1], (1, 2))
a = np.reshape(a[:-1], (size, 2))
#Patryk Krawiec subproject part
digitsy=np.load("Ytest.npy")
digitsx=np.load("Xtest.npy")
images_and_labels=list(zip(digitsx,digitsy))
num,xnum,ynum=numbering.num(20,images_and_labels)
paying_customers=num[3:]
paying_customers = list(map(int, paying_customers))
#initiating the coordinates for the garbage truck
GT = GarbageTruck()
coor = GT.start()
@ -109,6 +120,8 @@ for i in range(0,size):
s.throwAway()
s.colour()
s.xy = a[i]
s.numberx=xnum[i]
s.numbery=ynum[i]
dumpsters.append(s)
#colouring trashcans
@ -158,14 +171,19 @@ while not done:
#recognize which dumpster are we visiting
Xz=np.where(all==x)[0]
x =[item for item, count in collections.Counter(Xz).items() if count > 1]
if GT.collectingTrash(dumpsters, x[0]):
predicted=numbering.pred(dumpsters[x[0]].numberx,dumpsters[x[0]].numbery)
if(predicted not in paying_customers):
print("House number is: ",predicted," but it is not our customer")
elif GT.collectingTrash(dumpsters, x[0]):
dumpsters[x[0]].empty()
print("House number is: ",predicted)
elif GT.amIFull():
print("DUMPSTER TRUCK FULL")
else:
print("No more space for this kind of trash")
# remove visited dumpster
a = a[~((a[:,0] ==ZZ[0]) & (a[:,1] ==ZZ[1]))]
print("Dumpsters left: ",len(a))