From 6aee933c0b94198f1b2bbe911d421db676fbce83 Mon Sep 17 00:00:00 2001 From: Tomek Date: Mon, 8 Jun 2020 18:26:34 +0200 Subject: [PATCH] Przystosowanie algorytmu MCDA --- __pycache__/data.cpython-38.pyc | Bin 2169 -> 2979 bytes __pycache__/field.cpython-38.pyc | Bin 1638 -> 1638 bytes __pycache__/mcda.cpython-38.pyc | Bin 2384 -> 2766 bytes __pycache__/supply.cpython-38.pyc | Bin 1288 -> 2272 bytes data.py | 29 ++++++++++++-- main.py | 4 +- mcda.py | 44 ++++++++++++++------- supply.py | 63 ++++++++++++++++++++++++++++-- 8 files changed, 118 insertions(+), 22 deletions(-) diff --git a/__pycache__/data.cpython-38.pyc b/__pycache__/data.cpython-38.pyc index 82c5772992f19063e8d47b9422f8399405315a29..4a63ec5f6784fb3b1fcd5a522758c4c9f670d384 100644 GIT binary patch delta 932 zcmYk4PfXKL9LHC;ZVSQ~0fcxkB_;%up^1MJq5=a!7@JdsX+`wW_b9*h(c)_>SwphK zc=Wc52}ktc(Tt-f2}jQ)9K3j{-n{8We{U zkx?UHmct2cyidIA3A$Uk|3uO#sh{iN8@&7=GtYvW1)9N$>w*z6L9rS{}_LQvBkjDt~SdeQ~{k_i};MVSiOW_+{=#s=XQ1pNg;EFa6YGV{RG^2`^4>2YS7 zA^u>vK(uWMn7ifB0Elgoa9@VHXUHaSsM<`ckaf<&A9a-dGia#LW|<&@YGqNgjar!; zzOukSi=h&8J$~>(n*tlOA{tlA6VI{1@-rANIKm|&(53}B{KWh;O0x$|A(ssY(Frmq z*XQ`QCu-qE6!pZFJb3=V67orZe82F)I%ytWlEvxPb!wGLcutn37W_59iw)(@B8jFw yPz3C7*8*MLWWs=EHo2!L%Z>fiH6_>ho*F^hn;urGjj{C2Mmar6Fl$V!_0SHV#ACBA3$H4Fy#6bq~K#l_t7iTbT)QMsgN|%mePO(d|Z()dH zNpT2f&~)6qhUpWd;4Rkh)Rfem^y`ZYY`L!gw~yMqo`r>xEsE7QGbelUVb&$AMQlK0 vCReZ>+RVebn32(b@&+zbMy1KmxHNzyKerl(4N#tknL~E6BeyB@6BY#k1YRe% diff --git a/__pycache__/field.cpython-38.pyc b/__pycache__/field.cpython-38.pyc index 4413c808e154086f3e5fef156e8f5dd1f2486723..4a8c22ce0bb50b9b81699f6e85c59bc318e68ae5 100644 GIT binary patch delta 47 zcmaFH^Nfc#l$V!_0SFv^-i;I4$m_(+sJc0Tc{U@X#^g6Fn;4BI&u6V+l$$KW<^=#c CD-9q3 delta 47 zcmaFH^Nfc#l$V!_0SHV#AC42+$m_(+sJ1zPc{U@X=Hxdln;4BJ&u6V+l%Fia<^=#W CtPJ-6 diff --git a/__pycache__/mcda.cpython-38.pyc b/__pycache__/mcda.cpython-38.pyc index 79e10a93b034ae505ce236949eb877dffbb5834c..5b843ed737f9dd1e5da3d7352ff5195e8d0f8e12 100644 GIT binary patch literal 2766 zcma)8&2Jk;6rb6hU9X+QHEl|gex)C2=#~NnDm9cqKT?&7Lxj{1RaO9Pb{5CU+FsAD zn+B~>#-`Amb9gi4yr2)(vwA5k`ue7s)cq^PMMkV zu2Z$qv#{dGu3Z(fBH#LfRULU$9+T7Z_^vJAMsLRSX5}1glI|FOMbkU6E2^$MDNkWn zL7tXp(0X!So<&=f=j3^`C3!(Epq-ExA25HhkGnFTYks+3L9b6w>`#&?kSLSDV_BbG z*Y`*qf$&S(S&xHoON&}7mfB4^Dv2W~RcpJc#d_SqV0)vUMcP&o7PM5*tVP=0iQ>4m zt=+U9KaEuX7+EZmMMoD^6lPcjJ0c<5Zrbhy3Klj4rR}Iz^KI>#=aNpM`h`_>8g}{) zggQe)keDakG=y(yk=DP*r5iz-5|&SXW9lMiUR_?fvGyp9RJwLIz-ybWaAWOmlx}6M zWbG@}+KjfcwMHm|_mdr6BpZ(d07r17EQk{ngX~(copH48?T|+15Im@jXw#8LN za^OZ|+l;T~cFt#kqHOmZM7VxrHm5;s3T$5n%Mb)a^M!lonrHLyfXks81(bMHx zl&!RyVN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8OuW*g~AO?V{?UVgvw@Q3cxOq;B`5z>64q_@-E z(AgkQ(k{KUs|R^E8>eZ!zn1RXcF*WA*Uwd$htE$fWhf@uI|3m+XGXT<7tkDYm)7%H z-K0t>(5kxmgdTEnNR^YSr=;fOR51^wk^^BjbLYsVtaXo_1GkVzUf~{7bsacnhI&4F zQWOq7iNakJ=)IUJP`bTMgG@8D>7raG=meD`){XVZ29#bZ8QKQ!(I~fmFBy+=vkakU zR_JEs6H1+GzqUNcs$D(-obep>$0I_xKPXGV_ delta 202 zcmaDL*uljY%FD~e00hT{kHl$kP2`jDk^u5j7*ZH>7;+h-7#SH-m{OQq7^0X`Sb`Ze zSzm$_Yck$q4=Bn{DNQa(2JvBl3CLgtVrL*OUcof6RdHiqD-&A{15l^JWJlJWlSA3G z7?mbBu(`9bfYg*sKFe0-$W){P7!3qdFYxwklMa)B1-q}nk8 KdBq^LJj?)8tR+VP diff --git a/data.py b/data.py index b8e059f..e714882 100644 --- a/data.py +++ b/data.py @@ -32,7 +32,7 @@ learning_data = [ # kolor, kształt, waga, rozmiar, nazwa ['black', 'rectangle', 51, 'small', 'Mars'], ['gold', 'pack', 100, 'big', 'Haribo'], - ['purple', 'rectangle', 100, 'big', 'Milka'], + ['purple', 'rectangle', 100, 'big', 'Milka-czekolada'], ['brown', 'pack', 45, 'small', 'M&M'], ['blue', 'rectangle', 50, 'medium', 'Bounty'], ['blue', 'square', 40, 'small', 'Knoppers'], @@ -40,10 +40,10 @@ learning_data = [ ['gold', 'rectangle', 40, 'medium', 'Twix'], ['gold', 'rectangle', 50, 'medium', 'Prince-polo'], ['brown', 'rectangle', 55, 'medium', 'Snickers'], - ['brown', 'rectangle', 45, 'medium', 'Lion'], + ['brown', 'rectangle', 45, 'medium', 'Lion'], ['white', 'rectangle', 40, 'medium', 'Kinder-bueno'], ['red', 'rectangle', 50, 'medium', 'Kit-kat'], - ['blue', 'rectangle', 115, 'big', 'Wedel'], + ['blue', 'rectangle', 115, 'big', 'Wedel-czekolada'], ['white', 'rectangle', 15, 'small', 'Krowka'], ['red', 'pack', 70, 'medium', 'Skittles'], ['orange', 'rectangle', 45, 'medium', 'Reeses'], @@ -57,6 +57,29 @@ learning_data = [ ['red', 'jar', 250, 'medium', 'Strawberry Jam'], ['black', 'jar', 250, 'medium', 'Blackberry Jam'], ['orange', 'jar', 250, 'medium', 'Peach Jam'], + ['brown', 'rectangle', 140, 'big', 'Jezyki classic'], + ['blue', 'rectangle', 140, 'big', 'Jezyki kokos'], + ['white', 'rectangle', 100, 'big', 'Kinder Chocolate'], + ['yellow', 'rectangle', 300, 'big', 'belVita'], + ['blue', 'rectangle', 380, 'big', 'Wedel-Ptasie Mleczko'], + ['purple', 'rectangle', 330, 'big', 'Milka-Alpejskie Mleczko'], + ['blue', 'rectangle', 294, 'big', 'Delicje'], + ['silver', 'pack', 280, 'big', 'Wawel-Michalki'], + ['red', 'rectangle', 50, 'medium', 'Krakuski Petit Beurre'], + ['white', 'egg', 20, 'small', 'Kinder Niespodzianka'], + ['brown', 'rectangle', 180, 'big', 'Familijne Wafle'], + ['red', 'rectangle', 235, 'big', 'dr Gerard PryncyPałki'], + ['white', 'rectangle', 25, 'medium', 'Nestlé Cini Minis Batonik'], + ['black', 'pack', 70, 'big', 'Korsarz Draże'], + ['white', 'rectangle', 50, 'medium', 'Góralki'], + ['white', 'rectangle', 24, 'medium', 'Kinder Country'], + ['red', 'rectangle', 46, 'medium', '3Bit'], + ['yellow', 'rectangle', 25, 'medium', 'Nestlé Nesquik Batonik'], + ['yellow', 'rectangle', 47, 'medium', 'Wedel WW'], + ['brown', 'rectangle', 30, 'medium', 'Lubisie'], + ['purple', 'rectangle', 22, 'small', 'Maoam'], + ['brown', 'rectangle', 294, 'medium', 'Grześki'], + ['white', 'rectangle', 250, 'big', 'merci'], ] diff --git a/main.py b/main.py index cb61a47..1df67b0 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from agent import Agent from settings import Settings from board import create_board, draw_board from random import randint, choice -from mcda import choseProducts +from mcda import selectedSupply # Inicjalizacja programu i utworzenie obiektu ekrany def run(): @@ -21,7 +21,7 @@ def run(): board = create_board(screen) my_tree = decision_tree.build_tree(data.learning_data) - produsctsFromSupply = choseProducts(5) + produsctsFromSupply = selectedSupply() # for row in board: # for field in row: diff --git a/mcda.py b/mcda.py index 68dd463..e8c17f2 100644 --- a/mcda.py +++ b/mcda.py @@ -1,9 +1,9 @@ from supply import * -allProducts = create_data_products() +allProducts = supply() -color = {'black': 16, 'gold': 10, 'purple': 5, 'brown': 7, 'blue': 12, 'white': 14, 'red': 13, 'orange': 11} -shape = {'rectangle': 15, 'pack': 19, 'square': 9, 'jar': 7} +color = {'black': 16, 'gold': 10, 'purple': 12, 'brown': 7, 'blue': 12, 'white': 14, 'red': 13, 'orange': 11, 'yellow': 8, 'silver': 15} +shape = {'rectangle': 15, 'pack': 19, 'square': 9, 'jar': 7, 'egg': 12} size = {'small': 7, 'medium': 16, 'big': 13} def sizeValue(X): @@ -68,12 +68,11 @@ def getConcordanceAllProducts(): C.append(c) return C -def choseProducts(number): +def choseProducts(): + number = 20 C = getConcordanceAllProducts() products = [] prev = -1 - if number > len(allProducts): - return allProducts while number > 0: max = -1 if prev == -1: @@ -89,11 +88,28 @@ def choseProducts(number): max = j prev = max for j in range(len(allProducts)): - if C[max] == C[j]: - products.append(allProducts[j]) - print(C[j]) - number -= 1 - if number == 0: - break - print(C) - return products \ No newline at end of file + if C[max] > 0.8: + if C[max] == C[j]: + products.append(allProducts[j]) + print(C[j]) + number -= 1 + if number == 0: + break + else: + number = 0 + return products + +def selectedSupply(): + products = choseProducts() + supply = [] + product = ['-', '-', 0, '-', '-'] + for i in range(len(products)): + product[0] = products[i].color + product[1] = products[i].shape + product[2] = products[i].mass + product[3] = products[i].size + supply.append(product) + product = ['-', '-', 0, '-', '-'] + supply.append(product) + print(supply) + return supply \ No newline at end of file diff --git a/supply.py b/supply.py index 673b31a..a574768 100644 --- a/supply.py +++ b/supply.py @@ -1,11 +1,10 @@ from product import Product +import random def create_data_products(): allProducts = [] - product = Product('black', 'rectangle', 51, 'small') - allProducts.append(product) product = Product('black', 'rectangle', 51, 'small') allProducts.append(product) product = Product('gold', 'pack', 100, 'big') @@ -60,5 +59,63 @@ def create_data_products(): allProducts.append(product) product = Product('orange', 'jar', 250, 'medium') allProducts.append(product) + product = Product('brown', 'rectangle', 140, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 140, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 100, 'big') + allProducts.append(product) + product = Product('yellow', 'rectangle', 300, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 380, 'big') + allProducts.append(product) + product = Product('purple', 'rectangle', 330, 'big') + allProducts.append(product) + product = Product('blue', 'rectangle', 294, 'big') + allProducts.append(product) + product = Product('silver', 'pack', 280, 'big') + allProducts.append(product) + product = Product('red', 'rectangle', 50, 'medium') + allProducts.append(product) + product = Product('white', 'egg', 20, 'small') + allProducts.append(product) + product = Product('brown', 'rectangle', 180, 'big') + allProducts.append(product) + product = Product('red', 'rectangle', 235, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 25, 'medium') + allProducts.append(product) + product = Product('black', 'pack', 70, 'big') + allProducts.append(product) + product = Product('white', 'rectangle', 50, 'medium') + allProducts.append(product) + product = Product('white', 'rectangle', 24, 'medium') + allProducts.append(product) + product = Product('red', 'rectangle', 46, 'medium') + allProducts.append(product) + product = Product('yellow', 'rectangle', 25, 'medium') + allProducts.append(product) + product = Product('yellow', 'rectangle', 47, 'medium') + allProducts.append(product) + product = Product('brown', 'rectangle', 30, 'medium') + allProducts.append(product) + product = Product('purple', 'rectangle', 22, 'small') + allProducts.append(product) + product = Product('brown', 'rectangle', 294, 'medium') + allProducts.append(product) + product = Product('white', 'rectangle', 250, 'big') + allProducts.append(product) + + return allProducts + +def supply(): + allProducts = create_data_products() + R = [] + supply = [] + while len(R)<20: + rand = random.randint(0, 49) + if R.count(rand) == 0: + R.append(rand) + supply.append(allProducts[rand]) + return supply - return allProducts \ No newline at end of file