<< lib/advantage/integration/SLVerticalIntegration.sleela SLeeLa Standard Library Definition. Definition: Vertical integration through capitalism/retail -- an ordered vertical stack of compartment tiers, recursively composable. >> #sleela 3.0 material; artifact; pure; gasoline; < The top-level model. VERTICAL INTEGRATION stacks tiers of a value chain from > < upstream (tier 0, raw/supply) to downstream (last tier, retail/sale). Each > < tier is a SLCompartment, so a tier can itself be a nested-model holding its > < own lower stack (recursion). The model aggregates capacity, utilization, > < relevance, and a SYSTEM SOPHISTICATION score over the whole recursive tree. > < > < Mainly a vertical arrangement: tier i feeds tier i+1 downstream. The straight > < onion model, engineering bays, trial compartments, newton median trays, and > < plain holders are all attached as compartments (or children of compartments), > < each contributing its own capacitive space, meaning and relevance. > class SLVerticalIntegration { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10545; String metaAuthor = "Kiro Agent"; String metaDate = "2026-11-08"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; < metaScienceRating: maturity/robustness on a 1..10 scale > String metaBirthDate = "2026-11-08"; int metaScienceRating = 8; << metaNationalSchedule: vertical integration is a classical industrial- organization concept (Coase, "The Nature of the Firm", 1937); academic, not a statute. >> String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } String name; SLIntegrationKind cat; < the vertical stack, index 0 = most upstream > SLCompartment[] tiers; int tierCount; int tierCap; void configure(String nm) { name = nm; cat = new SLIntegrationKind(); tierCap = 32; tiers = new SLCompartment[tierCap]; tierCount = 0; } String getName() { return name; } SLIntegrationKind catalog() { return cat; } int getTierCount() { return tierCount; } < Append a tier downstream. Returns its tier index (0 = most upstream). > int addTier(SLCompartment tier) { if (tierCount >= tierCap) { return 0 - 1; } tiers[tierCount] = tier; int idx = tierCount; tierCount = tierCount + 1; return idx; } < Build and append a tier of a given kind in one call; returns the tier. > SLCompartment addKind(String label, int kind) { SLCompartment t = new SLCompartment(); t.configure(label, kind, cat); addTier(t); return t; } SLCompartment tierAt(int i) { if (i < 0) { return null; } if (i >= tierCount) { return null; } return tiers[i]; } < ---- Vertical flow: push units from upstream tier i to downstream i+1 ---- > < Moves up to `amount` used units out of tier i and stores them in tier i+1, > < limited by what tier i holds and what tier i+1 can accept. Returns moved. > int flowDownstream(int i, int amount) { if (i < 0) { return 0; } if (i + 1 >= tierCount) { return 0; } SLCompartment up = tiers[i]; SLCompartment down = tiers[i + 1]; int take = amount; int have = up.getUsed(); if (take > have) { take = have; } int room = down.free(); if (take > room) { take = room; } if (take < 0) { take = 0; } up.release(take); down.store(take); return take; } < Run one full upstream->downstream sweep moving `amount` per hop. Returns > < the units delivered into the most downstream (retail) tier. > int runChain(int amount) { int delivered = 0; int i = 0; while (i + 1 < tierCount) { int moved = flowDownstream(i, amount); if (i + 1 == tierCount - 1) { delivered = delivered + moved; } i = i + 1; } return delivered; } < ---- Aggregates over the whole recursive tree ---- > int totalCompartments() { int sum = 0; int i = 0; while (i < tierCount) { SLCompartment t = tiers[i]; sum = sum + t.subtreeSize(); i = i + 1; } return sum; } int totalCapacity() { int sum = 0; int i = 0; while (i < tierCount) { SLCompartment t = tiers[i]; sum = sum + t.totalCapacity(); i = i + 1; } return sum; } int totalUsed() { int sum = 0; int i = 0; while (i < tierCount) { SLCompartment t = tiers[i]; sum = sum + t.totalUsed(); i = i + 1; } return sum; } int totalRelevance() { int sum = 0; int i = 0; while (i < tierCount) { SLCompartment t = tiers[i]; sum = sum + t.totalRelevance(); i = i + 1; } return sum; } < Maximum recursion depth across all tiers (how deep the nesting goes). > int maxDepth() { int best = 0; int i = 0; while (i < tierCount) { SLCompartment t = tiers[i]; int d = t.depth(); if (d > best) { best = d; } i = i + 1; } return best; } << System sophistication score: rewards breadth (compartments), depth (recursive nesting), and relevance density. A single rolled-up integer so two designs can be compared. sophistication = totalCompartments + 3*maxDepth + totalRelevance/4. >> int sophistication() { return totalCompartments() + 3 * maxDepth() + totalRelevance() / 4; } < Utilization percentage of the whole tree (0 if no capacity). > int utilization() { int capv = totalCapacity(); if (capv <= 0) { return 0; } return totalUsed() * 100 / capv; } String describe() { return "vertical-integration '" + name + "': tiers=" + tierCount + " compartments=" + totalCompartments() + " maxDepth=" + maxDepth() + " capacity=" + totalCapacity() + " relevance=" + totalRelevance() + " sophistication=" + sophistication(); } < Report this model through an output emitter (terminal / commonrails / > < socket / silent); the emitter and its sink decide the destination. > void emitThrough(SLAdvantageEmitter em) { em.report("vertical-integration", describe()); } }