forked from s444420/AL-2020
Dodanie podprojektu
This commit is contained in:
parent
7777b4cc6b
commit
734505ab3d
@ -3,5 +3,5 @@
|
|||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="ES6" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (AL-2020)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (Projekt)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -4,7 +4,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.7 (AL-2020)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.8 (Projekt)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TestRunnerService">
|
<component name="TestRunnerService">
|
||||||
|
BIN
__pycache__/agent.cpython-38.pyc
Normal file
BIN
__pycache__/agent.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/board.cpython-38.pyc
Normal file
BIN
__pycache__/board.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/data.cpython-38.pyc
Normal file
BIN
__pycache__/data.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/decision_tree.cpython-38.pyc
Normal file
BIN
__pycache__/decision_tree.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/field.cpython-38.pyc
Normal file
BIN
__pycache__/field.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/functions.cpython-38.pyc
Normal file
BIN
__pycache__/functions.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/mcda.cpython-38.pyc
Normal file
BIN
__pycache__/mcda.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/product.cpython-38.pyc
Normal file
BIN
__pycache__/product.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/settings.cpython-38.pyc
Normal file
BIN
__pycache__/settings.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/shelf.cpython-38.pyc
Normal file
BIN
__pycache__/shelf.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/supply.cpython-38.pyc
Normal file
BIN
__pycache__/supply.cpython-38.pyc
Normal file
Binary file not shown.
BIN
__pycache__/sweets.cpython-38.pyc
Normal file
BIN
__pycache__/sweets.cpython-38.pyc
Normal file
Binary file not shown.
4
main.py
4
main.py
@ -9,7 +9,7 @@ from agent import Agent
|
|||||||
from settings import Settings
|
from settings import Settings
|
||||||
from board import create_board, draw_board
|
from board import create_board, draw_board
|
||||||
from random import randint, choice
|
from random import randint, choice
|
||||||
|
from mcda import choseProducts
|
||||||
|
|
||||||
# Inicjalizacja programu i utworzenie obiektu ekrany
|
# Inicjalizacja programu i utworzenie obiektu ekrany
|
||||||
def run():
|
def run():
|
||||||
@ -21,6 +21,8 @@ def run():
|
|||||||
board = create_board(screen)
|
board = create_board(screen)
|
||||||
my_tree = decision_tree.build_tree(data.learning_data)
|
my_tree = decision_tree.build_tree(data.learning_data)
|
||||||
|
|
||||||
|
produsctsFromSupply = choseProducts(5)
|
||||||
|
|
||||||
# for row in board:
|
# for row in board:
|
||||||
# for field in row:
|
# for field in row:
|
||||||
# print(field.cost_of_travel)
|
# print(field.cost_of_travel)
|
||||||
|
100
mcda.py
Normal file
100
mcda.py
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
from supply import *
|
||||||
|
|
||||||
|
allProducts = create_data_products()
|
||||||
|
|
||||||
|
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}
|
||||||
|
size = {'small': 7, 'medium': 16, 'big': 13}
|
||||||
|
|
||||||
|
def sizeValue(X):
|
||||||
|
if X.size == 'small':
|
||||||
|
return X.mass/5
|
||||||
|
if X.size == 'medium':
|
||||||
|
return X.mass/10
|
||||||
|
if X.size == 'big':
|
||||||
|
return X.mass/20
|
||||||
|
parameters = {
|
||||||
|
'color': {'weights': 3, 'q': 1, 'p': 5},
|
||||||
|
'shape': {'weights': 4, 'q': 1, 'p': 6},
|
||||||
|
'mass': {'weights': 0.5, 'q': 2, 'p': 10},
|
||||||
|
'size': {'weights': 1, 'q': 1, 'p': 8}
|
||||||
|
|
||||||
|
}
|
||||||
|
def getConcordance(gA, gB, q, p):
|
||||||
|
if gB <= gA + q:
|
||||||
|
return 1
|
||||||
|
if gB <= gA + p:
|
||||||
|
return (p - gB + gA) / (p - q)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def getAllTypeConcordance(A, B):
|
||||||
|
concordance = 0.0
|
||||||
|
weight_sum = 0
|
||||||
|
|
||||||
|
parameter = parameters['color']
|
||||||
|
w, q, p = parameter['weights'], parameter['q'], parameter['p']
|
||||||
|
concordance += getConcordance(color[A.color], color[B.color], q, p) * w
|
||||||
|
weight_sum += w
|
||||||
|
|
||||||
|
parameter = parameters['shape']
|
||||||
|
w, q, p = parameter['weights'], parameter['q'], parameter['p']
|
||||||
|
concordance += getConcordance(shape[A.shape], shape[B.shape], q, p) * w
|
||||||
|
weight_sum += w
|
||||||
|
|
||||||
|
parameter = parameters['mass']
|
||||||
|
w, q, p = parameter['weights'], parameter['q'], parameter['p']
|
||||||
|
concordance += getConcordance(sizeValue(A), sizeValue(B), q, p) * w
|
||||||
|
weight_sum += w
|
||||||
|
|
||||||
|
parameter = parameters['size']
|
||||||
|
w, q, p = parameter['weights'], parameter['q'], parameter['p']
|
||||||
|
concordance += getConcordance(size[A.size], size[B.size], q, p) * w
|
||||||
|
weight_sum += w
|
||||||
|
|
||||||
|
concordance /= weight_sum
|
||||||
|
return concordance
|
||||||
|
|
||||||
|
def getConcordanceAllProducts():
|
||||||
|
|
||||||
|
C = []
|
||||||
|
|
||||||
|
for i in range(len(allProducts)):
|
||||||
|
c = 0
|
||||||
|
for j in range(len(allProducts)):
|
||||||
|
if j==i:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
c += getAllTypeConcordance(allProducts[i], allProducts[j])
|
||||||
|
c /= len(allProducts)-1
|
||||||
|
C.append(c)
|
||||||
|
return C
|
||||||
|
|
||||||
|
def choseProducts(number):
|
||||||
|
C = getConcordanceAllProducts()
|
||||||
|
products = []
|
||||||
|
prev = -1
|
||||||
|
if number > len(allProducts):
|
||||||
|
return allProducts
|
||||||
|
while number > 0:
|
||||||
|
max = -1
|
||||||
|
if prev == -1:
|
||||||
|
max = 0
|
||||||
|
for j in range(len(allProducts)):
|
||||||
|
if prev == -1:
|
||||||
|
if C[max]<C[j]:
|
||||||
|
max = j
|
||||||
|
elif max == -1:
|
||||||
|
if C[prev]>C[j]:
|
||||||
|
max = j
|
||||||
|
elif C[max] < C[j] and C[j] < C[prev]:
|
||||||
|
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
|
7
product.py
Normal file
7
product.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class Product:
|
||||||
|
|
||||||
|
def __init__(self, color, shape, mass, size):
|
||||||
|
self.color = color
|
||||||
|
self.shape = shape
|
||||||
|
self.mass = mass
|
||||||
|
self.size = size
|
64
supply.py
Normal file
64
supply.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
from product import Product
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('purple', 'rectangle', 100, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('brown', 'pack', 45, 'small')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('blue', 'rectangle', 50, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('blue', 'square', 40, 'small')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('blue', 'rectangle', 35, 'small')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('gold', 'rectangle', 40, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('gold', 'rectangle', 50, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('brown', 'rectangle', 55, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('brown', 'rectangle', 45, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('white', 'rectangle', 40, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('red', 'rectangle', 50, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('blue', 'rectangle', 115, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('white', 'rectangle', 15, 'small')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('red', 'pack', 70, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('orange', 'rectangle', 45, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('blue', 'rectangle', 55, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('gold', 'rectangle', 120, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('white', 'rectangle', 120, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('white', 'jar', 600, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('white', 'rectangle', 25, 'small')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('brown', 'jar', 500, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('brown', 'jar', 470, 'big')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('red', 'jar', 250, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('black', 'jar', 250, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
product = Product('orange', 'jar', 250, 'medium')
|
||||||
|
allProducts.append(product)
|
||||||
|
|
||||||
|
return allProducts
|
Loading…
Reference in New Issue
Block a user