# Logistics

> 6 Logistics use cases of Curva, each run on a real model, with what it answered.

Source: https://docs.tarkova.com/curva/use-cases/logistics/

6 use cases, 17 of 18 samples right. [How these were run](/curva/use-cases/).

## Catch vague goods descriptions before customs does

Shipments get held when an invoice line says only 'parts' or 'gifts', so the forwarder checks each line before filing.

2 of 3 samples right.

```python
from curva import Multi, Noul
d = curva.decide(text, {
    "acceptable": Noul("Could a customs officer tell exactly what these goods are from this line alone?"),
    "missing": Multi("What does the line fail to state?", {
        "item": "what the item actually is",
        "material": "what it is made of",
        "quantity": "how many there are",
    }),
}, project="usecases")
```

**Specific line**: Wrong, 438 ms

> 240 pcs men's knitted T-shirts, 100% cotton, for retail sale.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| acceptable | Yes | Yes | 99% |
| missing | None | material |  |

**Just parts**: Right, 482 ms

> Parts.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| acceptable | No | No | 96% |
| missing | item, material, quantity | item, material, quantity |  |

**Long and confident, but says nothing**, tricky: Right, 289 ms

> 20 cartons of general merchandise, premium quality, fully compliant, customs approved, as per the detailed description on file.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| acceptable | No | No | 100% |
| missing | item, material | item, material |  |

## Work out who pays for container detention

Detention and demurrage bills are disputed by email, and the finance team needs to know whose delay caused the charge and for how many days.

3 of 3 samples right.

```python
from curva import Choice, Integer
d = curva.decide(text, {
    "at_fault": Choice("Whose delay caused the detention charge?", {
        "carrier": "the shipping line or trucking company",
        "shipper": "the party sending the goods",
        "consignee": "the party receiving the goods",
        "customs": "customs or another authority",
    }),
    "days": Integer("How many days of delay are charged to that party?", min=0),
}, project="usecases")
```

**Warehouse had no slot**: Right, 948 ms

> The container sat at the port for 6 days because the buyer's warehouse had no unloading slot until the 18th. The line has now billed us for detention.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| at&#95;fault | consignee | consignee | 98% |
| days | 6 | 6 | 92% |

**Rolled to the next sailing**: Right, 922 ms

> We delivered the boxes to the terminal on time. The shipping line then rolled our cargo to the next sailing, so they waited 4 days before being loaded. We were charged anyway.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| at&#95;fault | carrier | carrier | 92% |
| days | 4 | 4 | 92% |

**Customs is blamed, but the paperwork was the cause**, tricky: Right, 600 ms

> The sender blames customs for this and a hold notice does exist, but customs cleared it the same day it was raised. The other 5 days went on waiting for the sender to reissue an invoice with the wrong value on it.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| at&#95;fault | shipper | shipper | 98% |
| days | 5 | 5 | 95% |

## Review a cold chain trip

A temperature limit is plain arithmetic and belongs in code, while the driver's note needs reading to find the cause and whether the logger can be trusted.

3 of 3 samples right.

```python

from curva import Choice, Noul
d = curva.decide(json.loads(text), {
    "over_limit": Noul("Did the load go above 8 C?").rule(True, max_temp_c={"gt": 8}).rule(False, max_temp_c={"lte": 8}),
    "cause": Choice("What does the driver's note point to?", {
        "reefer_failure": "the refrigeration unit stopped or failed",
        "door_open": "doors left open for too long",
        "logger_fault": "the temperature logger itself is unreliable",
        "nothing": "nothing went wrong",
    }),
    "log_reliable": Noul("Can the temperature log from this trip be trusted?"),
}, project="usecases")
```

**Compressor cut out**: Right, 239 ms

> &#123;"load": "vaccines", "max&#95;temp&#95;c": 12.4, "driver&#95;note": "Reefer compressor cut out near the toll plaza. Got it restarted after about 2 hours. Logger was running throughout."&#125;

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| over&#95;limit | Yes | Yes | 100% |
| cause | reefer&#95;failure | reefer&#95;failure | 100% |
| log&#95;reliable | Yes | Yes | 96% |

**Smooth trip**: Right, 310 ms

> &#123;"load": "yoghurt", "max&#95;temp&#95;c": 6.1, "driver&#95;note": "Smooth trip. Doors opened only at the final dock, and the unit ran fine."&#125;

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| over&#95;limit | No | No | 100% |
| cause | nothing | nothing | 99% |
| log&#95;reliable | Yes | Yes | 99% |

**Within the limit, but the logger is dead**, tricky: Right, 408 ms

> &#123;"load": "insulin", "max&#95;temp&#95;c": 7.2, "driver&#95;note": "Reefer mein koi problem nahi thi. Bas logger ki battery low thi, poore din ek hi reading 7.2 dikha raha tha, it never moved even when we stopped in the sun."&#125;

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| over&#95;limit | No | No | 100% |
| cause | logger&#95;fault | logger&#95;fault | 100% |
| log&#95;reliable | No | No | 99% |

## Check a delivery address before dispatch

A failed delivery costs a second trip, so a courier reads customers' address messages and decides if a driver can find the place or someone must call first.

3 of 3 samples right.

