Commit 38f33857 authored by Sebastien Robin's avatar Sebastien Robin

simulation: fix FIFO and FILO solvers, they were unable to work with several movements

parent 521b48ad
...@@ -9,6 +9,9 @@ for solver_process in delivery.getSolverValueList(): ...@@ -9,6 +9,9 @@ for solver_process in delivery.getSolverValueList():
draft_solver_process = solver_process draft_solver_process = solver_process
if draft_solver_process is not None: if draft_solver_process is not None:
# Fully clean it to avoid having some solver decisions in double
id_list = [x for x in draft_solver_process.objectIds()]
draft_solver_process.manage_delObjects(ids=id_list)
draft_solver_process.buildSolverDecisionList(delivery) draft_solver_process.buildSolverDecisionList(delivery)
else: else:
delivery.getPortalObject().portal_solver_processes.newSolverProcess(delivery) delivery.getPortalObject().portal_solver_processes.newSolverProcess(delivery)
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
</item> </item>
<item> <item>
<key> <string>line_groupable</string> </key> <key> <string>line_groupable</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>permission</string> </key> <key> <string>permission</string> </key>
......
...@@ -67,17 +67,29 @@ ...@@ -67,17 +67,29 @@
</value> </value>
</item> </item>
<item> <item>
<key> <string>_mt_index</string> </key> <key> <string>_identity_criterion</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
<item> <item>
<key> <string>_tree</string> </key> <key> <string>_mt_index</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>acquire_local_roles</string> </key> <key> <string>acquire_local_roles</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
...@@ -136,17 +148,13 @@ ...@@ -136,17 +148,13 @@
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>last_id</string> </key>
<value> <string>2</string> </value>
</item>
<item> <item>
<key> <string>line_exclusive</string> </key> <key> <string>line_exclusive</string> </key>
<value> <int>0</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>line_groupable</string> </key> <key> <string>line_groupable</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>permission</string> </key> <key> <string>permission</string> </key>
...@@ -166,6 +174,10 @@ ...@@ -166,6 +174,10 @@
<key> <string>solver_action_title</string> </key> <key> <string>solver_action_title</string> </key>
<value> <string>Split and Differ</string> </value> <value> <string>Split and Differ</string> </value>
</item> </item>
<item>
<key> <string>type_class</string> </key>
<value> <string>QuantitySplitSolver</string> </value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
...@@ -176,6 +188,21 @@ ...@@ -176,6 +188,21 @@
<pickle> <int>0</int> </pickle> <pickle> <int>0</int> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="OOBTree" module="BTrees.OOBTree"/> <global name="OOBTree" module="BTrees.OOBTree"/>
</pickle> </pickle>
...@@ -183,7 +210,22 @@ ...@@ -183,7 +210,22 @@
<none/> <none/>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle> <pickle>
<global name="OOBTree" module="BTrees.OOBTree"/> <global name="OOBTree" module="BTrees.OOBTree"/>
</pickle> </pickle>
......
...@@ -77,22 +77,25 @@ class FIFODeliverySolver(XMLObject): ...@@ -77,22 +77,25 @@ class FIFODeliverySolver(XMLObject):
return result return result
simulation_movement_list = self._getSimulationMovementList() simulation_movement_list = self._getSimulationMovementList()
for movement in simulation_movement_list: for movement in simulation_movement_list:
if remaining_quantity: quantity = movement.getQuantity()
quantity = movement.getQuantity() if quantity < remaining_quantity:
if quantity < remaining_quantity: result.append((movement, quantity))
result.append((movement, quantity)) remaining_quantity -= quantity
remaining_quantity -= quantity movement.edit(quantity=0, delivery_ratio=0, activate_kw=activate_kw)
movement.edit(quantity=0, delivery_ratio=0, activate_kw=activate_kw) else:
else: # only append movement if we decrease the quantity, which means we
# would surely split it. If remaining quantity is 0, the code is
# just used to update delivery ratio
if remaining_quantity:
result.append((movement, remaining_quantity)) result.append((movement, remaining_quantity))
movement_quantity = quantity - remaining_quantity movement_quantity = quantity - remaining_quantity
delivery_ratio = 1. delivery_ratio = 1.
if new_quantity: if new_quantity:
delivery_ratio = movement_quantity / new_quantity delivery_ratio = movement_quantity / new_quantity
movement.edit(quantity=movement_quantity, movement.edit(quantity=movement_quantity,
delivery_ratio=delivery_ratio, delivery_ratio=delivery_ratio,
activate_kw=activate_kw) activate_kw=activate_kw)
remaining_quantity = 0 remaining_quantity = 0
# Return movement, split_quantity tuples # Return movement, split_quantity tuples
return result return result
...@@ -103,6 +106,6 @@ class FIFODeliverySolver(XMLObject): ...@@ -103,6 +106,6 @@ class FIFODeliverySolver(XMLObject):
simulation_movement_list = self.getDeliveryValueList() simulation_movement_list = self.getDeliveryValueList()
if len(simulation_movement_list) > 1: if len(simulation_movement_list) > 1:
return sorted(simulation_movement_list, return sorted(simulation_movement_list,
key=lambda x:x.getExplainationValue().getStartDate(), reverse=True) key=lambda x:x.getExplanationValue().getStartDate(), reverse=True)
else: else:
return simulation_movement_list return simulation_movement_list
...@@ -63,6 +63,6 @@ class LIFODeliverySolver(FIFODeliverySolver): ...@@ -63,6 +63,6 @@ class LIFODeliverySolver(FIFODeliverySolver):
simulation_movement_list = self.getDeliveryValueList() simulation_movement_list = self.getDeliveryValueList()
if len(simulation_movement_list) > 1: if len(simulation_movement_list) > 1:
return sorted(simulation_movement_list, return sorted(simulation_movement_list,
key=lambda x:x.getExplainationValue().getStartDate()) key=lambda x:x.getExplanationValue().getStartDate())
else: else:
return simulation_movement_list return simulation_movement_list
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