Skip to content

Commit

Permalink
Fix data tracker
Browse files Browse the repository at this point in the history
When no valid networks are found in an iteration of the supply systems optimisation the tracker (tracking optimal networks) would not be able store anything and run into an error. This changes fixes this edge-case.
  • Loading branch information
MatNif committed Nov 14, 2023
1 parent eec8963 commit 7120ce8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cea/optimization_new/helpercalsses/optimization/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def add_candidate_individual(self, candidate_individual):
connectivity vectors have been analysed.
"""
network_ids = [network.identifier for network in candidate_individual.networks]
networks_with_supsys = list(candidate_individual.supply_systems.keys())
network_graphs = {network.identifier: network
for network in candidate_individual.networks}
supsys_structures = {network_id: supply_systems[0].structure
Expand All @@ -65,7 +66,8 @@ def add_candidate_individual(self, candidate_individual):
{network_id: {'network_graph': network_graphs[network_id],
'supsys_structure': supsys_structures[network_id],
'supsys_individuals': supsys_individuals[network_id]}
for network_id in network_ids}
for network_id in network_ids
if network_id in networks_with_supsys}

def set_current_individual(self, connectivty_vector):
""" Update the current connectivity vector which is being evaluated. """
Expand Down

0 comments on commit 7120ce8

Please sign in to comment.