Commit 3c95538f authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] CLUnfolder: Fix explanations of get_var_name(), get_var_indexed_name()

parent 1ec9eb87
......@@ -586,7 +586,7 @@ class CLUnfolder(object):
def get_var_name(self, var_num):
"""Get name of the variable
.. seealso:: Explanations on get_var_indexed_name()
.. seealso:: Explanations are on :meth:`get_var_indexed_name`
@param var_num: DIMACS literal coding of an initial variable
@return: name of the variable
......@@ -598,9 +598,8 @@ class CLUnfolder(object):
# => variable from the initial system
return self.__var_list[var_code]
else:
# auxiliary variable introduced by properties compilation
return self.__aux_list[var_code - self.shift_step_init -1]
#raise MCLException("Not a DIMACS code of an initial variable")
# Auxiliary variable introduced by properties compilation
return self.__aux_list[var_code - self.shift_step_init - 1]
def get_var_indexed_name(self, var_num):
"""Get name of the variable with the time index appended
......@@ -608,9 +607,10 @@ class CLUnfolder(object):
.. note:: time index is the number of steps since the begining of the
simulation.
:Example:
__shift_step = 2 (current step of the unfolding)
shift_step_init = 2 (number of variables in the system)
:Example - Only standard variables:
__shift_step = 2 (number of variables in the system)
shift_step_init = 2 (number of variables in the system at the initial state)
__var_list = ["##", "n1", "n2"]
Virtual list of indexes in the state vector of a solution:
......@@ -625,6 +625,35 @@ class CLUnfolder(object):
=> return: "n1_3"
:Example - With an auxiliary variable:
__shift_step = 2 (There is 1 auxiliary variable)
shift_step_init = 1
__var_list = ["##", "n1"]
__aux_list = ["_lit0"]
Virtual list of indexes in the state vector of a solution:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
#|n1,_lit0|n1,_lit0|n1,_lit0|
ti=0 ti=1 ti=2
If the index is > shift_step_init, then it is an auxiliary
variable. In order to get the index in __aux_list we have to
substract:
- ``1` because on the contrary of __var_list, __aux_list begins at index 0
- `shift_step_init` because value of the first aux variable
follows the last value of __var_list
Given var_num = 6
var_code of var_name: ((6-1) % 2) + 1 = 2
2 > shift_step_init
index of var_name in __aux_list:
var_code - shift_step_init - 1
2 -1 -1 = 0
var_name = "_lit0"
=> return: "_lit0_2"
@param var_num: DIMACS literal coding
@return: name of the variable with the time index appended
"""
......
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