Commit 034e801b authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Fix proper list index + pythonic code

parent 15b4017a
......@@ -185,7 +185,7 @@ class RawSolution(object):
# the variable is frontier var:
if abs(sol) == frontiers[j]:
if self.__shift_direction == "FORWARD":
fsol.append(self.__solution[i])
fsol.append(sol)
else:
fsol.append(self.__solution[i+dec])# look for initial values
j += 1
......@@ -200,20 +200,21 @@ class RawSolution(object):
@param sol: a dimacs solution
@return: a dimacs code list of the activation state on the frontier for sol
"""
jmax = len(self.__unfolder.get_frontier())
frontiers = self.__unfolder.get_frontier()
jmax = len(frontiers)
fsol = []
sol = self.__solution
j = 0
dec = self.__shift_step * self.__current_step
for i in range(len(sol)):
for i, sol in enumerate(self.__solution):
# the variable is frontier var:
if abs(sol[i]) == self.__unfolder.get_frontier()[j]:
if abs(sol) == frontiers[j]:
if self.__shift_direction == "FORWARD":
if sol[i] > 0:
fsol.append(sol[i])
if sol > 0:
fsol.append(sol)
else:
if sol[i+dec] > 0:
fsol.append(sol[i+dec]) # look for initial values
if self.__solution[i+dec] > 0:
fsol.append(self.__solution[i+dec]) # look for initial values
j += 1
if j == jmax:
return fsol
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment