pour changer de pc

poc
ludovic.castglia 4 months ago
parent dfde73f85e
commit 1e6cdd87c2

@ -29,6 +29,8 @@ class Nnnar:
selected = [] selected = []
subSpaceIdxList = getSpaceIdxAround(idx, nbAround, self) subSpaceIdxList = getSpaceIdxAround(idx, nbAround, self)
for subSpaceIdx in subSpaceIdxList: for subSpaceIdx in subSpaceIdxList:
print(subSpaceIdx)
print(self.space[subSpaceIdx])
selected += selectPointsInRange(self.space[subSpaceIdx],coord,nbAround*self.unit) selected += selectPointsInRange(self.space[subSpaceIdx],coord,nbAround*self.unit)
nbAround += 1 nbAround += 1
found = [] found = []
@ -75,4 +77,5 @@ class Point:
n = Nnnar(2, 0, 3, 2) n = Nnnar(2, 0, 3, 2)
n.addPoint(np.array([1, 0.8]), 1) n.addPoint(np.array([1, 0.8]), 1)
print(n.space[0][0][0].coord)
print(n.getNNearest(np.array([1,0.8]),1))

@ -1,8 +1,12 @@
from spaceAround import *
def getSpaceIdxAround(center, nbAround, space): def getSpaceIdxAround(center, nbAround, space):
if (nbAround < len(space.calculatedSpaceAroundIdx)): if (nbAround < len(space.calculatedSpaceAroundIdx)):
return space.calculatedSpaceAroundIdx[nbAround] spaceAround = space.calculatedSpaceAroundIdx[nbAround]
# TODO: implement l'algo pour trouver les indices subSapce à nbAround autour du centre else:
spaceAround = findCoordAround(center,nbAround)
space.calculatedSpaceAroundIdx.append(spaceAround)
return applySapceAroundToCase(center,spaceAround,space)
def selectPointsInRange(points, coord, distance): def selectPointsInRange(points, coord, distance):
found = [] found = []

@ -0,0 +1,80 @@
from sympy.utilities.iterables import multiset_permutations
def findCoordAround(center, nbAround):
find = []
for i in range(len(center)):
find = getNCoordDiff(center,find,i,nbAround)
return find
def getNCoordDiff(center,find,nbDiffValue, nbAround):
coord = []
if (-nbAround+nbAround >= nbDiffValue):
return find
for i in range(nbDiffValue):
coord.append(-nbAround+i)
while True:
modified = False
cursor = len(coord)-1
while(not modified):
if (cursor<0):
return find
if (coord[cursor]+len(coord)-1-cursor<nbAround):
modified = True
coord[cursor] += 1
val = coord[cursor] +1
cursor += 1
while(cursor<len(coord)):
coord[cursor] = val
cursor +=1
val += 1
else:
cursor -= 1
find = getCompletVariationOfCoord(center,find,coord)
return find
def getCompletVariationOfCoord(center,find,partialCoord):
coord = []
for i in range(len(partialCoord)):
coord.append(partialCoord[i])
while len(coord) != len(center):
coord.append(partialCoord[0])
find = getPermutationOfCoord(center,find,coord)
while True:
cursor = len(coord)-1
modified = False
while not modified:
if (cursor == len(partialCoord)-1):
return find
if (coord[cursor]!=partialCoord[len(partialCoord)-1]):
modified = True
afterCursor = 0
while afterCursor<len(partialCoord) and coord[cursor] != partialCoord[afterCursor]:
afterCursor +=1
afterCursor += 1
while(cursor<len(coord)):
coord[cursor] = partialCoord[afterCursor]
cursor += 1
else:
cursor -= 1
find = getPermutationOfCoord(center,find,coord)
return find
def getPermutationOfCoord(center,find,coord):
find.append(coord)
for perm in multiset_permutations(coord):
find.append(perm)
return find
def applySapceAroundToCase(center,spaceAround,space):
reelSpaceAround = []
for y in range(len(spaceAround)):
estBon = True
for i in range(len(spaceAround[y])):
if not estBon:
continue
spaceAround[y][i] += center[i]
estBon = estBon and space.minCoord < spaceAround[y][i] < space.maxCoord
if estBon:
reelSpaceAround.append(spaceAround[y])
print(reelSpaceAround)
return reelSpaceAround
Loading…
Cancel
Save