Commit 79256a8c authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] C: Rename shift_dynamic to shift_dimacs_clauses: More accurate

parent 5ee8833c
......@@ -569,14 +569,13 @@ static PyObject* forward_init_dynamic(PyObject *self, PyObject *args, PyObject *
return dynamic_constraints;
}
PyDoc_STRVAR(shift_dynamic_doc,
"shift_dynamic(numeric_clauses, shift_step)\n\
PyDoc_STRVAR(shift_dimacs_clauses_doc,
"shift_dimacs_clauses(numeric_clauses, shift_step)\n\
Shift numeric clauses representing the dynamics X' = f(X,I,C)\n\
\n\
Basically, `shift_step` is added to positive variables and subtracted\n\
from negative variables in each clause in `numeric_clauses`.\n\
\n\
TODO: Rename this function \"shift_numeric_clauses or shift_dimacs_clauses\"\n\
:param numeric_clauses: List of clauses in DIMACS format (constraints)\n\
:param shift_step: Shift step dependant on the run\n\
:return: A list of DIMACS coding of the forward shifted clause\n\
......@@ -585,7 +584,7 @@ TODO: Rename this function \"shift_numeric_clauses or shift_dimacs_clauses\"\n\
:rtype: <list <list <int>>>"
);
static PyObject* shift_dynamic(PyObject *self, PyObject *args, PyObject *kwds)
static PyObject* shift_dimacs_clauses(PyObject *self, PyObject *args, PyObject *kwds)
{
#ifndef NDEBUG
/* Debugging code */
......@@ -798,7 +797,7 @@ static PyMethodDef module_methods[] = {
{"get_unshift_code", (PyCFunction) get_unshift_code, METH_VARARGS | METH_KEYWORDS, get_unshift_code_doc},
{"unflatten", (PyCFunction) unflatten, METH_VARARGS | METH_KEYWORDS, unflatten_doc},
{"shift_clause", (PyCFunction) shift_clause, METH_VARARGS | METH_KEYWORDS, shift_clause_doc},
{"shift_dynamic", (PyCFunction) shift_dynamic, METH_VARARGS | METH_KEYWORDS, shift_dynamic_doc},
{"shift_dimacs_clauses", (PyCFunction) shift_dimacs_clauses, METH_VARARGS | METH_KEYWORDS, shift_dimacs_clauses_doc},
{"forward_code", (PyCFunction) forward_code, METH_VARARGS | METH_KEYWORDS, forward_code_doc},
{"forward_init_dynamic", (PyCFunction) forward_init_dynamic, METH_VARARGS | METH_KEYWORDS, forward_init_dynamic_doc},
{NULL, NULL, 0, NULL} /* Sentinel - marks the end of this structure */
......
......@@ -159,7 +159,7 @@ from cadbiom.models.clause_constraints.mcl.MCLSolutions import RawSolution, MCLE
from cadbiom import commons as cm
# C++ API
from _cadbiom import shift_clause, shift_dynamic, forward_code, \
from _cadbiom import shift_clause, shift_dimacs_clauses, forward_code, \
forward_init_dynamic
# Standard imports
......@@ -856,7 +856,7 @@ class CLUnfolder(object):
# __dynamic_constraints:
# List of lists of DIMACS encoded clauses (lists of ints)
self.__dynamic_constraints.append(
shift_dynamic(
shift_dimacs_clauses(
self.__dynamic_constraints[-1], # <list <list <int>>>
self.__shift_step
)
......@@ -872,7 +872,7 @@ class CLUnfolder(object):
- init_backward_unfolding()
"""
self.__initial_constraints = \
shift_dynamic(
shift_dimacs_clauses(
self.__initial_constraints,
self.__shift_step
)
......@@ -887,7 +887,7 @@ class CLUnfolder(object):
- init_forward_unfolding()
"""
self.__final_constraints = \
shift_dynamic(
shift_dimacs_clauses(
self.__final_constraints,
self.__shift_step
)
......@@ -905,7 +905,7 @@ class CLUnfolder(object):
if self.__invariant_constraints:
# New API via C++ module
self.__invariant_constraints.append(
shift_dynamic(
shift_dimacs_clauses(
self.__invariant_constraints[-1],
self.__shift_step
)
......
......@@ -24,11 +24,11 @@ def test_shift_clause():
assert found == [103148, 106526, 95988, -95985]
def test_shift_dynamic():
def test_shift_dimacs_clauses():
from _cadbiom import shift_dynamic
from _cadbiom import shift_dimacs_clauses
found = shift_dynamic([[66035, 66037, -66036],
found = shift_dimacs_clauses([[66035, 66037, -66036],
[66036, -66037],
[55515, 58893, 48355, -48352]], 47633)
assert found == [[113668, 113670, -113669],
......
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