-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
74 lines (54 loc) · 1.41 KB
/
models.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from pydantic import BaseModel
from typing import List, Optional, Tuple
from enum import Enum
class Pos(BaseModel):
x: int
y: int
def to_tuple(self) -> Tuple[int, int]:
return (self.x, self.y)
def to_tuple_yx(self) -> Tuple[int, int]:
return (self.y, self.x)
class Config:
from_attributes = True
class GasType(Enum):
test_gas = 0
class Gas(BaseModel):
pos: Pos
gas: GasType
def velocity(self) -> float:
pass
class Config:
from_attributes = True
class Person(BaseModel):
pos: Pos
velocity: float = 1.0
class Config:
from_attributes = True
class Destination(BaseModel):
position: Pos
class Config:
from_attributes = True
class BaseElement(Enum):
free = 0
wall = 1
person = 2
gas = 3
class Route(BaseModel):
points: List[Pos]
class EvacuationMap(BaseModel):
ev_map: List[List[BaseElement]]
def to_array(self) -> List[List[int]]:
return [[v.value for v in _map] for _map in self.ev_map]
class Config:
from_attributes = True
class EvacuationMapTimeSeries(BaseModel):
maps_series: List[EvacuationMap]
class Config:
from_attributes = True
class GasSpreadLayers(BaseModel):
layers: List[List[Pos]]
class BaseSettings(BaseModel):
person: Person
gases: List[Gas]
class Config:
from_attributes = True