Skip to main content

SCx

PyPI version License: MIT

MIT's Supply Chain Micromaster (SCx) Python Package

Documentation

Technical documentation can be found here.

Examples

Setup

Cloud Setup (Google Colab)

  • You can access google colab here
  • Create a new notebook
  • Install the scx package by adding the following to a new code cell at the top of your notebook and running it:
    • pip install scx

Local Setup

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

Recommended (but Optional) -> Expand this section to setup and activate a virtual environment.
  • Install (or upgrade) virtualenv:
python3 -m pip install --upgrade virtualenv
  • Create your virtualenv named venv:
python3 -m virtualenv venv
  • Activate your virtual environment
    • On Unix (Mac or Linux):
    source venv/bin/activate
    
    • On Windows:
    venv\\scripts\\activate
    
pip install scx

Optimization Getting Started

See all of the optimization examples here.

Basic Usage

from scx.optimize import Model

Simple Optimization

from scx.optimize import Model

# Create variables
product_1_amt = Model.variable(name="product_1", lowBound=0)
product_2_amt = Model.variable(name="product_2", lowBound=0)

# Initialize the model
my_model = Model(name="Generic_Problem", sense='maximize')

# Add the Objective Fn
my_model.add_objective(
    fn = (product_1_amt*1)+(product_2_amt*1)
)

# Add Constraints
my_model.add_constraint(
    name = 'input_1_constraint',
    fn = product_1_amt*1+product_2_amt*2 <= 100
)
my_model.add_constraint(
    name = 'input_2_constraint',
    fn = product_1_amt*3+product_2_amt*1 <= 200
)

# Solve the model
my_model.solve(get_duals=True, get_slacks=True)

# Show the outputs
# NOTE: outputs can be fetched directly as a dictionary with `my_model.get_outputs()`
my_model.show_outputs()

Outputs:

{'duals': {'input_1_constraint': 0.4, 'input_2_constraint': 0.2},
 'objective': 80.0,
 'slacks': {'input_1_constraint': -0.0, 'input_2_constraint': -0.0},
 'status': 'Optimal',
 'variables': {'product_1': 60.0, 'product_2': 20.0}}

Database Getting Started

See all of the database examples here

Basic Usage

from scx.database import Database
# Specify the S3 path to the data
data_folder = 's3://scx-dev/databases/supermarket/'
# Create the database
db = Database(f'''
    CREATE TABLE Customers AS SELECT * FROM read_parquet('{data_folder}customers.parquet');
''')
# Show the database Schema
db.show_info()

# Query the database
db.query("SELECT * FROM Customers LIMIT 5")

Metadata

Release files for scx 1.3.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 scx 1.3.1
File Size Uploaded Provenance Actions
scx-1.3.1.tar.gz 9.7 kB Without provenance Details for scx-1.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 20.2 kB

Release files / scx-1.3.1.tar.gz

Download URL scx-1.3.1.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2abddb51ef33bac8b566a595c83063a08c1a66c1168b165c09415933bef48710
BLAKE2b-256 checksum
How to use checksums
f9c1f9e90382da3083dcfb5dc1227f038766ae96feda516ba5de11bebbe02a69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / scx-1.3.1-py3-none-any.whl

Download URL scx-1.3.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e8c633c662659767baaf6ce8aa56c6a61a6536e43209505a78932e5c0d61a70
BLAKE2b-256 checksum
How to use checksums
1f59743e5341fd9ed1cdd9a1a9fe10f390da92dccdaf2d68fa916bdc76a31314
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for scx 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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