Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
79256a8c
Commit
79256a8c
authored
Dec 02, 2019
by
VIGNET Pierre
Browse files
[lib] C: Rename shift_dynamic to shift_dimacs_clauses: More accurate
parent
5ee8833c
Changes
3
Hide whitespace changes
Inline
Side-by-side
library/_cadbiom/cadbiom.c
View file @
79256a8c
...
...
@@ -569,14 +569,13 @@ static PyObject* forward_init_dynamic(PyObject *self, PyObject *args, PyObject *
return
dynamic_constraints
;
}
PyDoc_STRVAR
(
shift_d
ynamic
_doc
,
"shift_d
ynamic
(numeric_clauses, shift_step)
\n
\
PyDoc_STRVAR
(
shift_d
imacs_clauses
_doc
,
"shift_d
imacs_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_d
ynamic
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
static
PyObject
*
shift_d
imacs_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_d
ynamic
"
,
(
PyCFunction
)
shift_d
ynamic
,
METH_VARARGS
|
METH_KEYWORDS
,
shift_d
ynamic
_doc
},
{
"shift_d
imacs_clauses
"
,
(
PyCFunction
)
shift_d
imacs_clauses
,
METH_VARARGS
|
METH_KEYWORDS
,
shift_d
imacs_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 */
...
...
library/cadbiom/models/clause_constraints/mcl/CLUnfolder.py
View file @
79256a8c
...
...
@@ -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_d
ynamic
,
forward_code
,
\
from
_cadbiom
import
shift_clause
,
shift_d
imacs_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_d
ynamic
(
shift_d
imacs_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_d
ynamic
(
shift_d
imacs_clauses
(
self
.
__initial_constraints
,
self
.
__shift_step
)
...
...
@@ -887,7 +887,7 @@ class CLUnfolder(object):
- init_forward_unfolding()
"""
self
.
__final_constraints
=
\
shift_d
ynamic
(
shift_d
imacs_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_d
ynamic
(
shift_d
imacs_clauses
(
self
.
__invariant_constraints
[
-
1
],
self
.
__shift_step
)
...
...
library/test/test_C_api.py
View file @
79256a8c
...
...
@@ -24,11 +24,11 @@ def test_shift_clause():
assert
found
==
[
103148
,
106526
,
95988
,
-
95985
]
def
test_shift_d
ynamic
():
def
test_shift_d
imacs_clauses
():
from
_cadbiom
import
shift_d
ynamic
from
_cadbiom
import
shift_d
imacs_clauses
found
=
shift_d
ynamic
([[
66035
,
66037
,
-
66036
],
found
=
shift_d
imacs_clauses
([[
66035
,
66037
,
-
66036
],
[
66036
,
-
66037
],
[
55515
,
58893
,
48355
,
-
48352
]],
47633
)
assert
found
==
[[
113668
,
113670
,
-
113669
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment