Skip to content

Commit

Permalink
fix(loadbalance): Ensure that load balance accounts for multipliers
Browse files Browse the repository at this point in the history
It seems that I misunderstood how the match.py module worked when I fist put together the load balance module. Now, I have tested it with multipliers and I'm pretty sure it works correctly.
  • Loading branch information
chriswmackey committed Jul 9, 2021
1 parent 029dabe commit 7a23247
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions honeybee_energy/result/loadbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def _match_room_input(self, data_collections, rooms, data_type,

# match the data collections to the rooms
if use_all: # firs try to see if all objects can be matched
matched_objs = match_rooms_to_data(data_collections, rooms)
matched_objs = match_rooms_to_data(data_collections, rooms, True)
if len(matched_objs) != len(rooms): # take them all
matched_objs = [(None, data, rm.multiplier)
for data, rm in zip(data_collections, rooms)]
Expand All @@ -538,13 +538,14 @@ def _match_room_input(self, data_collections, rooms, data_type,
coll_dict[coll.header.metadata['type']].append(coll)
except KeyError:
coll_dict[coll.header.metadata['type']] = [coll]
all_match = [match_rooms_to_data(val, rooms) for val in coll_dict.values()]
all_match = [match_rooms_to_data(val, rooms, True)
for val in coll_dict.values()]
matched_objs = [list(tup) for tup in all_match[0]]
for other_tups in all_match[1:]:
for i, tup in enumerate(other_tups):
matched_objs[i][1] += tup[1]
else:
matched_objs = match_rooms_to_data(data_collections, rooms)
matched_objs = match_rooms_to_data(data_collections, rooms, True)
assert len(matched_objs) != 0, \
'None of the data collections could be matched to the input rooms.'
self._rooms = tuple(obj[0] for obj in matched_objs) if not use_all else rooms
Expand Down
7 changes: 6 additions & 1 deletion honeybee_energy/result/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from honeybee.face import Face


def match_rooms_to_data(data_collections, rooms):
def match_rooms_to_data(data_collections, rooms, invert_multiplier=False):
"""Match honeybee Rooms to the Zone-level data collections from SQLiteResult.
This method ensures that Room multipliers are correctly output for a given
Expand All @@ -21,6 +21,9 @@ def match_rooms_to_data(data_collections, rooms):
will be used to match the data in the collections to the input rooms.
rooms: An array of honeybee Rooms, which will be matched to the data_collections.
The length of these Rooms does not have to match the data_collections.
invert_multiplier: Boolean to note whether the output room multiplier should be
included when the data type values already account for the multiplier
(False) or when they do not (True).
Returns:
An array of tuples that contain matched rooms and data collections. All
Expand Down Expand Up @@ -52,6 +55,8 @@ def match_rooms_to_data(data_collections, rooms):
zone_ids.append(hvac_id.split('_IDEALAIR')[0])
else:
zone_ids.append(hvac_id)
if invert_multiplier:
use_mult = not use_mult

# loop through the rooms and match the data to them
for room in rooms:
Expand Down

0 comments on commit 7a23247

Please sign in to comment.