Skip to main content

A priority-queue-driven crop supply monitoring engine.

Project description

🌟Polaris

A Structured Redistribution Engine for Crop Supply Monitoring and Agricultural Logistics

📖 Overview

POLARIS a Domain-specific supply-balancing framework is an agricultural logistics system built to monitor the supply conditions of various crops across Local Government Units (LGUs).

It uses:

  • Signed priority values (key > 0 = Oversupply | key < 0 = Undersupply)
  • Per-crop database tables in SQLite!
  • Per-Crop Priority Queues implemented using a DLL!
  • 2D Priority Structure Grouping PQs by crop type!
  • CLI control interface for adding, listing, and evaluating LGU Supply States!

POLARIS aims to support logistics balancing:

matching oversupplied regions with undersupplied regions efficiently for sustainable food distribution.

🚀 Key Features

🔹 Signed Priority System

POLARIS computes supply difference as:

priority = curr_supply - ideal_supply
  • Positive priority -> Oversupply
  • Negative priority -> Undersupply
  • Zero → Perfectly balanced supply

The Priority Queue System is max-based, so the largest shortage (most negative) gets paired up with the highest priority.

🔹 Per-Crop Architecture (Dynamic Tables)

Each crop automatically creates its own table inside the SQLite database:

rice(_lgu TEXT UNIQUE, key INTEGER)
corn(_lgu TEXT UNIQUE, key INTEGER)
onion(_lgu TEXT UNIQUE, key INTEGER)
...

This avoids cross-crop contamination and keeps the database clean and scalable.

🔹 2D Priority Queue Structure

POLARIS maintains:

"Rice": PQ_of_Rice
"Corn": PQ_of_Corn
"Onion": PQ_of_Onion
...

This acts like a 2D priority system, where each crop has its own queue sorted by imbalance severity. 🔹 Automatic Oversupply → Undersupply Matching

Because priorities are signed:

  • Most positive = largest oversupply
  • Most negative = largest undersupply
PQ[crop][0]    LGU with worst shortage
PQ[crop][-1]   LGU with worst oversupply

This enables logistics pairing:

Send oversupply  to undersupply region

🔹 SQLite Integration

Data persists through:

  • Crop-specific tables
  • UPSERT behavior (INSERT OR REPLACE)
  • Full or soft database flushing

Command Line Interface

Use POLARIS through simple commands:

Command Description
--add Add or update LGU crop supply
--list Show all PQs and DB tables
--cget Retrieve the most critical imbalance
--flush=true Clear all crop tables

🧮 Priority Calculation

Given:

curr_supply
ideal_supply

Priority = signed difference:

priority = curr_supply - ideal_supply

Examples:

Curr Ideal Difference(key) Meaning
500 300 +200 Oversupply
100 300 -200 Undersupply
200 200 0 Balanced

PQ Priority:

  • Largest positive -> biggest oversupply -> biggest priority
  • Most negative -> biggest shortage -> lowest priority (unless changed)

Installation

Clone the repository:

git clone https://github.com/dejely/Polaris.git
cd src

or

pip install Polaris

No Dependencies Needed.

Usage

➕ Add a new supply record

python main.py --add --lgu your_lgu --crop your_crop --curr 500 --ideal 300

📋 List all queues and database content

python main.py --list

Contributing

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

agripolaris-0.1.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agripolaris-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file agripolaris-0.1.0.tar.gz.

File metadata

  • Download URL: agripolaris-0.1.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agripolaris-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e715c38a507e4acfc7d5f488bc626473701daeca56ba486a2306d15155664c3
MD5 043a13b53c2e9a49e998f8ad79d38591
BLAKE2b-256 5dde483e62818e35ef9e503e727649a5a1df5a85f22a3735897a068e9989370e

See more details on using hashes here.

File details

Details for the file agripolaris-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agripolaris-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agripolaris-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1bd96094994afd6bfb04e3cacea366bc195b69de67a59a24e6aa9674e528fde4
MD5 4abd5fad58a620bbdba064fe5d805988
BLAKE2b-256 76f8e019e3b795d837ed3061d1c9e4f0bf61b0b2f9a380268dcf7726926e7c58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page