Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cadbiom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIGNET Pierre
cadbiom
Commits
a142eaf4
Commit
a142eaf4
authored
5 years ago
by
VIGNET Pierre
Browse files
Options
Downloads
Patches
Plain Diff
[lib] Reformat MCLQuery
parent
95d1cfd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
library/cadbiom/models/clause_constraints/mcl/MCLQuery.py
+26
-13
26 additions, 13 deletions
library/cadbiom/models/clause_constraints/mcl/MCLQuery.py
with
26 additions
and
13 deletions
library/cadbiom/models/clause_constraints/mcl/MCLQuery.py
+
26
−
13
View file @
a142eaf4
...
@@ -48,6 +48,7 @@ from logging import DEBUG
...
@@ -48,6 +48,7 @@ from logging import DEBUG
LOGGER
=
cm
.
logger
()
LOGGER
=
cm
.
logger
()
class
MCLSimpleQuery
(
object
):
class
MCLSimpleQuery
(
object
):
"""
Class packaging the elements of a query
"""
Class packaging the elements of a query
...
@@ -83,6 +84,7 @@ class MCLSimpleQuery(object):
...
@@ -83,6 +84,7 @@ class MCLSimpleQuery(object):
NB: DClause: A clause coded as a list of DIMACS coded literals: <list <int>>
NB: DClause: A clause coded as a list of DIMACS coded literals: <list <int>>
"""
"""
def
__init__
(
self
,
start_prop
,
inv_prop
,
final_prop
):
def
__init__
(
self
,
start_prop
,
inv_prop
,
final_prop
):
"""
"""
@param start_prop: init property - None is allowed
@param start_prop: init property - None is allowed
...
@@ -90,10 +92,14 @@ class MCLSimpleQuery(object):
...
@@ -90,10 +92,14 @@ class MCLSimpleQuery(object):
@param final_prop: final property - None is allowed
@param final_prop: final property - None is allowed
"""
"""
if
LOGGER
.
getEffectiveLevel
()
==
DEBUG
:
if
LOGGER
.
getEffectiveLevel
()
==
DEBUG
:
LOGGER
.
debug
(
"
MCLSimpleQuery params:: start prop:
"
+
\
LOGGER
.
debug
(
str
(
start_prop
)
+
'
; inv prop:
'
+
\
"
MCLSimpleQuery params:: start prop:
"
str
(
inv_prop
)
+
'
; final prop:
'
+
\
+
str
(
start_prop
)
str
(
final_prop
))
+
"
; inv prop:
"
+
str
(
inv_prop
)
+
"
; final prop:
"
+
str
(
final_prop
)
)
# Strings forms of constraints
# Strings forms of constraints
self
.
start_prop
=
start_prop
# logical formula or None
self
.
start_prop
=
start_prop
# logical formula or None
self
.
inv_prop
=
inv_prop
# logical formula or None
self
.
inv_prop
=
inv_prop
# logical formula or None
...
@@ -144,7 +150,9 @@ class MCLSimpleQuery(object):
...
@@ -144,7 +150,9 @@ class MCLSimpleQuery(object):
# - Get events names in each step
# - Get events names in each step
# (remove the leading "%" and split the string on spaces)
# (remove the leading "%" and split the string on spaces)
# - join events names with a logical operator " and "
# - join events names with a logical operator " and "
var_prop
=
[
"
and
"
.
join
(
raw_step
[
1
:].
split
())
for
raw_step
in
f_sol
.
ic_sequence
]
var_prop
=
[
"
and
"
.
join
(
raw_step
[
1
:].
split
())
for
raw_step
in
f_sol
.
ic_sequence
]
# PS: var_prop and any attribute can be [], but keep this for uniformity
# PS: var_prop and any attribute can be [], but keep this for uniformity
if
not
var_prop
:
if
not
var_prop
:
var_prop
=
None
var_prop
=
None
...
@@ -153,7 +161,6 @@ class MCLSimpleQuery(object):
...
@@ -153,7 +161,6 @@ class MCLSimpleQuery(object):
n_query
.
variant_prop
=
var_prop
n_query
.
variant_prop
=
var_prop
return
n_query
return
n_query
@classmethod
@classmethod
def
from_frontier_sol_new_timing
(
cls
,
f_sol
,
unfolder
):
def
from_frontier_sol_new_timing
(
cls
,
f_sol
,
unfolder
):
"""
Build a query from a frontier solution
"""
Build a query from a frontier solution
...
@@ -190,8 +197,10 @@ class MCLSimpleQuery(object):
...
@@ -190,8 +197,10 @@ class MCLSimpleQuery(object):
# (remove the leading "%" and split the string on spaces)
# (remove the leading "%" and split the string on spaces)
# - negation of each event with "not ( event )"
# - negation of each event with "not ( event )"
# - join events names with a logical operator " or "
# - join events names with a logical operator " or "
var_prop
=
[
"
or
"
.
join
(
"
not (
"
+
icp
+
"
)
"
for
icp
in
raw_step
[
1
:].
split
())
var_prop
=
[
for
raw_step
in
f_sol
.
ic_sequence
]
"
or
"
.
join
(
"
not (
"
+
icp
+
"
)
"
for
icp
in
raw_step
[
1
:].
split
())
for
raw_step
in
f_sol
.
ic_sequence
]
# PS: var_prop and any attribute can be [], but keep this for uniformity
# PS: var_prop and any attribute can be [], but keep this for uniformity
if
not
var_prop
:
if
not
var_prop
:
var_prop
=
None
var_prop
=
None
...
@@ -201,8 +210,9 @@ class MCLSimpleQuery(object):
...
@@ -201,8 +210,9 @@ class MCLSimpleQuery(object):
# and force their inactivation with a negative value.
# and force their inactivation with a negative value.
## dim_start doit-il etre ordonné ?
## dim_start doit-il etre ordonné ?
# 1 - Get negative values of activated frontiers in FrontierSolution object
# 1 - Get negative values of activated frontiers in FrontierSolution object
activated_frontier_neg_values
=
\
activated_frontier_neg_values
=
{
{
-
unfolder
.
var_dimacs_code
(
name
)
for
name
in
f_sol
.
activated_frontier
}
-
unfolder
.
var_dimacs_code
(
name
)
for
name
in
f_sol
.
activated_frontier
}
# 2 - Get values of inactivated frontiers in the FrontSolution object
# 2 - Get values of inactivated frontiers in the FrontSolution object
dim_start_values
=
\
dim_start_values
=
\
...
@@ -250,7 +260,9 @@ class MCLSimpleQuery(object):
...
@@ -250,7 +260,9 @@ class MCLSimpleQuery(object):
# - Get events names in each step
# - Get events names in each step
# (remove the leading "%" and split the string on spaces)
# (remove the leading "%" and split the string on spaces)
# - join events names with a logical operator " and "
# - join events names with a logical operator " and "
var_prop
=
[
"
and
"
.
join
(
raw_step
[
1
:].
split
())
for
raw_step
in
f_sol
.
ic_sequence
]
var_prop
=
[
"
and
"
.
join
(
raw_step
[
1
:].
split
())
for
raw_step
in
f_sol
.
ic_sequence
]
# PS: var_prop and any attribute can be [], but keep this for uniformity
# PS: var_prop and any attribute can be [], but keep this for uniformity
if
not
var_prop
:
if
not
var_prop
:
var_prop
=
None
var_prop
=
None
...
@@ -259,8 +271,9 @@ class MCLSimpleQuery(object):
...
@@ -259,8 +271,9 @@ class MCLSimpleQuery(object):
# Search all frontiers that are not in activated_frontier
# Search all frontiers that are not in activated_frontier
# and force their inactivation with a negative value.
# and force their inactivation with a negative value.
# Get negative values of activated frontiers in FrontierSolution object
# Get negative values of activated frontiers in FrontierSolution object
activated_frontier_neg_values
=
\
activated_frontier_neg_values
=
{
{
-
unfolder
.
var_dimacs_code
(
name
)
for
name
in
f_sol
.
activated_frontier
}
-
unfolder
.
var_dimacs_code
(
name
)
for
name
in
f_sol
.
activated_frontier
}
# Get list of values of inactivated frontiers in the FrontSolution object
# Get list of values of inactivated frontiers in the FrontSolution object
dim_start_values
=
\
dim_start_values
=
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment