Support calculate_demand_to_network

This commit is contained in:
WQY\qiong
2023-05-12 19:47:19 +08:00
parent b75a717f95
commit e6ec0018a0
4 changed files with 25 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
from .database import ChangeSet
from .s0_base import is_junction
from .s0_base import is_junction, get_nodes
from .s9_demands import get_demand
from .s32_region_util import Topology, get_nodes_in_region
from .batch_exe import execute_batch_command
@@ -43,6 +43,11 @@ def calculate_demand_to_region(name: str, demand: float, region: str) -> dict[st
return calculate_demand_to_nodes(name, demand, nodes)
def calculate_demand_to_network(name: str, demand: float) -> dict[str, float]:
nodes = get_nodes(name)
return calculate_demand_to_nodes(name, demand, nodes)
def distribute_demand_to_nodes(name: str, demand: float, nodes: list[str], type: str = DISTRIBUTION_TYPE_ADD) -> ChangeSet:
if len(nodes) == 0 or demand == 0.0:
return ChangeSet()