redistribute the demands

This commit is contained in:
xinzish
2024-04-12 23:59:09 +08:00
parent 330248041f
commit e8fddfb71a
3 changed files with 24 additions and 4 deletions

View File

@@ -91,3 +91,14 @@ def distribute_demand_to_nodes(name: str, demand: float, nodes: list[str], type:
def distribute_demand_to_region(name: str, demand: float, region: str, type: str = DISTRIBUTION_TYPE_ADD) -> ChangeSet:
nodes = get_nodes_in_region(name, region)
return distribute_demand_to_nodes(name, demand, nodes, type)
def get_total_base_demand(name:str,region:str)->float:
nodes = get_nodes_in_region(name, region)
t_demands=0.0
for node in nodes:
if not is_junction(name, node):
continue
ds = get_demand(name, node)['demands']
t_demands= t_demands+ds[0]['demand']
return t_demands