Skip to content

Commit

Permalink
loggs minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Almog-David committed Jul 26, 2024
1 parent a4aadff commit a3f3d9f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def setup_logger():
logger.addHandler(console_handler)
return logger

#logger = setup_logger()

#logger = logging.getLogger(__name__)
logger = setup_logger()

def spreading_maxsave(Graph:nx.DiGraph, budget:int, source:int, targets:list, stop_condition=None) -> tuple[list, set]:
"""
Expand Down Expand Up @@ -296,6 +294,7 @@ def non_spreading_minbudget(Graph:nx.DiGraph, source:int, targets:list) -> int:
logger.info(f"Starting the non_spreading_minbudget function with source node {source} and targets: {targets}")

G = create_st_graph(Graph, targets)
logger.info(f"Calculating the minimum budget using edmonds karp algorithm")
min_budget = len(algo.minimum_st_node_cut(G, source, 't'))

logger.info(f"Returning minimum budget: {min_budget}")
Expand Down Expand Up @@ -437,7 +436,6 @@ def heuristic_maxsave(Graph:nx.DiGraph, budget:int, source:int, targets:list, sp
if len(local_targets) == 0 or any(node in infected_nodes for node in local_targets):
for node in targets:
node_status = Graph.nodes[node]['status']
logger.debug(f" node {node} status {node_status}")
if node_status != Status.INFECTED.value:
saved_target_nodes.add(node)
logger.info(f"Returning vaccination strategy: {vaccination_strategy}. The strategy saved the nodes: {saved_target_nodes}")
Expand All @@ -447,7 +445,6 @@ def heuristic_maxsave(Graph:nx.DiGraph, budget:int, source:int, targets:list, sp

for node in targets:
node_status = Graph.nodes[node]['status']
logger.debug(f" node {node} status {node_status}")
if node_status != Status.INFECTED.value:
saved_target_nodes.add(node)

Expand Down Expand Up @@ -497,6 +494,7 @@ def heuristic_minbudget(Graph:nx.DiGraph, source:int, targets:list, spreading:bo
best_strategy = heuristic_maxsave(Graph, min_budget, source, targets, spreading, True)[0]

while min_value < max_value:
logger.info(f"Calling heuristic_maxsave with parameters - Source: {source}, Targets: {targets}, Budget: {middle}")
strategy, nodes_saved = heuristic_maxsave(Graph, middle, source, targets, spreading, True)

common_elements = set(nodes_saved) & set(targets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@

logger = logging.getLogger(__name__)

def setup_global_logger(level: int = logging.DEBUG):
log_format = "|| %(asctime)s || %(levelname)s || %(message)s"
date_format = '%H:%M:%S'
formatter = logging.Formatter(log_format, datefmt=date_format)
handler = logging.StreamHandler()
handler.setFormatter(formatter)

root_logger = logging.getLogger()
root_logger.setLevel(level)
root_logger.addHandler(handler)


def generate_random_DiGraph(
num_nodes: int = 100,
edge_probability: float = 0.1,
Expand Down
17 changes: 1 addition & 16 deletions networkz/algorithms/approximation/firefighter_problem/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,7 @@ class Status(Enum):
'directly vaccinated': 'green',
'default' : "#00FFD0"
}

def setup_logger():
logger = logging.getLogger('firefighter_problem_main')
logger.setLevel(logging.INFO)

console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)

formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
console_handler.setFormatter(formatter)

logger.addHandler(console_handler)
return logger

logger = setup_logger()
#logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)

# ============================ Validation Functions ============================

Expand Down

0 comments on commit a3f3d9f

Please sign in to comment.