Commit f303b3ce authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

avoid ZeroDivisionError in TradeModelSolver.

parent d642ab37
...@@ -129,7 +129,10 @@ class TradeModelSolver(AcceptSolver): ...@@ -129,7 +129,10 @@ class TradeModelSolver(AcceptSolver):
movement.setQuantity(total_quantity) movement.setQuantity(total_quantity)
for simulation_movement in simulation_movement_list: for simulation_movement in simulation_movement_list:
quantity = simulation_movement.getQuantity() quantity = simulation_movement.getQuantity()
delivery_ratio = quantity / total_quantity if total_quantity != 0.0:
delivery_ratio = quantity / total_quantity
else:
delivery_ratio = 1.0 / len(simulation_movement_list)
delivery_error = total_quantity * delivery_ratio - quantity delivery_error = total_quantity * delivery_ratio - quantity
simulation_movement.edit(delivery_ratio=delivery_ratio, simulation_movement.edit(delivery_ratio=delivery_ratio,
delivery_error=delivery_error, delivery_error=delivery_error,
......
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