Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from .node import Node
from .arrival_node import ArrivalNode
from decimal import Decimal, getcontext
from .server import Server
class ExactNode(Node):
"""
Inherits from the Node class, implements a more
precise version of addition to fix discrepencies
with floating point numbers.
"""
def create_starting_servers(self):
"""
Initialise the servers
"""
return [Server(self, i + 1, Decimal('0.0')) for i in range(self.c)]
def increment_time(self, original, increment):
"""
Increments the original time by the increment
"""
return Decimal(str(original)) + Decimal(str(increment))
def set_classes(self, node_class, arrival_node_class):
"""
Sets the type of ArrivalNode and Node classes being used
in the Simulation model (if customer classes are used.)
"""
if arrival_node_class is not None:
self.ArrivalNodeType = arrival_node_class
else:
self.ArrivalNodeType = ArrivalNode
if node_class is not None:
self.NodeType = node_class
else:
self.NodeType = Node