<jupyter_start><jupyter_text>Demo: MultiContainer feeder exampleThe basic steps to set up an OpenCLSim simulation are:* Import libraries* Initialise simpy environment* Define object classes* Create objects  * Create sites  * Create vessels  * Create activities* Register processes and run simpy----  0. Import libraries<jupyter_code>import datetime, time
import simpy

import numpy as np
import pandas as pd
import shapely.geometry

import openclsim.core as core
import openclsim.model as model
import openclsim.plot as plot<jupyter_output><empty_output><jupyter_text>1. Initialise simpy environment<jupyter_code># setup environment
simulation_start = 0
my_env = simpy.Environment(initial_time=simulation_start)<jupyter_output><empty_output><jupyter_text>2. Define object classes<jupyter_code># create a Site object based on desired mixin classes
Site = type(
    "Site",
    (
        core.Identifiable,
        core.Log,
        core.Locatable,
        core.HasMultiContainer,
        core.HasResource,
    ),
    {},
)

# create a TransportProcessingResource object based on desired mixin classes
TransportProcessingResource = type(
    "TransportProcessingResource",
    (
        core.Identifiable,
        core.Log,
        core.MultiContainerDependentMovable,
        core.Processor,
        core.HasResource,
    ),
    {"key": "MultiStoreHopper"},
)<jupyter_output><empty_output><jupyter_text>3. Create objects 3.1. Create site object(s)<jupyter_code># prepare input data for from_site
location_from_site = shapely.geometry.Point(4.18055556, 52.18664444)
data_from_site = {"env": my_env,
                  "name": "from_site",
                  "geometry": location_from_site,
                  "store_capacity": 4,
                  "nr_resources": 1,
                  "initials": [
                                {"id": "Cargo type 1", "level": 10, "capacity": 10},
                              ],
                 }
# instantiate from_site 
from_site = Site(**data_from_site)

# prepare input data for to_site
location_to_site = shapely.geometry.Point(4.25222222, 52.11428333)
data_to_site = {"env": my_env,
                "name": "to_site",
                "geometry": location_to_site,
                "store_capacity": 4,
                "nr_resources": 1,
                "initials": [
                                {"id": "Cargo type 1", "level": 0, "capacity": 10},
                            ],
                 }
# instantiate to_site 
to_site = Site(**data_to_site)<jupyter_output><empty_output><jupyter_text>3.2. Create vessel object(s)<jupyter_code># prepare input data for vessel_01
data_vessel01 = {"env": my_env,
                 "name": "vessel01",
                 "geometry": location_from_site, 
                 "store_capacity": 4,
                 "nr_resources": 1,
                 "compute_v": lambda x: 10,
                 "initials": [
                                {"id": "Cargo type 1", "level": 0, "capacity": 1},
                             ],
                 }
# instantiate vessel_01 
vessel01 = TransportProcessingResource(**data_vessel01)

# prepare input data for vessel_02
data_vessel02 = {"env": my_env,
                 "name": "vessel02",
                 "geometry": location_from_site, 
                 "store_capacity": 4,
                 "nr_resources": 1,
                 "compute_v": lambda x: 10,
                 "initials": [
                                {"id": "Cargo type 1", "level": 0, "capacity": 1},
                             ],
                 }
# instantiate vessel_02 
vessel02 = TransportProcessingResource(**data_vessel02)

# prepare input data for installer01
data_installer01 = {"env": my_env,
                 "name": "installer01",
                 "geometry": location_to_site, 
                 "store_capacity": 4,
                 "nr_resources": 1,
                 "compute_v": lambda x: 10,
                 "initials": [
                                {"id": "Cargo type 1", "level": 0, "capacity": 1},
                             ],
                 }
# instantiate vessel_02 
installer01 = TransportProcessingResource(**data_installer01)<jupyter_output><empty_output><jupyter_text>3.3 Create activity/activities<jupyter_code># initialise registry
registry = {}
processes = []
for vessel in [vessel01, vessel02]:
    processes.append(
        model.RepeatActivity(
            env=my_env,
            name=f"while {vessel.name}",
            registry=registry,
            sub_processes=[
                model.SequentialActivity(
                    env=my_env,
                    name=f"sequence {vessel.name}",
                    registry=registry,
                    sub_processes=[
                        model.MoveActivity(
                            env=my_env,
                            name=f"sailing empty {vessel.name}",
                            registry=registry,
                            mover=vessel,
                            destination=from_site,
                            duration=10,
                        ),
                        model.ShiftAmountActivity(
                            env=my_env,
                            name=f"load cargo type 1 {vessel.name}",
                            registry=registry,
                            processor=vessel,
                            origin=from_site,
                            destination=vessel,
                            amount=1,
                            duration=10,
                            id_="Cargo type 1",
                        ),
                        model.MoveActivity(
                            env=my_env,
                            name=f"sailing filled {vessel.name}",
                            registry=registry,
                            mover=vessel,
                            destination=to_site,
                            duration=10,
                        ),
                        model.ShiftAmountActivity(
                            env=my_env,
                            name=f"unload cargo type 1 {vessel.name}",
                            registry=registry,
                            processor=installer01,
                            origin=vessel,
                            destination=installer01,
                            amount=1,
                            duration=10,
                            id_="Cargo type 1",
                        ),
                    ],
                )
            ],
            repetitions=5
        )
    )
install_process = model.WhileActivity(
    env=my_env,
    name=f"While installer",
    registry=registry,
    condition_event={"type": "container", "concept": to_site, "state": "full", "id_":"Cargo type 1"},
    sub_processes=[
        model.ShiftAmountActivity(
            env=my_env,
            name=f"Install Cargo type 1",
            registry=registry,
            processor=installer01,
            origin=installer01,
            destination=to_site,
            amount=1,
            duration=10,
            id_="Cargo type 1",
            start_event={"type": "container", "concept": installer01, "state": "full", "id_":"Cargo type 1"}
        )
    ],
)<jupyter_output><empty_output><jupyter_text>4. Register processes and run simpy<jupyter_code>model.register_processes([install_process, *processes])
my_env.run()<jupyter_output><empty_output><jupyter_text>5. Inspect results 5.1 Inspect logs<jupyter_code>plot.get_log_dataframe(from_site, [install_process, *processes, vessel01])<jupyter_output><empty_output><jupyter_text>5.2 Visualise gantt charts<jupyter_code>acts = []
for proc in processes:
    acts.extend(proc.sub_processes[0].sub_processes)
    
plot.get_gantt_chart([*install_process.sub_processes, *acts])<jupyter_output><empty_output><jupyter_text>5.3 Visualise step charts<jupyter_code>plot.get_step_chart([installer01])
plot.get_step_chart([from_site, vessel01, vessel02, installer01, to_site])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09695221372130942, 'fraction_numerical': 0.021823654835068356, 'mean_word_length': 1.6651069518716577, 'pattern_counts': {'":': 57, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '246299', 'license': 'MIT', 'n_tokens_mistral': 2316, 'n_tokens_neox': 2133, 'n_words': 433, 'path': 'notebooks/23_Simple_feeder_process_MC.ipynb', 'repo_name': 'TUDelft-CITG/OpenCLSim', 'size': '7973'}