From d25c4213de7616669146eedb8ec53b1d3de13131 Mon Sep 17 00:00:00 2001 From: tomasz Date: Sun, 17 May 2020 15:23:06 +0200 Subject: [PATCH] generowanie populacji, gen jako koszt obiekt z kosztem przejazdu --- .idea/workspace.xml | 344 ++++++++++-------- AStar.py | 15 +- Mapa/__pycache__/generate.cpython-37.pyc | Bin 3030 -> 3030 bytes Mapa/generate.py | 1 + __pycache__/AStar.cpython-37.pyc | Bin 2510 -> 2637 bytes __pycache__/program.cpython-37.pyc | Bin 4496 -> 4760 bytes genetyczny/Data.py | 12 +- genetyczny/Gene.py | 8 + genetyczny/__pycache__/Data.cpython-37.pyc | Bin 402 -> 655 bytes genetyczny/__pycache__/funkcje.cpython-37.pyc | Bin 0 -> 2102 bytes .../__pycache__/randomBox.cpython-37.pyc | Bin 683 -> 0 bytes genetyczny/funkcje.py | 86 +++++ genetyczny/randomBox.py | 26 -- program.py | 26 +- 14 files changed, 340 insertions(+), 178 deletions(-) create mode 100644 genetyczny/Gene.py create mode 100644 genetyczny/__pycache__/funkcje.cpython-37.pyc delete mode 100644 genetyczny/__pycache__/randomBox.cpython-37.pyc create mode 100644 genetyczny/funkcje.py delete mode 100644 genetyczny/randomBox.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6d0694e..d69a6f3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,12 @@ - + - - + + + + - + - - + + @@ -31,14 +33,20 @@ - - + + - - - - - + + + + + + + + + + + @@ -46,8 +54,8 @@ - - + + @@ -58,8 +66,8 @@ - - + + @@ -68,19 +76,13 @@ - + - - - - - - - - - - - + + + + + @@ -88,8 +90,17 @@ - - + + + + + + + + + + + @@ -105,7 +116,6 @@ - whereDecisio toVisit dra neuro @@ -120,15 +130,29 @@ regalsik # put - random randomB + search + sear + rando + chi + genera + return + occupied + astarstate + grid + whereDecision + genMa + random + mapfor + tmp + global @@ -143,21 +167,24 @@ - @@ -320,13 +347,16 @@ + - + + @@ -353,19 +383,19 @@ - - - + + + - - - - - - - + + + + + + + - + @@ -374,19 +404,19 @@ - - - + + + - - - - - - - + + + + + + + - + @@ -399,9 +429,9 @@ - file://$PROJECT_DIR$/AStar.py - 17 - @@ -417,6 +447,10 @@ + + + + @@ -469,33 +503,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -512,37 +519,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -550,48 +526,128 @@ - - - - + - - - - - + + - + - - - - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AStar.py b/AStar.py index 169af59..d0ecf9c 100644 --- a/AStar.py +++ b/AStar.py @@ -2,7 +2,7 @@ import numpy from AStarState import AStarState class AStar: - def returnPath(self, currentNode, grid, flaga): + def returnPath(self, currentNode, grid): path = [] noRows, noColumns = numpy.shape(grid) result = [[-1 for i in range(noColumns)] for j in range(noRows)] @@ -41,10 +41,14 @@ class AStar: if item.gmax and flaga == 0: #podprojekt genetyczne + return current.g if iterations>max: return self.returnPath(current, grid) visited.append(current) toVisit.pop(currentIndeks) + if current==endNode and flaga == 0: + return current.g if current==endNode: return self.returnPath(current, grid) #zwracanie wagi przejscia children = [] @@ -56,6 +60,11 @@ class AStar: positions[1] > (noColumns - 1) or positions[1] < 0): continue + """ podprojekt genetyczne""" + if grid[positions[0]][positions[1]] == 2 and flaga == 0: + children.append(AStarState(current, positions)) + continue + if grid[positions[0]][positions[1]]!=0: continue @@ -76,3 +85,7 @@ class AStar: continue toVisit.append(child) + + + + diff --git a/Mapa/__pycache__/generate.cpython-37.pyc b/Mapa/__pycache__/generate.cpython-37.pyc index 8d190dcbc6cc0dec32a870a983b971f3f40cfbbb..685a68a50e8f5405967b6305f191b53dff82a115 100644 GIT binary patch delta 28 icmca6eodU$iIZfE39hm`GQ)lm(=0ws0|5E{ue! zu-G4P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-4,5 +4,15 @@ class Data: def __init__(self): - self.zajeteRegaly = [] + self.zajeteRegaly = [] #krotka (x,y) + self.mapa = [] + self.unbox = [] + self.astarMap = [] + + def genMap(self, mapa): + tmpMap =[] + tmpMap = mapa.copy() + for regal in self.zajeteRegaly: + tmpMap[regal[0]][regal[1]] = 2 + return tmpMap diff --git a/genetyczny/Gene.py b/genetyczny/Gene.py new file mode 100644 index 0000000..075688e --- /dev/null +++ b/genetyczny/Gene.py @@ -0,0 +1,8 @@ + + +class Gene: + def __init__(self, poczatkowa, koncowa, name): + self.poczatkowa = poczatkowa + self.koncowa = koncowa + self.koszt = 0 + self.name = name diff --git a/genetyczny/__pycache__/Data.cpython-37.pyc b/genetyczny/__pycache__/Data.cpython-37.pyc index 571bb4142b8d570857f580e44643c15d82cf3b21..f2082c6d152947563e0d33ee03942a32a864f9b4 100644 GIT binary patch literal 655 zcmYjO!EV$r5FI;C8p^JaP!C;+6SrK7ggBuJ6}nQ@1ACxCNKwEtv02*9W>Y(>Hc@(_ z9|A}IqTk^wr~L&^%y?DQiRR5@#^aecem5TP0?Nx5cVE6UfIsweFA+LNsO~Ak324yl z7WD_uLGv@nq7vi(g`;YgDO$eD(mYo_@vVvw;th<`b9z+GqlYaJlyh z23o6_ZRo-cDr{&s8TX=GHJzn!CM?Zk>2dO;T{g(n$CefmXl{X~^$C)~>==C)UYQA& zvJu;7{o_Djo1bMdajn(TNa=T_T(0!GB7Y?1}?g#bLhmaNFrksKYY&2P;U22><{9 delta 247 zcmeBYoy5%N#LLUY00d4KcgF=VOyqM*76I~78KM|d7^0X`7*m*97^0X{n1dNKS#Gho zB$gy5GlJ9u0f=S-VrL*O1{sphP{R<DTs$?xxuE)tb>$NxI zS+cvbpBC}JuSg&H8A$w!dF82pfhW!#w`o;`S2OpHcfRhq=N{i*Uk@3czqbDT`S*aa zziIILap2rVt28>vB+uD|N1T)IHd$)&AD!d#nPZ#4n9uFU+)mWF);k|E%M?gX^l4Y?N9?pt!a-8l? z7i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