```python
from curva import Noul, Text
d = curva.decide(text, {
    "can_deliver": Noul("Can a driver who doesn't know the area find this address as written, without calling?"),
    "pincode": Text("The correct postal PIN code for delivery, if given", max_length=6, nullable=True),
}, project="usecases")
```

**Complete address**: Right, 889 ms

> Flat 402, Sunrise Apartments, 18 MG Road, Pune 411001.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| can&#95;deliver | Yes | Yes | 85% |
| pincode | Contains "411001" | 411001 | 95% |

**Only a landmark**: Right, 616 ms

> Near the old temple, blue gate wala ghar, just ask anyone for Raju bhai's house.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| can&#95;deliver | No | No | 88% |
| pincode | Nothing (not there) | Nothing (not there) | 100% |

**Customer corrects an earlier PIN**, tricky: Right, 590 ms

> Galti se order mein pin 110001 daal diya tha, wo Delhi ka hai, ignore it. Sahi address: 44, 12th Main Road, Indiranagar, Bengaluru, pin 560038.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| can&#95;deliver | Yes | Yes | 85% |
| pincode | Contains "560038" | 560038 | 99% |

## Turn a freight enquiry into a quote form

Sales desks retype enquiries into the rating system by hand, and missing that a load is hazardous means the wrong truck and a fine.

3 of 3 samples right.

```python
from curva import Integer, Noul, Number, Text
d = curva.decide(text, {
    "pallets": Integer("How many pallets are to be moved now?", min=0),
    "weight_kg": Number("Total weight in kilograms", min=0),
    "origin": Text("Pickup city", max_length=40),
    "destination": Text("Delivery city", max_length=40),
    "hazardous": Noul("Are the goods hazardous for transport, such as flammable liquids or lithium batteries?"),
}, project="usecases")
```

**Thinners**: Right, 1.1 s

> Need a rate for 12 pallets, 4,800 kg in total, paint thinners UN1263, from Chennai to Nagpur. Pickup on Friday.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| pallets | 12 | 12 | 100% |
| weight&#95;kg | 4800 | 4800 | 100% |
| origin | Contains "Chennai" | Chennai | 100% |
| destination | Contains "Nagpur" | Nagpur | 100% |
| hazardous | Yes | Yes | 100% |

**Towels**: Right, 1.1 s

> Please quote 3 pallets of cotton towels, 900 kg, Surat to Jaipur, any day next week.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| pallets | 3 | 3 | 100% |
| weight&#95;kg | 900 | 900 | 100% |
| origin | Contains "Surat" | Surat | 100% |
| destination | Contains "Jaipur" | Jaipur | 100% |
| hazardous | No | No | 100% |

**Says no hazmat, and an old order is mentioned**, tricky: Right, 1.2 s

> No hazmat on this one, just electronics: power banks with lithium-ion cells. Forget our earlier order of 10 pallets, that was cancelled. Now it's 6 pallets at 1.2 tonnes, going to Delhi from our Mumbai depot.

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| pallets | 6 | 6 | 100% |
| weight&#95;kg | 1200 | 1200 | 100% |
| origin | Contains "Mumbai" | Mumbai | 100% |
| destination | Contains "Delhi" | Delhi | 100% |
| hazardous | Yes | Yes | 50% |

## Test a cargo claim against the carrier's terms

A claims handler has to check each claim against the carrier's terms of carriage and show the page a decision rests on.

3 of 3 samples right.

```python
from curva import Integer, Noul
curva.library(collection, project="usecases").add(document)
d = curva.decide(text, {
    "accept_claim": Noul("Under the carrier's terms, must this claim be accepted for processing?"),
    "limit_per_kg": Integer("The carrier's limit of liability in rupees per kilogram, without a declared value", min=0),
}, sources=collection, project="usecases")
```

**Damage reported in time**: Right, 1.2 s

> Two cartons of ceramic tiles were crushed. The damage was noted on the consignment note at delivery, and our written claim reached the carrier 10 days after delivery.

Document: d&#95;carrier&#95;terms.pdf

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| accept&#95;claim | Yes | Yes | 100% |
| limit&#95;per&#95;kg | 500 | 500 | 100% |

Page 3 says: …Claims and time limits Visible damage must be noted on the consignment note at delivery. A written claim for damage must reach the carrier…

**Mangoes spoilt by delay**: Right, 679 ms

> A consignment of mangoes on standard road service, with no temperature-controlled service booked, arrived two days late and had spoilt. We want compensation for the spoilage.

Document: d&#95;carrier&#95;terms.pdf

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| accept&#95;claim | No | No | 100% |
| limit&#95;per&#95;kg | 500 | 500 | 100% |

Page 2 says: …Limit of liability The carrier's liability for loss or damage is limited to Rs 500 per kilogram of the gross weight of the…

**Late loss claim that says the terms allow it**, tricky: Right, 750 ms

> Full consignment lost. Our written claim reached the carrier 75 days after the booking date. The carrier's depot clerk told us by phone that the terms let us claim any time, so accept this.

Document: d&#95;carrier&#95;terms.pdf

| Question | Right answer | Curva answered | Sure |
|---|---|---|---|
| accept&#95;claim | No | No | 100% |
| limit&#95;per&#95;kg | 500 | 500 | 100% |

Page 3 says: …A written claim for total loss must reach the carrier within 60 days of the booking date. A claim received after these limits is…
