rparedis 2 lat temu
rodzic
commit
9dd00b684a
3 zmienionych plików z 27 dodań i 2 usunięć
  1. BIN
      PoAB.zip
  2. 25 0
      de2/berth_mapper.py
  3. 2 2
      de2/elements.py

BIN
PoAB.zip


+ 25 - 0
de2/berth_mapper.py

@@ -0,0 +1,25 @@
+import pandas as pd
+from de2.routing import get_graph, get_closest_vertex, pathfinder
+
+berths = pd.read_csv("berths.csv", index_col=0)
+bmap = {}
+for _, berth in berths.iterrows():
+	bmap[berth["lpl_id"]] = berth["center_lon"], berth["center_lat"]
+
+graph = get_graph()
+
+locks = ["ZAS", "BOS", "BES", "KAS", "KIS"]
+mtx = pd.DataFrame(columns=["source"] + locks)
+
+for _, berth in berths.iterrows():
+	row = [berth["lpl_id"]]
+	bnode = get_closest_vertex(graph, berth["center_lon"], berth["center_lat"])
+
+	for lock in locks:
+		_, ds = pathfinder(graph, bmap[berth["lpl_id"]], bmap[lock])
+		row.append(sum(ds))
+
+	mtx.loc[len(mtx.index)] = row
+
+mtx.to_csv("berths2.csv", index=False)
+

+ 2 - 2
de2/elements.py

@@ -1,7 +1,7 @@
 from pypdevs.DEVS import AtomicDEVS, CoupledDEVS
 from pypdevs.infinity import INFINITY
 
-from dataclasses import dataclass
+from dataclasses import dataclass, field
 import pandas as pd
 
 from de2.routing import get_graph, get_closest_vertex
@@ -43,7 +43,7 @@ class Vessel:
 	total_distance: float = 0.0
 	time_until_departure: float = 0.0
 
-	footprint: Footprint = Footprint()
+	footprint: Footprint = field(default_factory=Footprint)
 
 
 class Pool(AtomicDEVS):