Mentions légales du service

Skip to content
Snippets Groups Projects
Commit a142eaf4 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Reformat MCLQuery

parent 95d1cfd8
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ from logging import DEBUG
LOGGER = cm.logger()
class MCLSimpleQuery(object):
"""Class packaging the elements of a query
......@@ -83,6 +84,7 @@ class MCLSimpleQuery(object):
NB: DClause: A clause coded as a list of DIMACS coded literals: <list <int>>
"""
def __init__(self, start_prop, inv_prop, final_prop):
"""
@param start_prop: init property - None is allowed
......@@ -90,10 +92,14 @@ class MCLSimpleQuery(object):
@param final_prop: final property - None is allowed
"""
if LOGGER.getEffectiveLevel() == DEBUG:
LOGGER.debug("MCLSimpleQuery params:: start prop: " + \
str(start_prop) + '; inv prop: ' + \
str(inv_prop) + '; final prop: ' + \
str(final_prop))
LOGGER.debug(
"MCLSimpleQuery params:: start prop: "
+ str(start_prop)
+ "; inv prop: "
+ str(inv_prop)
+ "; final prop: "
+ str(final_prop)
)
# Strings forms of constraints
self.start_prop = start_prop # logical formula or None
self.inv_prop = inv_prop # logical formula or None
......@@ -144,7 +150,9 @@ class MCLSimpleQuery(object):
# - Get events names in each step
# (remove the leading "%" and split the string on spaces)
# - 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
if not var_prop:
var_prop = None
......@@ -153,7 +161,6 @@ class MCLSimpleQuery(object):
n_query.variant_prop = var_prop
return n_query
@classmethod
def from_frontier_sol_new_timing(cls, f_sol, unfolder):
"""Build a query from a frontier solution
......@@ -190,8 +197,10 @@ class MCLSimpleQuery(object):
# (remove the leading "%" and split the string on spaces)
# - negation of each event with "not ( event )"
# - join events names with a logical operator " or "
var_prop = [" or ".join("not (" + icp + ")" for icp in raw_step[1:].split())
for raw_step in f_sol.ic_sequence]
var_prop = [
" 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
if not var_prop:
var_prop = None
......@@ -201,8 +210,9 @@ class MCLSimpleQuery(object):
# and force their inactivation with a negative value.
## dim_start doit-il etre ordonné ?
# 1 - Get negative values of activated frontiers in FrontierSolution object
activated_frontier_neg_values = \
{-unfolder.var_dimacs_code(name) for name in f_sol.activated_frontier}
activated_frontier_neg_values = {
-unfolder.var_dimacs_code(name) for name in f_sol.activated_frontier
}
# 2 - Get values of inactivated frontiers in the FrontSolution object
dim_start_values = \
......@@ -250,7 +260,9 @@ class MCLSimpleQuery(object):
# - Get events names in each step
# (remove the leading "%" and split the string on spaces)
# - 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
if not var_prop:
var_prop = None
......@@ -259,8 +271,9 @@ class MCLSimpleQuery(object):
# Search all frontiers that are not in activated_frontier
# and force their inactivation with a negative value.
# Get negative values of activated frontiers in FrontierSolution object
activated_frontier_neg_values = \
{-unfolder.var_dimacs_code(name) for name in f_sol.activated_frontier}
activated_frontier_neg_values = {
-unfolder.var_dimacs_code(name) for name in f_sol.activated_frontier
}
# Get list of values of inactivated frontiers in the FrontSolution object
dim_start_values = \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment