Skip to content

Commit

Permalink
Fixed the HC_MMHC_tabu_Lner so it uses new an improved HC_TabuLner
Browse files Browse the repository at this point in the history
  • Loading branch information
rrtucci committed Sep 5, 2016
1 parent bd9b175 commit 0bbadb1
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions learning/HC_MMHC_tabu_Lner.py
Expand Up @@ -119,12 +119,12 @@ def __init__(self, states_df, score_type, max_num_mtries,

def move_approved(self, move):
"""
Returns bool indicating whether move is approved. Only moves not in
tabu_list are approved. Of those, all 'del' and 'rev' moves are
approved but 'add' moves approved only if they add an edge from a
vertex to one of its neighbors. Neighbors are given by the
dictionary vtx_to_nbors which is calculated before the hill climbing
starts.
Returns bool indicating whether move is approved. Only moves that
are approved by parent class HC_TabuLner are approved. Of those,
all 'del' and 'rev' moves are approved but 'add' moves approved only
if they add an edge from a vertex to one of its neighbors. Neighbors
are given by the dictionary vtx_to_nbors which is calculated before
the hill climbing starts.
Parameters
----------
Expand All @@ -135,18 +135,15 @@ def move_approved(self, move):
bool
"""
m_approved = True
if move in self.tabu_list:
m_approved = False
# print('inside amove approved')
if not HC_TabuLner.move_approved(self, move):
return False
# print('inside move approved')
# print(move)
# print(self.vtx_to_nbors)
if move[2] == 'add':
if move[0] not in self.vtx_to_nbors[move[1]] or\
move[1] not in self.vtx_to_nbors[move[0]]:
m_approved = False
# print(m_approved)
return m_approved
if move[0] not in self.vtx_to_nbors[move[1]]:
return False
return True

if __name__ == "__main__":
HillClimbingLner.HC_lner_test(HC_MMHC_tabu_Lner)

0 comments on commit 0bbadb1

Please sign in to comment.