A package to help with your supply chain model
Project description
Supply Chain Model Helper
This is a python package that helps with creating your own supply chain model. You dont need intricate knowledge about python, you might need a bit knowledge about graphs (essential part is provided in video tutorials) and a bit about supply chain models in general. This package also gives you the opportunity to store the data you may need to make this supply chain model run in an efficient manner. A full documentation is provided inside the python package. Videotutorials will be linked here later, as well as a documentation to read.
What's New in Version 0.2.0
I added graphics package to draw certain aspects of the supply chain model. An example can be found in the subfolder example_scripts in this project.
jupyter notebook files
Jupyter notebook tutorial files are stored in this projects 'example_scripts' subfolder.
Currently these these tutorials are to be found:
- Creating a toy supply chain model (unfinished)
- tutorial on making use of the graphics package
The following jupyter tutorials are in development:
- creating a simple supply chain model
- toolkit for handling attributes on the network
- data modelling and mapping it onto the predefined network structure
- create a full gravity model
- hdf5 datacube for supply chain modelling
- Meta data schema of database for the supply chain model
- handling multiple datasets for supply chain modelling
- a not so simple example model
Installation manual
pip install supplychainmodelhelper
Example scripts
in project folder 'example_scripts, you'll find examples of how to implement supply chain toy models, so you can start working on your own much easier
Video tutorials
A series of tutorials is planned, but still unfinished. https://www.youtube.com/channel/UCtUiAESg7TiTdublRlUhvjw
If you cant wait, see a preliminary documentation below and full documentation from the help functions in python itself, instructions on how to get help within python below.
Functionalities
Create network model
Purpose: create graph from specifications of the user with generally used node properties used in supply chain models.
Get full documentation in python by
from supplchainmodulator import graphoperations as go
help(go)
Get documentation on 1 particular function
help(go.[INSERT FUNCTION NAME HERE])
Functions
Basic operations on network:
- createGraph - the graph is created with node attributes 'actors', 'locations','products'
- getListOfNodeIDs - returns a list of nodeIDs with the corresponding attributes, used for editing information on the graph
- getNodeIDswAttr - returns a tuple of (nodeIDs,attributes) with the corresponding attributes, used for editing information on the graph
- addAttr2ExistingNodes - adds a user specified attribute to the nodes of the network
- addAttr2Edges - adds a user specified attribute to the edges of the network
- getEdgeID - returns the IDs for the edges on the graph, given the user specified nodes (IDs given by getListOfNodeIDs) on the network
- getEdgesAttr - returns a list of attributes of the edges (IDs given by getEdgeID) specified by the user
- getEdgeIDswAttr - returns a tuple of ((edge ID, attribute) = (node out,node in, attribute)) of the edges (IDs given by getEdgeID) specified by the user
- getExistingAttrs - returns a list of existing attributes on the graph (either nodes or edges)
Toolkit for handling information and data on the network:
- combineActorBrand - if an actor consists of different subtypes (e.g. warehouse and brand(ALDI, REWE, etc.)), then this function helps with a fast way of creating additional actors, before creating the network
- convertLoT2NTs - functions like getEdgeIDswAttr, return a list of tuples, but only a part of this is needed. This function accepts a list of tuples as input and returns 2 lists with the same order as before.
- convertTup2LoT - functions like addAttr2ExistingNodes, accept a list of tuples as input, but only a list available. This function accepts 2 lists as input and returns a list on tuples with the same order as before.
- getAllCombinations - getEdgeID is a function that has the corresponding nodes as input, and returns a direct 1-to-1 list (node out, node in). If all possible combinations of edges between 2 nodes are to be returned, this function helps with that.
- convertMatrix - 2 applications:
- for calibration might be needed if calibration measure is of different dimension as the calculated flows
- if a matrix with redundant information needs to be created from a matrix with minimum information (e.g. similar geographical distances between nodes to be put into a distance matrix)
Mapping raw data objects to network data objects:
-
proxyModel - simple fraction model. If data for correlated variable is available, this model may be used to use the proxy data to model the data in question (e.g. modellled data = produced eggs, proxy data= number of laying hens)
-
furnessModel - given geographical distance, supply and demand of the participating nodes and the free parameter (resistance factor) beta this function returns the flow between given nodes (beta needs to be determined by hymanModel / calibration)
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'input' needs to be defined on the nodes demanding the product.
-
hymanModel - calculates resistance factor beta given a transport distance. Returns the flow between participating nodes of supply and demand.
- NOTE that each of the returned values are POSSIBLE average transport distance. The best one still needs to be determined(see calibration).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'input' needs to be defined on the nodes demanding the product.
-
calibration - function for calculating the best configuration of given transport distances and corresponding flows. A number of possible average transport distances are given by the function calcPotTransportDistances. The function hymanModel calculates the corresponding flows. Now this needs to be calibrated against a measure to determine which average transport distance fits best the calibration measure. This function accepts a 4D-Tensor of all flows as input [supply, demand,product,transport distance] and the calibration measure in question.
- NOTE that each of the returned values are POSSIBLE average transport distance. The best one still needs to be determined(see calibration).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'input' needs to be defined on the nodes demanding the product.
-
getDistMatrix - accesses the graph for attribute 'distance' for user-specified nodes, return a dataframe containing information of the geographical distance between the locations of given nodes (needs to be entered into the graphe beforehand via the function addAttr2Edges)
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
-
optFlow, minOptFlowForBeta - calculating and minimizing the optimal flow given supply and demand of a product and the distance between participating nodes. Needed for calculating minimum transport distance (see calcPotTransportDistances).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
-
propFlow - calculating the proportional flow given supply and demand of a product and the distance between participating nodes. Needed for calculating maximum transport distance (see calcPotTransportDistances).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
-
calcPotTransportDistances - calculates the range of possible average transport distances and returns a list of values within this interval. The number of returned values from this interval may be specified by the user (needed for hymanModel to determine beta for furnessModel).
- NOTE that each of the returned values are POSSIBLE average transport distance. The best one still needs to be determined(see calibration).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'input' needs to be defined on the nodes demanding the product.
-
getWeightedDist - returns the average transport distance, given the flow between participating nodes of supply and demand.
- NOTE that each of the returned values are POSSIBLE average transport distance. The best one still needs to be determined(see calibration).
- NOTE that the attribute 'distance' needs to be defined on the edges of the participating nodes.
- NOTE that the attribute 'output' needs to be defined on the nodes supplying the product.
- NOTE that the attribute 'input' needs to be defined on the nodes demanding the product.
Create hdf5 file structure for raw data objects
Purpose: create hdf5 file structure for raw data objects including infos about metadata structure. This is optional, but highly recommended. Complex supply chain models are based on complex input data, so a structured centralized data platform that gives easy access is necessary.
Get full documentation in python by
from supplychainmodelhelper import mds
help(mds)
Get documentation on 1 particular function
help(mds.Datacube.[INSERT FUNCTION NAME HERE])
function names:
-
__init__ - initialise database: a new hdf5 file created or an existing accessed
-
add2TemplateMDofDB - extend the existing basic metadata schema of the database
-
removeFromTemplateMDofDB - remove an existing element from the md schema of the database
-
add2TemplateMDofDataset - extend the existing basic metadata schema of an existing folder
-
removeElementTemplateDataSetMD - remove an element of the md schema of a dataset
-
addFolder2ExistingDB - add a folder to the database, incl. a list of metadata information based on the current metadata schema
-
removeFolder - remove an existing folder from the database
-
addDataSet2ExistingFolder - add a dataset to an existing folder, incl. a list of metadata information based on the current metadataschema
-
getDataFrameFromFolder - get an existing dataset from a specific folder in the database
-
removeDatasetFromFolder - remove an existing dataset from an existing folder in the database
-
getMDFromDataSet- get metadata information about an existing dataset in the database
-
getMDFromFolder - get metadata information about an existing folder in the database
-
getMDfrom_db - get metadata information about the database
-
editMDofDataset - if the user changes the meta data schema of the datasets, this needs to be updated with every dataset in the db. This function helps with that.
-
editMDofDB - if the user changes the metadata schema of the database, the new entries need to be filled with content. This function helps with that.
-
exportTemplateMDSchemaofDB2CSV - store the current metadata schema of the database as a template csv file, for later import
-
exportTemplateMDSchemaofDataset2CSV - store the current metadata schema of a folder as a template csv file, for later import
-
importMDDataofDatasetFromCSV - import csv file with current metadata schema of folder and filled out metadata information about containing datasets
-
importMDDataofDBfromCSV - import csv file with current metadata schema of database and filled out metadata information about containing datasets
Assorted function to further support the user
- importDataFromFolder - IF the user already has a data folder with certain specifications
from supplychainmodelhelper import datahandling as dh
help(dh.importDataFromFolder)
this function may be used to create a hdf5 database without much effort. With this a complete folder of raw data may be imported into a hdf5 database. Note that this function is still in the testing phase and needs further updates.
-
decBSList - if a list of strings or bytestrings are given, this function returns a list of strings. No need to check if some string is one or the other, just apply this to your list.
-
decBS - if a string or bytestring is given, this function returns a string. No need to check if some string is one or the other, just apply this to your list.
Still to do
- check proxy model for vegetables = identical/similar to eggs in FoodFlow?
- video tutorials:
- graphoperations
- datacube
- datahandling
- what is to do for FoodFlow
- export graph to hdf5 and to graphml
- make it possible to filter/link 2 LoTs via common attribute (intersect?)
- check minimizing of active edges still possible with concept of distance matrix mapped to graph
- get all content of list of given node ids
- on creating graph str should be accepted (currently list only)
- check if get attributes of nodes/edges is always in a tuple
- add attributes in tuples
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file supplychainmodelhelper-0.2.7.tar.gz.
File metadata
- Download URL: supplychainmodelhelper-0.2.7.tar.gz
- Upload date:
- Size: 60.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95191dfa9f32a1c84c9efd2d2f90047d7ed1958008c5c395ecaee15f4b98fa85
|
|
| MD5 |
cdb09e0a570e2ba7e5c42b51b41f0e06
|
|
| BLAKE2b-256 |
17f7f47986bc2f66162b46ec1f9514ac80b291349146d5195adc895bf9df3a47
|
File details
Details for the file supplychainmodelhelper-0.2.7-py3-none-any.whl.
File metadata
- Download URL: supplychainmodelhelper-0.2.7-py3-none-any.whl
- Upload date:
- Size: 60.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0def75646f0e43afc98899eba91c44efbd1091519676881828c0a271a9f0eca
|
|
| MD5 |
d5cae8e055261f183332328f229111be
|
|
| BLAKE2b-256 |
41e0274835f7c139715470bec63fc30921db18bb687b2e2756f05ad54eb231d8
|