Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit d6c4b872 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] MCLSolutions: refactor FrontierSolution

parent 6a7cbcdb
......@@ -433,7 +433,8 @@ class FrontierSolution(object):
..TODO::
- Faire une super classe dont héritent RawSolution et DimacsFrontierSol
pour éviter la duplication de code...
pour éviter la duplication de code et le stockage d'attributs qu'on
connait déjà dans les types de plus bas niveaux...
- ... Ou détecter le type d'objet dans le constructeur => ducktyping
- renommer l'attr activated_frontier en activated_frontiers
"""
......@@ -458,10 +459,26 @@ class FrontierSolution(object):
self.current_step = current_step
@classmethod
def build_input_clock_sequence(cls, obj, ic_sequence):
"""
def build_input_clock_sequence(cls, get_var_name, ic_sequence):
"""Get strings representing timings of each step in the solution.
:param get_var_name: Method to call for a conversion of values to names.
(binding of the method get_var_name() of an unfolder).
:param ic_sequence:
- Each tuple is the state of literals in a step of the solution.
- Each literal in the tuple is an activated variable in a step.
- Variables are inputs or events (free clocks) ONLY!
:type get_var_name: <function>
:type ic_sequence: <tuple <tuple <int>>
:return: List of strings representing timings of each step in ic_sequence.
:rtype: <list <str>>
"""
return [str("% " + " ".join(obj.get_var_name(iii) for iii in icv)).rstrip(" ") for icv in ic_sequence]
# Strip used to remove trailing space on empty steps : "% "
return [
str("% " + " ".join(get_var_name(value)
for value in step_literals)).rstrip(" ")
for step_literals in ic_sequence
]
@classmethod
def from_raw(cls, raw_sol):
......@@ -483,10 +500,10 @@ class FrontierSolution(object):
# Get raw activated inputs and free clocks (values)
# and format them so that they are understandable by humans
ic_seq = raw_sol.extract_act_input_clock_seq()
# Strip used to remove trailing space on empty steps : "% "
ic_sequence = [str("% " + " ".join(raw_sol.get_var_name(iii) for iii in icv)).rstrip(" ") for icv in ic_seq]
ic_sequence = FrontierSolution.build_input_clock_sequence(
raw_sol.get_var_name,
raw_sol.extract_act_input_clock_seq()
)
# LOGGER.debug("FrontierSolution:from_raw:: ic_sequence %s", ic_sequence)
return cls(activated_frontiers, ic_sequence, raw_sol.current_step)
......@@ -509,10 +526,10 @@ class FrontierSolution(object):
# Get raw activated inputs and free clocks (values)
# and format them so that they are understandable by humans
ic_seq = dimacs_front_sol.ic_sequence
# Strip used to remove trailing space on empty steps : "% "
ic_sequence = [str("% " + " ".join(dimacs_front_sol.get_var_name(iii) for iii in icv)).rstrip(" ") for icv in ic_seq]
ic_sequence = FrontierSolution.build_input_clock_sequence(
dimacs_front_sol.get_var_name,
dimacs_front_sol.ic_sequence
)
# LOGGER.debug("FrontierSolution:from_dimacs_front_sol:: ic_sequence %s", ic_sequence)
return cls(activated_frontiers, ic_sequence, dimacs_front_sol.current_step)
......
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