Commit 5377d7c3 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Experimental Commit for K

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33952 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e5eda9eb
......@@ -80,7 +80,6 @@ class SolverProcess(XMLObject, ActiveProcess):
"""
Builds target solvers from solver decisions
"""
solver_dict = {}
movement_dict = {}
types_tool = self.portal_types
......@@ -102,6 +101,14 @@ class SolverProcess(XMLObject, ActiveProcess):
movement_solver_configuration_dict[solver_conviguration_key] = None
# Second, make sure solvers do not conflict and configuration is valid
# Build a movement and configuration structure per solver type
solver_dict = {}
for movement_url, movement_solver_dict in movement_dict.items():
for solver_type, movement_solver_configuration_dict in movement_solver_dict.items():
solver_movement_dict = solver_dict.setdefault(solver_type, {})
configuration_list = solver_movement_dict.setdefault(movement_url, [])
configuration_list.extend(movement_solver_configuration_dict) # XXX-JPS WRONG
# Then start the grouping procedure
for movement_url, movement_solver_dict in movement_dict.items():
for solver_type, movement_solver_configuration_dict in movement_solver_dict.items():
solver = types_tool[solver_type]
......@@ -109,13 +116,14 @@ class SolverProcess(XMLObject, ActiveProcess):
if other_solver_type == solver_type:
continue
if solver.conflictsWithSolver(types_tool[other_solver_type]):
# XXX6PJS REDO HERE
raise ValueError, "Solver %s conflicts with solver %s on movement %s" % (solver_type, other_solver_type, movement_url)
# Make sure multiple configuration are possible
try:
# Solver key contains only those properties which differentiate
# solvers (ex. there should be only Production Reduction Solver)
solver_key = tuple(solver.reduceConfigurationList(movement_solver_configuration_dict.keys()))
except:
solver_key = solver.getSolverProcessGroupingKey(movement_url, movement_solver_configuration_dict, movement_solver_dict, solver_dict[solver_type])
except: # Raise the exception generated by the solver in case of failure of grouping
raise
solver_key_dict = solver_dict.setdefault(solver_type, {})
solver_movement_dict = solver_key_dict.setdefault(solver_key, {})
......@@ -174,7 +182,7 @@ class SolverProcess(XMLObject, ActiveProcess):
movement_list.extend(x.getMovementList())
# We suppose here that movement_list is a list of
# delivery lines. Let group decisions in such way
# delivery lines. Let us group decisions in such way
# that a single decision is created per divergence tester instance
# and per application level list
solver_tool = self.getParentValue()
......
......@@ -52,24 +52,69 @@ class SolverTypeInformation(ERP5TypeInformation):
, PropertySheet.Configurable
)
def conflictsWithSolver(self, other_solver):
def conflictsWithSolver(self, movement, configuration_dict, other_configuration_list):
"""
Returns True if the solver conflicts with other_solver. False else.
movement -- a movement or a movement relative url
configuration_dict -- a dictionary of configuration parameters to
solve the current movement with self
other_configuration_list -- a list of solvers and their configuration
for the same movement
"""
if self.getTestedProperty() == other_solver.getTestedProperty():
return True
# XXX more condition is needed?
method = self._getTypeBasedMethod('conflictsWithSolver')
if method is not None:
return method(movement, configuration_dict, other_configuration_list)
# Default Implementation (use categories and trivial case)
for solver_type, configuration_dict in other_configuration_list:
if solver.getTestedProperty() == self.getTestedProperty():
return True
# Return False by Default
return False
def reduceConfigurationList(self, configuration_property_id_list):
def getSolverProcessGroupingKey(self, movement, configuration_dict, other_configuration_list):
"""
Note: if one reduces production by 10% for one line and one reduces
production by 20% for another line or for the same line the total
reduction is 20% for both lines this is the goal of
reduceConfigurationList
Returns a key which can be used to group solvers during the
process to build Targer Solver instances from Solver Decisions.
This key depends on the movement and on the configuration_dict.
For example, the movement dependent key for a solver which reduces
produced quantity is the releative URL of the production order which
this movement depends from (if it depennds on a single production
order). If the same movement relates to multiple production orders,
then the movement dependent grouping key should be None, but this
could generate a different group for movements which depend on
a single production order and for movements which depend on
multiple production orders. For this purpose, the grouping key
can be decided by looking up other_movement_list, a dictionnary
which provides for each movement solver by the same solver the
configuration parameters.
The configuration dependent key for a "universal" solver (ex.
Adopt, Accept) which tested property is configurable, is the
tested property itself.
movement -- a movement or a movement relative url
configuration_dict -- a dictionary of configuration parameters
other_configuration_list -- a list of movements and their configuration
which are solved by the same solve type.
[(m1, c1), (m2, c2), ...]
"""
# XXX real implementation is needed.
return configuration_property_id_list
method = self._getTypeBasedMethod('getSolverProcessGroupingKey')
if method is not None:
return method(movement, configuration_dict, other_configuration_list)
# Default Implementation (read properties and implement XXX)
if self.isLineGroupable():
return ()
return movement.getRelativeUrl()
def getDefaultConfigurationPropertyDict(self, configurable):
"""
......@@ -119,4 +164,6 @@ class SolverTypeInformation(ERP5TypeInformation):
configurable -- a configurable document (Solver Decision
or Target Solver)
TODO: XXX-JPS unify with IConfigurable
"""
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