Use Cases

Architecting a Logistics Rule Engine for Carrier Optimization and Routing

Decouple business logic from your WMS/ERP. Learn how to implement a deterministic, 4-phase decision flow for carrier calculation using a REST API architecture.

Architecting a Logistics Rule Engine for Carrier Optimization and Routing hero image

Key Takeaway

Separation of Concerns

Moving logistics logic into a rule engine allows for parametric configuration, enabling business analysts to manage operational rules while technical teams focus on core system performance.

Deterministic Multi-Phase Flow

A structured flow-covering data standardization, segmentation, multi-carrier calculation, and strategic selection-guarantees reproducible and auditable results.

API-First Integration

Modern rule engines utilize REST APIs to provide real-time, stateless decisioning that easily integrates with legacy ERPs, modern WMS, and cloud-native TMS platforms.

From Logistics Rigidity to Rule-Driven Execution

In the previous article, How to Overcome Logistics Rigidity , we explored why hardcoded logic and slow development cycles limit logistics teams’ ability to adapt.

To overcome this, you need a system that can evaluate carriers in real time, calculate precise and auditable costs, and respond instantly to operational changes.

This is where a rule engine comes in.

Instead of embedding logic into code, it structures decision-making into a flexible, deterministic system that can be adjusted without development cycles.

In this article, we’ll show how such a system works in practice and how to design a multi-phase decision flow for carrier optimization and route pricing.

👉 If you haven’t read Part 1 yet, start here: How to Overcome Logistics Rigidity


The Role of Rule Engines in Logistics Decision-Making

A decision rule engine allows logistics teams to configure operational logic parametrically instead of embedding it directly into code.

This approach enables business users such as logistics analysts, transportation planners, and pricing specialists to control key decisions, including:

  • carrier eligibility
  • route assignment
  • cost calculation
  • pricing rules
  • optimization scenarios

all without requiring software development.

The rule engine structures the delivery calculation as a decision flow. Rules evaluate shipment attributes, segment packages, determine applicable carriers, and calculate transportation costs in a clear and controlled way.

This design supports all transportation phases, including last-mile delivery, mid-mile transport, linehaul, and cross-border logistics.

Because the logic is parameterized, the system can continuously adapt to changes in pricing, routes, and operational constraints without requiring code changes.

Core Calculation Process

The delivery calculation process is executed as a rule-driven decision flow, orchestrated by the rule engine. The flow itself is visually defined in the rule engine designer as a process overview, where the main stages of the calculation are organized into logical blocks.

While the process overview presents the logical sequence of the delivery calculation, the operational logic inside each block is configured through parametrization tables and rule definitions. These configuration tables allow business users to maintain calculation logic without modifying system code.

Each stage in the process therefore consists of two layers:

  • Process flow layer – visual flow of calculation steps in the rule engine
  • Decision and configuration layer – parameterization tables and rule definitions defining the detailed logic


1.png

Process flow, decision and configuration layers

This structure ensures that the logistics calculation remains both transparent and maintainable, while allowing flexible adjustments to business rules, carrier data, and pricing models.

The core calculation flow consists of the following phases.

Start Faster with Pre-Built Logistics Templates

The decision flow described below can be implemented from scratch, but you don’t have to start with a blank page.

You can use pre-built logistics templates to accelerate:

  • carrier segmentation
  • pricing rule configuration
  • delivery cost calculation

Browse logistics templates or try the solution directly in the application .

Phase 1: Shipment Validation and Data Checks

Initial validation ensures consistency and standardization of shipment data.

2.png

Shipment Validation and Data Checks

Key checks include:

Unit and Dimension Validation

Shipment requests may originate from multiple operational systems using different measurement standards.

The rule engine:

  • validates incoming units
  • converts them into standardized measurement systems
  • ensures consistency across calculations

Example supported unit systems:

  • Metric: centimeters, meters, cubic meters (m³), kilograms
  • Imperial: inches, feet, cubic feet (ft³), pounds

Sorting Validation

Sorting logic may be required depending on:

  • warehouse preparation rules
  • carrier loading requirements
  • route structure

The rule engine determines whether packages must be sorted and calculates optimal orientation for loading and unloading operations.

