Skip to main content
ClaudeWave
Skill209 repo starsupdated 7d ago

algo-sc-eoq

Calculate Economic Order Quantity to minimize total inventory cost (ordering + holding). Use this skill when the user needs to determine optimal order size, balance ordering frequency against storage costs, or set reorder points — even if they say 'how much to order', 'optimal batch size', or 'inventory cost minimization'.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/asgard-ai-platform/skills /tmp/algo-sc-eoq && cp -r /tmp/algo-sc-eoq/algo-sc-eoq ~/.claude/skills/algo-sc-eoq
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

# Economic Order Quantity (EOQ)

## Overview

EOQ determines the order quantity that minimizes total inventory cost = ordering cost + holding cost. Formula: EOQ = √(2DS/H) where D=annual demand, S=ordering cost per order, H=holding cost per unit per year. Assumes constant demand and instantaneous replenishment.

## When to Use

**Trigger conditions:**
- Setting standard order quantities for inventory replenishment
- Balancing ordering frequency against warehousing costs
- Baseline calculation before applying safety stock adjustments

**When NOT to use:**
- When demand is highly uncertain (use newsvendor model)
- When products are perishable with short shelf life
- When quantity discounts change the cost structure significantly

## Algorithm

```
IRON LAW: EOQ Assumes CONSTANT, KNOWN Demand
If demand is variable or uncertain, EOQ gives the wrong answer.
Real-world application: use EOQ as a starting point, then add
safety stock for demand variability and lead time uncertainty.
Total cost curve is flat near EOQ — ±20% from optimal Q changes
total cost by only ~2%.
```

### Phase 1: Input Validation
Determine: D (annual demand in units), S (fixed cost per order), H (holding cost per unit per year = unit cost × holding rate, typically 20-30% of unit value).
**Gate:** All costs positive, demand estimate reasonable.

### Phase 2: Core Algorithm
1. EOQ = √(2 × D × S / H)
2. Number of orders per year = D / EOQ
3. Reorder point = d × L (daily demand × lead time in days)
4. Total annual cost = (D/Q × S) + (Q/2 × H) at Q = EOQ

### Phase 3: Verification
Check: ordering cost component ≈ holding cost component (they're equal at EOQ). Total cost is at minimum.
**Gate:** Ordering cost ≈ holding cost (±5%).

### Phase 4: Output
Return EOQ with cost breakdown and reorder point.

## Output Format

```json
{
  "eoq": 500,
  "orders_per_year": 20,
  "reorder_point": 150,
  "annual_cost": {"ordering": 2000, "holding": 2000, "total": 4000},
  "metadata": {"demand": 10000, "order_cost": 100, "holding_cost": 4.0}
}
```

## Examples

### Sample I/O
**Input:** D=10,000 units/year, S=$100/order, H=$4/unit/year
**Expected:** EOQ = √(2×10000×100/4) = √500000 = 707 units

### Edge Cases
| Input | Expected | Why |
|-------|----------|-----|
| Very high S, low H | Large EOQ, few orders | Minimize expensive ordering |
| Very low S, high H | Small EOQ, frequent orders | Minimize expensive holding |
| D = 0 | EOQ = 0, no ordering | No demand, no orders needed |

## Gotchas

- **Holding cost underestimation**: H should include: capital cost, storage, insurance, obsolescence, handling. Companies often only count warehouse rent, understating true H.
- **Flat cost curve**: Total cost is insensitive near EOQ. Rounding EOQ to a convenient number (full pallet, container) costs very little.
- **Quantity discounts**: Price breaks at certain quantities may make it cheaper to order MORE than EOQ. Compare total cost at EOQ vs discount breakpoints.
- **Lead time variability**: EOQ doesn't address when to order, only how much. Add safety stock: SS = z × σ_demand × √(lead time).
- **Multi-item coordination**: When multiple items share ordering costs (same supplier), use joint replenishment models, not individual EOQs.

## Scripts

| Script | Description | Usage |
|--------|-------------|-------|
| `scripts/eoq.py` | Compute Economic Order Quantity and cost breakdown | `python scripts/eoq.py --help` |

Run `python scripts/eoq.py --verify` to execute built-in sanity tests.

## References

- For EOQ with quantity discounts, see `references/eoq-discounts.md`
- For safety stock calculation, see algo-sc-safety-stock
algo-ad-biddingSkill

Implement and select ad bidding strategies from manual CPC to automated target-CPA and target-ROAS. Use this skill when the user needs to choose a bidding strategy, set up automated bidding, or optimize bid parameters — even if they say 'what bidding strategy should I use', 'target CPA setup', or 'smart bidding configuration'.

algo-ad-budgetSkill

Optimize advertising budget allocation across campaigns using marginal returns analysis. Use this skill when the user needs to distribute budget across multiple campaigns, optimize spend pacing, or maximize overall ROAS under budget constraints — even if they say 'how to split my ad budget', 'campaign budget optimization', or 'diminishing returns on ad spend'.

algo-ad-ctrSkill

Build CTR prediction models for estimating ad click-through rates from features. Use this skill when the user needs to predict click probability, build an ad ranking model, or evaluate ad creative performance — even if they say 'predict click rate', 'ad relevance scoring', or 'which ad will get more clicks'.

algo-ad-gspSkill

Implement Generalized Second Price auction for ad slot allocation and pricing. Use this skill when the user needs to understand search ad auctions, compute ad positions and costs-per-click, or analyze bidding dynamics — even if they say 'how does Google Ads auction work', 'ad rank calculation', or 'second price auction for ads'.

algo-ad-vcgSkill

Implement VCG mechanism for incentive-compatible ad slot allocation with truthful bidding. Use this skill when the user needs to design a truthful auction mechanism, compute externality-based payments, or understand why platforms may prefer GSP over VCG — even if they say 'truthful auction design', 'VCG payments', or 'incentive-compatible mechanism'.

algo-blockchain-basicsSkill

Explain blockchain fundamentals including distributed ledger architecture, consensus mechanisms, and block structure. Use this skill when the user needs to understand blockchain concepts, evaluate whether blockchain fits a use case, or design a blockchain-based solution — even if they say 'how does blockchain work', 'do I need blockchain', or 'distributed ledger'.

algo-blockchain-smart-contractSkill

Design and implement smart contracts as self-executing programmatic agreements on blockchain. Use this skill when the user needs to build automated on-chain logic, evaluate smart contract security, or design tokenized business rules — even if they say 'smart contract development', 'automated agreement', or 'on-chain logic'.

algo-ecom-bm25Skill

Implement BM25 ranking function for e-commerce product search relevance scoring. Use this skill when the user needs to build a text-based product search engine, improve search result relevance, or replace basic TF-IDF with a more robust ranking function — even if they say 'product search ranking', 'search relevance', or 'BM25 implementation'.