Exemplo n.º 1
0
    def __init__(self, env):

        self.env = env
        self.model_components: Any
        self.model_graph_names: Dict[str, List[str]]

        #!resources+components (generated)

        self.source = Source(
            self.env,
            "source",
            xy=(79, 59),
            entity_type=Truck,
            max_entities=10,
            inter_arrival_time=250,
            ways={"drive_tour": [(97, 59), (180, 59)]},
        )

        self.sink = Sink(self.env, "sink", xy=(368, 59), ways={})

        self.drive_tour = DriveTour(
            self.env,
            "drive_tour",
            xy=(230, 59),
            geo_info=geo_info,
            start="PAT",
            stops=["ZFB", "MMC", "CAV"],
            ways={"sink": [(280, 59), (350, 59)]},
        )

        #!model (generated)

        self.model_components = {
            "source": self.source,
            "sink": self.sink,
            "drive_tour": self.drive_tour,
        }

        self.model_graph_names = {
            "source": ["drive_tour"],
            "sink": [],
            "drive_tour": ["sink"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]
Exemplo n.º 2
0
def test_if_source_is_creating_entities():
    """test source"""
    env = Environment()
    core_source = Source(env, "source", inter_arrival_time=0)
    entity_receiver = EntityReceiver(env)
    core_source.successors.append(entity_receiver)

    env.run(until=1)
    assert len(
        entity_receiver.received_entities) == core_source.overall_count_in
    assert core_source.overall_count_in == core_source.max_entities
Exemplo n.º 3
0
    def __init__(self, env):

        self.env = env

        #!resources+components

        self.source = Source(
            self.env,
            "source",
            xy=(80, 59),
            inter_arrival_time=100,
            max_entities=2,
            ways={"tilemover": [(98, 59), (181, 59)]},
        )

        self.sink = Sink(self.env, "sink", xy=(369, 59), ways={})

        self.tilemover = TilemapMovement(
            self.env,
            "tilemover",
            xy=(231, 59),
            speed=10,
            coordinates_holder=coordinates_holder,
            from_node="A",
            to_node="C",
            ways={"sink": [(281, 59), (351, 59)]},
        )

        #!model

        self.model_components = {
            "source": self.source,
            "sink": self.sink,
            "tilemover": self.tilemover,
        }

        self.model_graph_names = {
            "source": ["tilemover"],
            "sink": [],
            "tilemover": ["sink"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]
Exemplo n.º 4
0
    def __init__(self, env):

        self.env = env

        #!resources+components

        self.source = Source(
            self.env,
            "source",
            xy=(31, 65),
            inter_arrival_time=0,
            max_entities=6,
            ways={"gateway_1": [(49, 65), (108, 65)]},
        )

        self.sink = Sink(self.env, "sink", xy=(600, 65), ways={})

        self.spr_1 = SeizeProcessRelease(
            self.env,
            "spr_1",
            xy=(289, 65),
            process_time=41,
            ways={"gateway_2": [(339, 65), (422, 65)]},
        )

        self.proc_1 = Delay(
            self.env,
            "proc_1",
            xy=(289, 186),
            process_time=120,
            ways={"gateway_2": [(339, 186), (447, 186), (447, 90)]},
        )

        self.gateway_1 = RoundRobinGateway(
            self.env,
            "gateway_1",
            xy=(133, 65),
            ways={
                "spr_1": [(158, 65), (239, 65)],
                "proc_1": [(133, 90), (133, 186), (239, 186)],
            },
        )

        self.gateway_2 = RoundRobinGateway(
            self.env,
            "gateway_2",
            xy=(447, 65),
            ways={"sink": [(472, 65), (582, 65)]})

        #!model

        self.model_components = {
            "source": self.source,
            "sink": self.sink,
            "spr_1": self.spr_1,
            "proc_1": self.proc_1,
            "gateway_1": self.gateway_1,
            "gateway_2": self.gateway_2,
        }

        self.model_graph_names = {
            "source": ["gateway_1"],
            "sink": [],
            "spr_1": ["gateway_2"],
            "proc_1": ["gateway_2"],
            "gateway_1": ["spr_1", "proc_1"],
            "gateway_2": ["sink"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]
Exemplo n.º 5
0
    def __init__(self, env):

        self.env = env

        #!resources+components

        self.source = Source(
            self.env,
            "source",
            xy=(31, 65),
            inter_arrival_time=0,
            max_entities=10,
            ways={"gateway_1": [(49, 65), (108, 65)]},
        )

        self.sink = Sink(self.env, "sink", xy=(565, 65), ways={})

        self.parallel_proc = Delay(
            self.env,
            "parallel_proc",
            xy=(289, 65),
            process_time=1,
            block_capacity=float("inf"),
            ways={"gateway_2": [(339, 65), (422, 65)]},
        )

        self.sequential_proc = Delay(
            self.env,
            "sequential_proc",
            xy=(355, 229),
            process_time=1,
            block_capacity=1,
            ways={"gateway_2": [(405, 229), (447, 229), (447, 90)]},
        )

        self.buffer = Delay(
            self.env,
            "buffer",
            xy=(215, 229),
            process_time=0,
            block_capacity=float("inf"),
            ways={"sequential_proc": [(265, 229), (305, 229)]},
        )

        self.gateway_1 = RoundRobinGateway(
            self.env,
            "gateway_1",
            xy=(133, 65),
            ways={
                "parallel_proc": [(158, 65), (239, 65)],
                "buffer": [(133, 90), (133, 229), (165, 229)],
            },
        )

        self.gateway_2 = RoundRobinGateway(
            self.env,
            "gateway_2",
            xy=(447, 65),
            ways={"sink": [(472, 65), (547, 65)]})

        #!model

        self.model_components = {
            "source": self.source,
            "sink": self.sink,
            "parallel_proc": self.parallel_proc,
            "sequential_proc": self.sequential_proc,
            "buffer": self.buffer,
            "gateway_1": self.gateway_1,
            "gateway_2": self.gateway_2,
        }

        self.model_graph_names = {
            "source": ["gateway_1"],
            "sink": [],
            "parallel_proc": ["gateway_2"],
            "sequential_proc": ["gateway_2"],
            "buffer": ["sequential_proc"],
            "gateway_1": ["parallel_proc", "buffer"],
            "gateway_2": ["sink"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]
Exemplo n.º 6
0
    def __init__(self, env):

        self.env = env

        #!resources+components

        self.source = Source(
            self.env,
            "source",
            xy=(55, 59),
            inter_arrival_time=0,
            max_entities=6,
            ways={"wait": [(73, 59), (131, 59)]},
        )

        self.source_2 = Source(
            self.env,
            "source_2",
            xy=(55, 250),
            inter_arrival_time=1,
            max_entities=6,
            ways={"free_wait": [(73, 250), (131, 250)]},
        )

        self.sink = Sink(self.env, "sink", xy=(311, 59), ways={})

        self.sink_2 = Sink(self.env, "sink_2", xy=(311, 250), ways={})

        self.wait = WaitForInterrupt(self.env,
                                     "wait",
                                     xy=(181, 59),
                                     ways={"sink": [(231, 59), (293, 59)]})

        self.free_wait = Interruptor(
            self.env,
            "free_wait",
            xy=(181, 250),
            ways={"sink_2": [(231, 250), (293, 250)]},
        )

        #!model

        self.model_components = {
            "source": self.source,
            "source_2": self.source_2,
            "sink": self.sink,
            "sink_2": self.sink_2,
            "wait": self.wait,
            "free_wait": self.free_wait,
        }

        self.model_graph_names = {
            "source": ["wait"],
            "source_2": ["free_wait"],
            "sink": [],
            "sink_2": [],
            "wait": ["sink"],
            "free_wait": ["sink_2"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]

        # custom additional wiring logic
        # nice possible extension: set this type of link in the bpmn and parse it
        self.free_wait.block_to_interrupt = self.wait
Exemplo n.º 7
0
    def __init__(self, env):

        self.env = env

        #!resources+components

        self.resource_1 = NamedResource(
            self.env, "resource_1", xy=(395, 43), capacity=2, ways={}
        )

        self.source = Source(
            self.env,
            "source",
            xy=(31, 169),
            inter_arrival_time=0,
            max_entities=6,
            ways={"wait_for_resource": [(49, 169), (125, 169)]},
        )

        self.sink = Sink(self.env, "sink", xy=(735, 169), ways={})

        self.proc_1 = Delay(
            self.env,
            "proc_1",
            xy=(315, 169),
            process_time=5,
            ways={"proc_2": [(365, 169), (415, 169)]},
        )

        self.proc_2 = Delay(
            self.env,
            "proc_2",
            xy=(465, 169),
            process_time=5,
            ways={"release_resource": [(515, 169), (575, 169)]},
        )

        self.wait_for_resource = ResourceSeizeQueue(
            self.env,
            "wait_for_resource",
            resource=self.resource_1,
            xy=(175, 169),
            ways={"proc_1": [(225, 169), (265, 169)]},
        )

        self.release_resource = ResourceRelease(
            self.env,
            "release_resource",
            resource=self.resource_1,
            xy=(625, 169),
            ways={"sink": [(675, 169), (717, 169)]},
        )

        #!model

        self.model_components = {
            "source": self.source,
            "sink": self.sink,
            "proc_1": self.proc_1,
            "proc_2": self.proc_2,
            "wait_for_resource": self.wait_for_resource,
            "release_resource": self.release_resource,
        }

        self.model_graph_names = {
            "source": ["wait_for_resource"],
            "sink": [],
            "proc_1": ["proc_2"],
            "proc_2": ["release_resource"],
            "wait_for_resource": ["proc_1"],
            "release_resource": ["sink"],
        }
        # translate model_graph_names into corresponding objects
        self.model_graph = {
            self.model_components[name]: [
                self.model_components[nameSucc]
                for nameSucc in self.model_graph_names[name]
            ]
            for name in self.model_graph_names
        }

        for component in self.model_graph:
            component.successors = self.model_graph[component]