This information is later used to improve vehicle loading efficiency and operational handling speed.

Phase 2: Package and Carrier Segmentation

After the input validation stage, the rule engine performs segmentation of the shipment and carrier resources.

Segmentation prepares structured information for pricing calculations, handling logic, and operational constraints.


3.png

Segmentation of the shipment and carrier resources

The segmentation logic is also driven by parametrization tables, allowing business users to maintain classification rules.

Package Segmentation

Packages are categorized according to defined criteria such as dimensions, weight, fragility, insurance requirements, product category, etc.

These definitions are configured through package segmentation tables in the rule engine.

Users can define segmentation thresholds and classification rules using configuration interfaces such as:

  • drag-and-drop rule definitions
  • dimension threshold tables
  • conditional decision tables


4.png

Package segmentation table

For example, package categories may include segments - standard parcel, oversized parcel, fragile shipment, high-value goods.

Each category may later influence - carrier eligibility, insurance requirements, price calculation models, handling rules

Carrier Segmentation

Carrier segmentation determines which carrier types are capable of transporting the shipment.

The rule engine evaluates shipment characteristics against carrier capability tables, which define - vehicle capacity limits, supported delivery types, operational regions, service level agreements.

Examples of delivery request categories include - Sprinter, Linehaul, Last Mile, Middle Mile, Dedicated transport, White Glove, Freight LTL, Freight FTL


5.png

Carrier segmentation table

Carrier vehicle types may include - Car, Small Van, Box Van, Heavy Duty Truck, Large Truck, Box Truck, Chassis Truck, 20-ft container, 40-ft container.

All carrier attributes are maintained within carrier definition tables in the rule engine. These tables can be populated manually by logistics managers, through synchronization with internal databases, via external carrier services through REST APIs.

This architecture ensures that carrier eligibility and pricing inputs remain dynamically configurable.

Phase 3: Calculation and Evaluation of Delivery Options

Once shipment validation and segmentation are completed, the rule engine evaluates all feasible delivery alternatives.


6.png

Decision layer of the logistics cost optimization process

This phase represents the core decision layer of the logistics cost optimization process.

Instead of computing a single carrier option, the rule engine constructs a candidate set of feasible delivery scenarios and calculates cost and operational parameters for each option.

The calculation process consists of several logical stages.

Carrier Eligibility Evaluation

The rule engine first evaluates carrier eligibility against the shipment request.

Rules verify compatibility between shipment type, delivery type, package segmentation, carrier capacity constraints, regulatory or contractual restrictions.

Only carriers that fully satisfy these criteria are allowed to proceed into the cost calculation stage. This step prevents invalid or operationally impossible transport assignments.

Carrier Type and Company Selection

For each eligible carrier type, the rule engine identifies all available carrier companies capable of executing the transport.

This may involve evaluating carrier service regions, available vehicle categories, delivery SLAs, carrier contractual conditions

Because carrier data may originate from multiple sources, the rule engine may combine internal carrier databases, external carrier APIs, contract pricing tables

This creates a comprehensive pool of delivery options.

Route and Segment Attribute Assignment

Each potential delivery option is enriched with route-specific attributes.

Examples include route distance, toll zones, hub events, cross-docking points, delivery sequence rules, handling requirements.

The rule engine can also incorporate event-based pricing, where costs occur at specific points in the route, such as hub handling fees, cross-dock operations, regional surcharges, fuel adjustments.

These events may be defined dynamically in the rule configuration.

Carrier Price Calculation

After route attributes are assigned, the rule engine performs detailed cost calculation.

Pricing models include price per package, price per weight, price per volume, distance-based pricing, event-based cost components, minimum route costs, tiered pricing structures.

For each candidate delivery option, the rule engine calculates:

  • Total carrier cost
  • Price per package
  • Capacity utilization
  • Transport feasibility

Because all calculations run inside a deterministic rule framework, the results remain fully auditable and reproducible with their own versions, which is critical for financial reconciliation and carrier invoice verification.

The result of this phase is a ranked set of delivery options, each with a complete cost and operational profile.

Phase 4: Automated Carrier Selection and Decision Strategies

