rmp-route-optimizer 0.1.0

High-performance route optimization library for waste collection and logistics using Eulerian circuit algorithms
Documentation
//! Core types for route optimization

use serde::{Deserialize, Serialize};

/// A geographic node (location) in the routing graph
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Node {
    /// Unique identifier for the node
    pub id: i64,
    /// Latitude in decimal degrees
    pub lat: f64,
    /// Longitude in decimal degrees
    pub lon: f64,
}

/// Pickup side constraint for waste collection
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum PickupSide {
    /// Pickup on left side of street
    Left,
    /// Pickup on right side of street
    Right,
    /// Pickup on either side
    Either,
}

/// An edge (road segment) in the routing graph
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Edge {
    /// Source node ID
    pub from: i64,
    /// Destination node ID
    pub to: i64,
    /// Edge cost (distance, time, etc.)
    pub cost: f64,
    /// Whether this is a one-way edge
    pub oneway: bool,
    /// Pickup side constraint
    pub side: PickupSide,
}

/// Result of Eulerian circuit optimization
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EulerianCircuit {
    /// Ordered sequence of node IDs forming the circuit
    pub nodes: Vec<i64>,
    /// Edges traversed in the circuit
    pub edges: Vec<Edge>,
    /// Total cost of the circuit
    pub total_cost: f64,
    /// Number of edges added to make graph Eulerian
    pub augmenting_edges: usize,
}

impl Node {
    /// Create a new node
    pub fn new(id: i64, lat: f64, lon: f64) -> Self {
        Self { id, lat, lon }
    }
}

impl Edge {
    /// Create a new edge
    pub fn new(from: i64, to: i64, cost: f64, oneway: bool, side: PickupSide) -> Self {
        Self {
            from,
            to,
            cost,
            oneway,
            side,
        }
    }
}