11import highspy as hp
22import logging
33import time
4+ from typing import List , Set , Tuple , Dict
45
56# Configure logging
67logging .basicConfig (level = logging .INFO )
@@ -26,15 +27,15 @@ def make_model(time_limit: float, logfile: str = "") -> hp.HighsModel:
2627 return model
2728
2829
29- def get_terminals (terminal_group : list [ list ]) -> list :
30+ def get_terminals (terminal_group : List [ List ]) -> List :
3031 """
3132 Turns a nested list of terminals into a list of terminals.
3233 :param terminal_group: nested list of terminals.
3334 :return: list of terminals.
3435 """
3536 return [t for group in terminal_group for t in group ]
3637
37- def terminal_groups_without_root (terminal_group : list [ list ], roots : list , group_index : int ) -> set :
38+ def terminal_groups_without_root (terminal_group : List [ List ], roots : List , group_index : int ) -> Set :
3839 """
3940 Get terminal groups until index k without kth root.
4041 :param terminal_group: nested list of terminals.
@@ -47,7 +48,7 @@ def terminal_groups_without_root(terminal_group: list[list], roots: list, group_
4748 else :
4849 return set ()
4950
50- def get_terminal_groups_until_k (terminal_groups : list [ list ], group_index : int ) -> set :
51+ def get_terminal_groups_until_k (terminal_groups : List [ List ], group_index : int ) -> Set :
5152 """
5253 Get terminal groups until index k.
5354 :param terminal_groups: nested list of terminals.
@@ -56,7 +57,7 @@ def get_terminal_groups_until_k(terminal_groups: list[list], group_index: int) -
5657 """
5758 return set (get_terminals (terminal_groups [:group_index ]))
5859
59- def add_directed_constraints (model : hp .HighsModel , steiner_problem : 'SteinerProblem' ) -> tuple [hp .HighsModel , dict [ hp .HighsVarType ]]:
60+ def add_directed_constraints (model : hp .HighsModel , steiner_problem : 'SteinerProblem' ) -> Tuple [hp .HighsModel , Dict [ str , hp .HighsVarType ]]:
6061 """
6162 Adds DO-D constraints to the model (see Markhorst et al. 2025)
6263 :param model: HiGHS model.
@@ -150,7 +151,7 @@ def demand_and_supply_directed(steiner_problem: 'SteinerProblem', group_id_k: in
150151 return 0
151152
152153
153- def add_flow_constraints (model : hp .HighsModel , steiner_problem : 'SteinerProblem' , z : hp .HighsVarType , y2 : hp .HighsVarType ) -> tuple [hp .HighsModel , dict [ hp .HighsVarType ]]:
154+ def add_flow_constraints (model : hp .HighsModel , steiner_problem : 'SteinerProblem' , z : hp .HighsVarType , y2 : hp .HighsVarType ) -> Tuple [hp .HighsModel , Dict [ str , hp .HighsVarType ]]:
154155 """
155156 We add the flow constraints to the HiGHS model.
156157 :param model: HiGHS model.
@@ -192,7 +193,7 @@ def add_flow_constraints(model: hp.HighsModel, steiner_problem: 'SteinerProblem'
192193 return model , f
193194
194195
195- def build_model (steiner_problem : 'SteinerProblem' , time_limit : float = 300 , logfile : str = "" ) -> tuple [hp .HighsModel , float ]:
196+ def build_model (steiner_problem : 'SteinerProblem' , time_limit : float = 300 , logfile : str = "" ) -> Tuple [hp .HighsModel , hp . HighsVarType , hp . HighsVarType , hp . HighsVarType , hp . HighsVarType , Dict [ str , hp . HighsVarType ] ]:
196197 """
197198 Returns the deterministic directed model.
198199 :param steiner_problem: SteinerProblem-object.
@@ -221,7 +222,7 @@ def build_model(steiner_problem: 'SteinerProblem', time_limit: float = 300, logf
221222 return model , x , y1 , y2 , z , f
222223
223224
224- def run_model (model : hp .HighsModel , steiner_problem : 'SteinerProblem' , x : hp .HighsVarType ) -> tuple [float , float , float , list [ tuple ]]:
225+ def run_model (model : hp .HighsModel , steiner_problem : 'SteinerProblem' , x : hp .HighsVarType ) -> Tuple [float , float , float , List [ Tuple ]]:
225226 """
226227 Solves the model and returns the result.
227228 :param model: highspy model.
0 commit comments