Tutorial

This tutorial guides you in running a simulation with COLCA App, step by step.

Installation of COLCA App

To use COLCA, first clone COLCA from the GitHub repo:

(.venv) $ git clone https://github.com/alberto-sastre/Project2_AS.git

Installation of skforecast

You have to install skforecast package from the github repository

(.venv) $ pip install git+https://github.com/JoaquinAmatRodrigo/skforecast@v0.1.9

Initialization of mongoDB

You have to install mongoDB and should have it running on your system.

If you have installed the MongoDB 4.4 Community Edition, you have to run MongoDB as a background service in terminal:

(.venv) $ brew services start mongodb-community@4.4

If you are working under Windows OS, by installing MongoDB in Windows you can install it as a background service (mongoDB installer will ask you for this option) and it will be available at running time.

Initialization of uvicorn

First, install uvicorn in your virtual enviroment using pip:

(.venv) $ pip install uvicorn

Second, execute uvicorn in terminal:

(.venv) sascr/colca_services$ uvicorn colca:app --reload

Third, do not close this terminal until the end of the simulation.

Run the simulation

Now you are ready to run the simulation, to do this:

(.venv) sascr/colca_tutorial$ python3 -m tutorial

It takes a while to complete, not much ;)

First, you have to setup 2 processes in order to perform a simulation. For this, you have to follow the instructions on screen, step by step. We recommend you to use the ‘default’ values, it is easier.

  1. You have to define a city name for a process:

    SETTING UP FIRST PROCESS:
    Select city name: [Oviedo, Aviles]; default: Oviedo >>
    
  2. You have to give a name to the process (to get it correctly idetified):

    Select process name: [Pump Station 1, Pump Station 2]; default: Pump Station 1 >>
    
  3. You have to select what does your process need (for instance, oil):

    Select need items: [oil, rhodium, aluminium]; default: oil >>
    
  4. You have to do the same with the second process:

    SETTING UP SECOND PROCESS:
    Select city name: [Oviedo, Aviles]; default: Aviles >>
    

Second, once you have your processes defined, you will see the description of then on screen. Now, you can press any button to start the simulation:

THESE ARE THE TWO PROCESSES WITH FULL DATA:


city_name: Oviedo                                 city_name: Aviles
co2_penalty: 23.44                                co2_penalty: 23.44
id_number: 1                                      id_number: 2
last_updated: 2021-06-04T06:20:37.185000          last_updated: 2021-06-04T06:20:37.185000
name: Pump Station 1                              name: Pump Station 2
needs_items: ['oil']                              needs_items: ['aluminium']
new_needs: True                                   new_needs: True
new_orders: True                                  new_orders: True
purchase_orders_made: True                        purchase_orders_made: True
purchased_items: ['gasoline', 'aluminium']        purchased_items: ['gasoline', 'aluminium']
start_work: 2021-06-04T06:20:37.184000            start_work: 2021-06-04T06:20:37.184000
time_span: 1200                                   time_span: 1200

Finally you will be presented with the simulation results on screen. You can also access to this data in a .log file where all the same information is available:

RESULTS OF THE SIMULATION, IN GREEN COLOR YOU CAN SEE THE CHANGES:


city_name: Oviedo                                 city_name: Oviedo
co2_penalty: 0                                    co2_penalty: 23.44
id_number: 1                                      id_number: 1
last_updated: 2021-06-04T06:20:37.185000          last_updated: 2021-06-14T07:37:42.321000
name: pump station 21                             name: pump station 21
needs_items: ['oil', 'rhodium']                   needs_items: ['oil', 'rhodium']
new_needs: True                                   new_needs: True
new_orders: True                                  new_orders: True
purchase_orders_made: True                        purchase_orders_made: True
purchased_items: ['gasoline', 'aluminium']        purchased_items: ['oil', 'rhodium']
start_work: 2021-06-04T06:20:37.184000            start_work: 2021-06-14T15:00:00.000000
time_span: 1200                                   time_span: 2465

Interpreting the results

Once you have the results of the simulation, either in the .log file or in screen, we can make an interpretation of the results with you, in order to extract useful information.

  1. co2_penalty

    co2_penalty: 0          co2_penalty: 23.44

    Indicates de c02_penalty, expressed in the currency of the country. It applies when the process has to get power from a non-renewal source.

  2. last_updated

    last_updated: 2021-06-04T06:20:37.185000          last_updated: 2021-06-14T07:37:42.321000

    When this process was updated for the last time.

  3. new_orders

    new_orders: True        new_orders: True

    If COLCA determines that there are new orders, it uses this flag, setting it to True.

  4. purchase_orders_made

    purchase_orders_made: True        purchase_orders_made: True

    If COLCA made a purchase of any element needed by the process, this flag is set to True.

  5. purchased_items

    purchased_items: ['gasoline', 'aluminium']        purchased_items: ['oil', 'rhodium']

    This is a list of elements that COLCA has purchasd automatically for the process in order to cover the process’s needs.

  6. start_work

    start_work: 2021-06-04T06:20:37.184000            start_work: 2021-06-14T15:00:00.000000

    This is the optimal date and time when the process has to start working.

  7. time-span

    time_span: 1200         time_span: 2465

    This is the time window for optimizing the energy used by the process, in order to avoid co2 emissions and get the better energy price (if needed a non-renewable source).

End of the simulation

COLCA’s simulation has come to its end. With this simulation you have seen how COLCA works very fast, analyzing the processes and making the best decisions for them. Keeps the information of each process updated, and an accountability oc co2 emissions and side costs could be easily performed.

In production, this is a fully automated process. Just add a process with the setup information and let COLCA help you going Green!

Note

You can also pip install requirements.txt to get all dependencies in your environment at once. You have to do this from the same folder where requierements.txt is stored:

(.venv) $ pip install -r requirements.txt