[Erp5-report] r33951 jp - /erp5/trunk/products/ERP5/Document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Mar 22 15:35:50 CET 2010
Author: jp
Date: Mon Mar 22 15:35:50 2010
New Revision: 33951
URL: http://svn.erp5.org?rev=33951&view=rev
Log:
Experimental Commit for K
Modified:
erp5/trunk/products/ERP5/Document/SolverProcess.py
erp5/trunk/products/ERP5/Document/SolverTypeInformation.py
Modified: erp5/trunk/products/ERP5/Document/SolverProcess.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SolverProcess.py?rev=33951&r1=33950&r2=33951&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SolverProcess.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SolverProcess.py [utf8] Mon Mar 22 15:35:50 2010
@@ -80,7 +80,6 @@
"""
Builds target solvers from solver decisions
"""
- solver_dict = {}
movement_dict = {}
types_tool = self.portal_types
@@ -102,6 +101,14 @@
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 @@
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 @@
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()
Modified: erp5/trunk/products/ERP5/Document/SolverTypeInformation.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/SolverTypeInformation.py?rev=33951&r1=33950&r2=33951&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/SolverTypeInformation.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/SolverTypeInformation.py [utf8] Mon Mar 22 15:35:50 2010
@@ -52,24 +52,69 @@
, 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
+ 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 @@
configurable -- a configurable document (Solver Decision
or Target Solver)
+
+ TODO: XXX-JPS unify with IConfigurable
"""
More information about the Erp5-report
mailing list