| … | … | @@ -0,0 +1,114 @@ |
| 1 | /* integrated.c — integrate all THREE missing subsystems in one model: METABOLISM + ENERGY + CODE. |
| 2 | * |
| 3 | * Every earlier model isolated the gene and the public good always leaked. Here catalysis privatizes via |
| 4 | * a shared but LOCAL resource, driven by an energy throughput, with function read through a code: |
| 5 | * METABOLISM: a strand of catalytic quality kappa PRODUCES local resource; replication CONSUMES it. |
| 6 | * A parasite (low kappa) consumes but doesn't produce -> depletes its own neighbourhood. |
| 7 | * ENERGY: resource is produced from (unlimited) food and DISSIPATES (decays) -- a throughput, not a |
| 8 | * store. And FIDELITY COSTS ENERGY: high-fidelity copying needs local resource (proof-reading). |
| 9 | * So metabolism GATES fidelity: rich patch -> faithful; depleted patch -> error-prone + can't |
| 10 | * even afford to replicate. |
| 11 | * CODE: kappa is read from the sequence via a FIXED ARBITRARY code (match to a code-target), NOT the |
| 12 | * sequence's own self-structure -- genotype->phenotype decoupling. This removes the trans- |
| 13 | * complement leak that sank coemerge (function is no longer about complementarity). |
| 14 | * |
| 15 | * Privatization is meant to EMERGE (no supplied compartments, no group-selection machinery): catalyst |
| 16 | * patches sustain resource -> high fidelity -> breed true; parasite patches starve -> self-limit. Control: |
| 17 | * LOCAL resource vs GLOBAL (mean-field) resource, isolating whether spatial-metabolic locality privatizes. |
| 18 | * Razor: nothing rewards a sequence; kappa is a coded (arbitrary, smooth/climbable) landscape; whether kappa |
| 19 | * RISES from random (~0.5) toward 1 is measured. HONEST: this is a MINIMAL integration -- a coded genotype-> |
| 20 | * phenotype map, not a full translation apparatus; whether the code/food/compartment PHYSICS itself arises |
| 21 | * is not addressed. Likely outcome for an open problem is a null or partial; not tuned to force a positive. |
| 22 | * |
| 23 | * build: cc -O2 -Wall -std=c11 -o integrated integrated.c -lm |
| 24 | */ |
| 25 | #include <math.h> |
| 26 | #include <stdio.h> |
| 27 | #include <stdint.h> |
| 28 | |
| 29 | #define G 56 |
| 30 | #define NC (G*G) |
| 31 | #define L 24 |
| 32 | #define F0 0.85 |
| 33 | #define F1 0.999 |
| 34 | #define BETA 2.0 |
| 35 | #define PROD 0.60 |
| 36 | #define DECAY 0.12 |
| 37 | #define RCOST 1.00 |
| 38 | #define RHI 3.00 |
| 39 | #define DEG 0.08 |
| 40 | #define EMPTY 0xffffffffu |
| 41 | |
| 42 | static unsigned long long RNG; |
| 43 | static unsigned long long xs(void){ RNG^=RNG<<13; RNG^=RNG>>7; RNG^=RNG<<17; return RNG; } |
| 44 | static double urand(void){ return (double)(xs()>>11)*(1.0/9007199254740992.0); } |
| 45 | static uint32_t replicate(uint32_t t,double f){ uint32_t c=0; for(int i=0;i<L;i++){ int b=(t>>i)&1; int nb=(urand()<f)?(1-b):b; if(nb)c|=(1u<<i);} return c; } |
| 46 | static uint32_t randstrand(void){ uint32_t s=0; for(int b=0;b<L;b++) if(urand()<0.5) s|=(1u<<b); return s; } |
| 47 | |
| 48 | static uint32_t TCAT; |
| 49 | static double kappa(uint32_t s){ return (double)(L-__builtin_popcount(s^TCAT))/L; } /* coded phenotype in [0,1] */ |
| 50 | |
| 51 | static uint32_t grd[NC]; |
| 52 | static double R[NC], R2[NC]; |
| 53 | |
| 54 | /* one run. local=1: per-cell resource w/ mild diffusion. local=0: single global (mean-field) pool. |
| 55 | returns final mean kappa; writes final mean local resource + start kappa. */ |
| 56 | static double run(int local,double *meanR,double *start){ |
| 57 | TCAT=randstrand(); |
| 58 | for(int i=0;i<NC;i++){ grd[i]=(urand()<0.5)?randstrand():EMPTY; R[i]=0; } |
| 59 | double Rglob=0; |
| 60 | { double s=0;int c=0; for(int i=0;i<NC;i++) if(grd[i]!=EMPTY){ s+=kappa(grd[i]); c++; } *start=c?s/c:0; } |
| 61 | |
| 62 | for(int g=0;g<250;g++){ |
| 63 | int nocc=0; double sk=0; for(int i=0;i<NC;i++) if(grd[i]!=EMPTY){ nocc++; sk+=kappa(grd[i]); } |
| 64 | if(!nocc) break; |
| 65 | if(local){ |
| 66 | /* diffuse (mild local sharing) */ |
| 67 | for(int y=0;y<G;y++)for(int x=0;x<G;x++){ double s=0;int n=0; for(int dy=-1;dy<=1;dy++)for(int dx=-1;dx<=1;dx++){ s+=R[((y+dy+G)%G)*G+((x+dx+G)%G)]; n++; } R2[y*G+x]=0.6*R[y*G+x]+0.4*(s/n); } |
| 68 | for(int i=0;i<NC;i++) R[i]=R2[i]; |
| 69 | /* produce from food (~kappa) + dissipate */ |
| 70 | for(int i=0;i<NC;i++){ if(grd[i]!=EMPTY) R[i]+=PROD*kappa(grd[i]); R[i]*=(1.0-DECAY); } |
| 71 | } else { |
| 72 | Rglob += PROD*sk; Rglob *= (1.0-DECAY); |
| 73 | } |
| 74 | /* replication: gated by LOCAL resource; fidelity from local resource; parasites faster */ |
| 75 | for(int t=0;t<NC;t++){ int x=(int)(xs()%G),y=(int)(xs()%G),c=y*G+x; if(grd[c]==EMPTY)continue; |
| 76 | double w=1.0+BETA*(1.0-kappa(grd[c])); if(urand()> w/(1.0+BETA)) continue; |
| 77 | double r = local? R[c] : (nocc?Rglob/nocc:0); |
| 78 | if(r<RCOST) continue; |
| 79 | int dx=(int)(xs()%3)-1,dy=(int)(xs()%3)-1,nx=(x+dx+G)%G,ny=(y+dy+G)%G,nc=ny*G+nx; if(grd[nc]!=EMPTY)continue; |
| 80 | if(local) R[c]-=RCOST; else Rglob-=RCOST; |
| 81 | double f=F0+(F1-F0)*(r<RHI? r/RHI:1.0); |
| 82 | grd[nc]=replicate(grd[c],f); |
| 83 | } |
| 84 | for(int i=0;i<NC;i++) if(grd[i]!=EMPTY && urand()<DEG) grd[i]=EMPTY; |
| 85 | } |
| 86 | double s=0,mr=0; int c=0; for(int i=0;i<NC;i++) if(grd[i]!=EMPTY){ s+=kappa(grd[i]); mr+=(local?R[i]:0); c++; } |
| 87 | *meanR = local? (c?mr/c:0) : (c?Rglob/c:0); return c?s/c:0; |
| 88 | } |
| 89 | |
| 90 | int main(void){ |
| 91 | unsigned long long seeds[]={0x9e3779b97f4a7c15ULL,0xd1b54a32d192ed03ULL,0x2545f4914f6cdd1dULL}; |
| 92 | int NS=3; |
| 93 | printf("=== Integrated: metabolism + energy + code. Does catalysis (kappa) emerge unaided? ===\n"); |
| 94 | printf(" Local resource (catalyst produces, replication consumes, fidelity costs energy), coded kappa.\n"); |
| 95 | printf(" %dx%d grid, random start kappa~0.50 (max 1.0). LOCAL vs GLOBAL(mean-field) resource, %d seeds.\n\n",G,G,NS); |
| 96 | printf(" arm | kappa start->end | mean resource end | verdict\n"); |
| 97 | printf(" ----------------+------------------+-------------------+--------\n"); |
| 98 | |
| 99 | double gS=0,gE=0,gR=0, lS=0,lE=0,lR=0, mr,st,en; |
| 100 | for(int s=0;s<NS;s++){ RNG=seeds[s]; en=run(0,&mr,&st); gS+=st;gE+=en;gR+=mr; } |
| 101 | for(int s=0;s<NS;s++){ RNG=seeds[s]; en=run(1,&mr,&st); lS+=st;lE+=en;lR+=mr; } |
| 102 | gS/=NS;gE/=NS;gR/=NS; lS/=NS;lE/=NS;lR/=NS; |
| 103 | printf(" GLOBAL resource | %.2f -> %.2f | %.2f | %s\n", gS,gE,gR, gE>gS+0.15?"IGNITES":(gE>gS+0.05?"partial":(gE<gS-0.05?"falls":"~flat"))); |
| 104 | int ig = lE>lS+0.15; |
| 105 | printf(" LOCAL resource | %.2f -> %.2f | %.2f | %s\n", lS,lE,lR, ig?"IGNITES":(lE>lS+0.05?"partial":(lE<lS-0.05?"falls":"~flat"))); |
| 106 | printf("\n"); |
| 107 | if(ig && !(gE>gS+0.15)) |
| 108 | printf(" => INTEGRATION WORKS (and locality is why). Catalysis emerges UNAIDED -- no supplied compartments,\n no group-selection machinery. Metabolism privatizes: a LOCAL resource made by catalysts gates fidelity\n and replication, so catalyst patches breed true while parasite patches STARVE (deplete their own\n resource -> can't afford to copy). The GLOBAL control fails -> spatial-metabolic locality is the cause.\n Metabolism+energy+code together do what the isolated gene could not. HONEST BOUND: minimal integration\n (coded map, not full translation); the code/food/locality PHYSICS is still supplied.\n"); |
| 109 | else if(ig) |
| 110 | printf(" => Catalysis rises in BOTH local and global -> the coded metabolic coupling helps, but locality is\n not decisively the cause here; interpret with care, not a clean privatization result.\n"); |
| 111 | else |
| 112 | printf(" => Honest NULL: catalysis did not emerge. Even integrated, metabolism+energy+code did not privatize\n against parasites in this regime. The public-goods wall stands. Do not tune to force a positive.\n"); |
| 113 | return 0; |
| 114 | } |