Remove old inp in routine

This commit is contained in:
WQY\qiong
2023-03-21 21:18:53 +08:00
parent 8681a56ed7
commit 9f9d3227b9
28 changed files with 83 additions and 642 deletions

View File

@@ -63,41 +63,9 @@ def set_demand(name: str, cs: ChangeSet) -> ChangeSet:
# [EPA2][EPA3][IN][OUT]
# node base_demand (pattern) ;category
#--------------------------------------------------------------
class InpDemand:
def __init__(self, line: str) -> None:
tokens = line.split()
num = len(tokens)
has_desc = tokens[-1].startswith(';')
num_without_desc = (num - 1) if has_desc else num
self.junction = str(tokens[0])
self.demand = float(tokens[1])
self.pattern = str(tokens[2]) if num_without_desc >= 3 else None
self.category = str(tokens[3]) if num_without_desc >= 4 else None
def inp_in_demand(section: list[str]) -> ChangeSet:
objs: dict[str, list[InpDemand]] = {}
for s in section:
# skip comment
if s.startswith(';'):
continue
obj = InpDemand(s)
if obj.junction not in objs:
objs[obj.junction] = []
objs[obj.junction].append(obj)
cs = ChangeSet()
for junction, demands in objs.items():
obj_cs : dict[str, Any] = g_update_prefix | {'type': 'demand', 'junction' : junction, 'demands' : []}
for obj in demands:
obj_cs['demands'].append({'demand': obj.demand, 'pattern' : obj.pattern, 'category': obj.category})
cs.append(obj_cs)
return cs
def inp_in_demand_new(line: str) -> str:
def inp_in_demand(line: str) -> str:
tokens = line.split()
num = len(tokens)