Skip to main content

SC Optimize

PyPI version License: MIT

Supply Chain Optimization package in python using PuLP.

Setup

Make sure you have Python 3.6.x (or higher) installed on your system. You can download it here.

Installation

pip install scoptimize

Getting Started

Technical Documentation

The Technical Docs can be found here.

Basic Usage

from scoptimize.network import Model, Node, Flow

model = Model(name='MyModel')
model.add_object(Node(name="Factory_1", origin=True, cashflow_per_unit=-1, max_units=15))
model.add_object(Node(name="Customer_1", destination=True, min_units=10))
model.add_object(Flow(name="Factory_1__Customer_1", cashflow_per_unit=-1, max_units=15, start='Factory_1', end='Customer_1'))
model.solve()

print(model.objective) #=> 20.0

Advanced Usage

Input:

from scoptimize.network import Model, Node, Flow
from pprint import pp

model = Model(name='MyAdvancedModel')

model.add_object(Node(name="F1", origin=True, cashflow_for_use=-8, cashflow_per_unit=-1, max_units=5))
model.add_object(Node(name="F2", origin=True, cashflow_per_unit=-2, max_units=10))
model.add_object(Node(name="W1", cashflow_per_unit=-1, max_units=10))
model.add_object(Node(name="D1", destination=True, cashflow_per_unit=0, min_units=8, max_units=10))

model.add_object(Flow(name="F1_W1", cashflow_per_unit=-1, max_units=15, start='F1', end='W1'))
model.add_object(Flow(name="F2_W1", cashflow_per_unit=-1, max_units=15, start='F2', end='W1'))
model.add_object(Flow(name="W1_D1", cashflow_per_unit=-1, max_units=15, start='W1', end='D1'))

model.solve()
pp(model.get_object_stats())

Output:

{'F1': {'name': 'F1',
        'class': 'Node',
        'origin': True,
        'destination': False,
        'inflows': 0.0,
        'outflows': 0.0,
        'reflows_in': 0.0,
        'reflows_out': 0.0,
        'use': 0.0,
        'variable_cashflow': -0.0,
        'fixed_cashflow': -0.0},
 'F2': {'name': 'F2',
        'class': 'Node',
        'origin': True,
        'destination': False,
        'inflows': 0.0,
        'outflows': 8.0,
        'reflows_in': 0.0,
        'reflows_out': 0.0,
        'use': 1.0,
        'variable_cashflow': -16.0,
        'fixed_cashflow': 0.0},
 'W1': {'name': 'W1',
        'class': 'Node',
        'origin': False,
        'destination': False,
        'inflows': 8.0,
        'outflows': 8.0,
        'reflows_in': 0.0,
        'reflows_out': 0.0,
        'use': 1.0,
        'variable_cashflow': -8.0,
        'fixed_cashflow': 0.0},
 'D1': {'name': 'D1',
        'class': 'Node',
        'origin': False,
        'destination': True,
        'inflows': 8.0,
        'outflows': 0,
        'reflows_in': 0.0,
        'reflows_out': 0.0,
        'use': 1.0,
        'variable_cashflow': 0.0,
        'fixed_cashflow': 0.0},
 'F1_W1': {'name': 'F1_W1',
           'class': 'Flow',
           'reflow': False,
           'start': 'F1',
           'end': 'W1',
           'flow': 0.0,
           'use': 1.0,
           'variable_cashflow': -0.0,
           'fixed_cashflow': 0.0},
 'F2_W1': {'name': 'F2_W1',
           'class': 'Flow',
           'reflow': False,
           'start': 'F2',
           'end': 'W1',
           'flow': 8.0,
           'use': 1.0,
           'variable_cashflow': -8.0,
           'fixed_cashflow': 0.0},
 'W1_D1': {'name': 'W1_D1',
           'class': 'Flow',
           'reflow': False,
           'start': 'W1',
           'end': 'D1',
           'flow': 8.0,
           'use': 1.0,
           'variable_cashflow': -8.0,
           'fixed_cashflow': 0.0}}

Testing

Docker:

  • docker build . --tag scoptimize_docker_test
  • docker run scoptimize_docker_test bash ./test.sh

Local:

  • python3.11 -m virtualenv venv
  • source venv/bin/activate
  • pip install -e .
  • ./test.sh

Metadata

Release files for scoptimize 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scoptimize 1.0.1
File Size Uploaded
scoptimize-1.0.1.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scoptimize 1.0.1
File Interpreter ABI Platform
scoptimize-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / scoptimize-1.0.1.tar.gz

Download URL scoptimize-1.0.1.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bbf6fb2b79723377d8c42a21be87daa840a0b62b9e7be89f9f64b6b15c722591
BLAKE2b-256 checksum
How to use checksums
fa420601683c67bc59bea5db7d54eb925456f364f488d4ca51b8be11b46a2994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / scoptimize-1.0.1-py3-none-any.whl

Download URL scoptimize-1.0.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbafda14c414596d9f5cc5794e2c841dee9cd5d3388a622e22242a6e8de6a56e
BLAKE2b-256 checksum
How to use checksums
814dab849075a35d3fe569a48362590e2d40d5ecf08814c5e3c853c3dba651ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.6

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page