-
Notifications
You must be signed in to change notification settings - Fork 3
/
PhysicsMemory.py
52 lines (35 loc) · 1.58 KB
/
PhysicsMemory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from Memory import Memory
from PrimitivesPhysics import PrimitivesPhysics
from AttributePool import AttributePool
from enum import Enum
class PhysicsMemoryMode(Enum):
PhiR = 0
PhiO = 1
class PhysicsMemory:
def __init__(self):
self._syntheticPhysics : PrimitivesPhysics = None
self._generatorMode : PhysicsMemoryMode = PhysicsMemoryMode.PhiR
def setSyntheticPhysics(self, primitivesPhysics : PrimitivesPhysics, attributePool : AttributePool):
self._syntheticPhysics = primitivesPhysics(attributePool)
def setMode(self, mode : PhysicsMemoryMode):
self._generatorMode = mode
def nextBatch(self, batchSize : int, inputMap : dict, outputMap : dict):
# inputMap : dict # Object - List of Indices -> Ignored for Physics
# outputMap : dict # Object - List of Indices -> Ignored for Physics
yData = [[]] * batchSize
xData = [[]] * batchSize
if self._generatorMode == PhysicsMemoryMode.PhiR:
if self._syntheticPhysics is not None:
for i in range(batchSize):
xVal, yVal = self._syntheticPhysics.generateRelation()
xData[i] = xVal
yData[i] = yVal
#else:
else:
if self._syntheticPhysics is not None:
for i in range(batchSize):
xVal, yVal = self._syntheticPhysics.generateInteraction()
xData[i] = xVal
yData[i] = yVal
#else:
return (xData, yData) # List of X Values, List of Y Values