Once all delivery alternatives are calculated, the rule engine proceeds to the decision layer, where the final delivery option is prepared or automatically selected.


7.png

Carrier selection and decision strategies

This stage is critical because operational contexts may require different decision strategies depending on the planning horizon and system integration.

Decision Strategy Configuration

The rule engine allows logistics operators to define multiple selection strategies, such as - Lowest cost carrier, Best cost-to-delivery-time ratio, Preferred carrier priority, Capacity availability, Operational reliability scores, SLA compliance.

These strategies can be configured as decision rules that evaluate calculated delivery options and determine the optimal choice. Because the logic is parameterized, companies can easily modify decision strategies without altering system code.

Operational vs Planning Mode

The calculation process can support different operational contexts:

Real-Time Operational Selection:

  • For real-time shipment processing, the rule engine may automatically select the best delivery option and send the final carrier assignment directly to operational systems.
  • Typical integration targets include WMS, ERP, Transport Management Systems (TMS), Carrier booking systems
  • The selected option triggers the carrier order creation and simultaneously prepares the data required for self-invoicing or cost tracking.

Bulk Planning and Simulation:

  • In planning scenarios, the rule engine may produce multiple delivery options without selecting one automatically.
  • Examples include next-day operational planning, weekly route optimization, carrier A/B testing, cost simulation scenarios.
  • In this case, planners can review and evaluate different options before confirming carrier assignments.

Multi-Source Input Integration

Shipment requests can originate from various sources - WMS / ERP systems, planning systems, operational dashboards, Excel datasets, external partner systems

All sources can interact with the rule engine via REST API interfaces, enabling automated recalculation even from structured files such as XLS.

Financial Output and Invoice Preparation

Because the rule engine performs deterministic cost calculations, the resulting data can directly support carrier invoice validation, internal cost allocation, automated self-billing, profitability analysis.

Versioned pricing rules ensure that historical calculations remain reproducible even after pricing updates.

Examples of I/O for Rest API

Example Shipment Request

The entire process begins with a ShipmentRequest delivered through a REST API payload.

{"deliveryRequest": "LastMile",
"deliveryType": "SmallVan",
"deliveryCurrency": "USD",
"distance": 53.8,
"distanceUnit": "metric",
"deliveryDimensionUnit": "metric",
"deliveryWeightUnit": "metric",
"pkgs": [
{"length": 15, "width": 7, "height": 9, "amount": 100, "weight": 0.3},
{"length": 26, "width": 10, "height": 18, "amount": 700, "weight": 0.5},
{"length": 43, "width": 10, "height": 10, "amount": 10, "weight": 1.5},
{"length": 12, "width": 6, "height": 9, "amount": 100, "weight": 2.5}]}


Example Calculation Output

The response returns standardized cost and operational metrics.

{"totalCost": 1284.8,
"Package": {"packageCategory": "Standard Parcels","maxWeight": 2.5,"noPkgsTotal": 910,
"pkgsMatrix": [[15, 9, 7],[26, 18, 10],[43, 10, 10],[12, 9, 6]]},
"Cargo": {"utilizationRate": 1.449,"volumeCalc": 3.4783,"weightCalc": 645,"sorting": "ascending"},
"action": "ChangeToFit",
"units": "metric",
"currency": "USD"}


The output includes:

  • final carrier cost
  • package segmentation
  • cargo utilization metrics
  • sorting instructions
  • standardized measurement units

These results can directly feed warehouse sorters, carrier dispatch systems, invoice preparation processes, cost analytics platforms, XLS sheets with analysis.

Conclusion

In modern logistics networks, carrier selection and route cost calculation are strategic operational processes that require both accuracy and flexibility.

Embedding decision logic directly into ERP or WMS systems often creates rigidity and slows operational adaptation. A rule engine architecture offers a more scalable approach by separating business decision logic from system code.

This enables logistics companies to:

  • rapidly adapt carrier strategies
  • run continuous route optimization experiments
  • maintain cost transparency
  • automate carrier selection
  • support large-scale operational planning

By empowering business teams to manage decision rules directly, logistics organizations can achieve higher operational agility, improved cost control, and more scalable delivery networks.

Milan Havelka

Milan Havelka

Advisor