diff --git a/examples/bank_reserves/BankReservesModel_Data.csv b/examples/bank_reserves/BankReservesModel_Data.csv deleted file mode 100644 index f9596ef9..00000000 --- a/examples/bank_reserves/BankReservesModel_Data.csv +++ /dev/null @@ -1,251 +0,0 @@ -,RunId,iteration,Step,init_people,rich_threshold,reserve_percent,Rich,Poor,Middle Class,Savings,Wallets,Money,Loans,AgentID,Wealth -0,0,0,1000,25,5,5,11,5,7,251,0,251,173,1,2 -1,0,0,1000,25,5,5,11,5,7,251,0,251,173,2,44 -2,0,0,1000,25,5,5,11,5,7,251,0,251,173,3,-22 -3,0,0,1000,25,5,5,11,5,7,251,0,251,173,4,-10 -4,0,0,1000,25,5,5,11,5,7,251,0,251,173,5,8 -5,0,0,1000,25,5,5,11,5,7,251,0,251,173,6,17 -6,0,0,1000,25,5,5,11,5,7,251,0,251,173,7,5 -7,0,0,1000,25,5,5,11,5,7,251,0,251,173,8,1 -8,0,0,1000,25,5,5,11,5,7,251,0,251,173,9,2 -9,0,0,1000,25,5,5,11,5,7,251,0,251,173,10,51 -10,0,0,1000,25,5,5,11,5,7,251,0,251,173,11,14 -11,0,0,1000,25,5,5,11,5,7,251,0,251,173,12,-22 -12,0,0,1000,25,5,5,11,5,7,251,0,251,173,13,10 -13,0,0,1000,25,5,5,11,5,7,251,0,251,173,14,57 -14,0,0,1000,25,5,5,11,5,7,251,0,251,173,15,7 -15,0,0,1000,25,5,5,11,5,7,251,0,251,173,16,3 -16,0,0,1000,25,5,5,11,5,7,251,0,251,173,17,12 -17,0,0,1000,25,5,5,11,5,7,251,0,251,173,18,-64 -18,0,0,1000,25,5,5,11,5,7,251,0,251,173,19,-2 -19,0,0,1000,25,5,5,11,5,7,251,0,251,173,20,9 -20,0,0,1000,25,5,5,11,5,7,251,0,251,173,21,7 -21,0,0,1000,25,5,5,11,5,7,251,0,251,173,22,-1 -22,0,0,1000,25,5,5,11,5,7,251,0,251,173,23,-23 -23,0,0,1000,25,5,5,11,5,7,251,0,251,173,24,2 -24,0,0,1000,25,5,5,11,5,7,251,0,251,173,25,-29 -25,1,0,1000,25,10,5,12,8,3,422,5,427,251,1,38 -26,1,0,1000,25,10,5,12,8,3,422,5,427,251,2,30 -27,1,0,1000,25,10,5,12,8,3,422,5,427,251,3,-21 -28,1,0,1000,25,10,5,12,8,3,422,5,427,251,4,65 -29,1,0,1000,25,10,5,12,8,3,422,5,427,251,5,40 -30,1,0,1000,25,10,5,12,8,3,422,5,427,251,6,10 -31,1,0,1000,25,10,5,12,8,3,422,5,427,251,7,-12 -32,1,0,1000,25,10,5,12,8,3,422,5,427,251,8,8 -33,1,0,1000,25,10,5,12,8,3,422,5,427,251,9,30 -34,1,0,1000,25,10,5,12,8,3,422,5,427,251,10,20 -35,1,0,1000,25,10,5,12,8,3,422,5,427,251,11,-5 -36,1,0,1000,25,10,5,12,8,3,422,5,427,251,12,-38 -37,1,0,1000,25,10,5,12,8,3,422,5,427,251,13,-12 -38,1,0,1000,25,10,5,12,8,3,422,5,427,251,14,27 -39,1,0,1000,25,10,5,12,8,3,422,5,427,251,15,-29 -40,1,0,1000,25,10,5,12,8,3,422,5,427,251,16,6 -41,1,0,1000,25,10,5,12,8,3,422,5,427,251,17,-37 -42,1,0,1000,25,10,5,12,8,3,422,5,427,251,18,27 -43,1,0,1000,25,10,5,12,8,3,422,5,427,251,19,-38 -44,1,0,1000,25,10,5,12,8,3,422,5,427,251,20,-10 -45,1,0,1000,25,10,5,12,8,3,422,5,427,251,21,-49 -46,1,0,1000,25,10,5,12,8,3,422,5,427,251,22,37 -47,1,0,1000,25,10,5,12,8,3,422,5,427,251,23,35 -48,1,0,1000,25,10,5,12,8,3,422,5,427,251,24,37 -49,1,0,1000,25,10,5,12,8,3,422,5,427,251,25,12 -50,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,1,-81 -51,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,2,27 -52,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,3,-56 -53,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,4,53 -54,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,5,86 -55,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,6,77 -56,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,7,20 -57,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,8,-28 -58,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,9,51 -59,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,10,-72 -60,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,11,-96 -61,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,12,81 -62,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,13,-43 -63,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,14,66 -64,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,15,70 -65,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,16,7 -66,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,17,32 -67,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,18,21 -68,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,19,64 -69,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,20,-54 -70,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,21,11 -71,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,22,-30 -72,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,23,-21 -73,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,24,24 -74,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,25,-4 -75,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,26,-12 -76,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,27,-67 -77,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,28,53 -78,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,29,79 -79,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,30,-9 -80,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,31,-6 -81,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,32,-2 -82,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,33,45 -83,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,34,85 -84,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,35,23 -85,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,36,-32 -86,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,37,-36 -87,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,38,-75 -88,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,39,-67 -89,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,40,-44 -90,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,41,-13 -91,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,42,-53 -92,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,43,105 -93,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,44,20 -94,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,45,-77 -95,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,46,36 -96,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,47,-35 -97,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,48,-87 -98,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,49,-70 -99,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,50,98 -100,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,51,109 -101,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,52,-93 -102,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,53,-18 -103,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,54,72 -104,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,55,38 -105,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,56,-33 -106,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,57,43 -107,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,58,87 -108,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,59,-2 -109,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,60,29 -110,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,61,123 -111,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,62,-22 -112,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,63,47 -113,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,64,108 -114,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,65,-53 -115,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,66,-3 -116,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,67,-58 -117,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,68,-16 -118,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,69,-28 -119,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,70,41 -120,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,71,-60 -121,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,72,-69 -122,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,73,93 -123,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,74,9 -124,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,75,37 -125,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,76,-108 -126,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,77,-69 -127,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,78,75 -128,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,79,-11 -129,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,80,-18 -130,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,81,16 -131,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,82,-32 -132,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,83,12 -133,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,84,8 -134,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,85,25 -135,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,86,16 -136,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,87,-99 -137,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,88,-15 -138,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,89,33 -139,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,90,12 -140,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,91,43 -141,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,92,2 -142,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,93,-139 -143,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,94,25 -144,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,95,101 -145,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,96,78 -146,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,97,44 -147,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,98,3 -148,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,99,-44 -149,2,0,1000,100,5,5,50,42,8,2563,7,2570,2219,100,-59 -150,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,1,-22 -151,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,2,27 -152,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,3,60 -153,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,4,89 -154,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,5,11 -155,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,6,12 -156,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,7,-47 -157,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,8,60 -158,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,9,34 -159,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,10,2 -160,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,11,5 -161,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,12,-27 -162,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,13,-13 -163,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,14,105 -164,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,15,-63 -165,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,16,138 -166,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,17,65 -167,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,18,40 -168,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,19,-68 -169,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,20,39 -170,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,21,-27 -171,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,22,64 -172,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,23,50 -173,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,24,-86 -174,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,25,21 -175,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,26,42 -176,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,27,-2 -177,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,28,-124 -178,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,29,90 -179,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,30,-39 -180,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,31,-40 -181,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,32,21 -182,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,33,55 -183,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,34,60 -184,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,35,71 -185,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,36,-27 -186,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,37,66 -187,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,38,48 -188,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,39,-63 -189,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,40,74 -190,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,41,3 -191,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,42,13 -192,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,43,-20 -193,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,44,0 -194,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,45,-51 -195,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,46,45 -196,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,47,44 -197,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,48,-110 -198,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,49,-95 -199,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,50,-21 -200,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,51,-46 -201,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,52,-34 -202,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,53,31 -203,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,54,-42 -204,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,55,52 -205,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,56,39 -206,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,57,112 -207,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,58,39 -208,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,59,-57 -209,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,60,108 -210,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,61,-33 -211,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,62,28 -212,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,63,7 -213,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,64,33 -214,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,65,-22 -215,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,66,69 -216,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,67,-77 -217,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,68,-58 -218,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,69,19 -219,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,70,27 -220,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,71,-41 -221,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,72,63 -222,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,73,97 -223,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,74,60 -224,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,75,32 -225,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,76,36 -226,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,77,-48 -227,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,78,-47 -228,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,79,45 -229,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,80,-5 -230,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,81,-27 -231,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,82,13 -232,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,83,48 -233,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,84,-69 -234,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,85,-55 -235,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,86,-41 -236,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,87,-31 -237,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,88,-14 -238,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,89,-103 -239,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,90,-29 -240,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,91,64 -241,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,92,-74 -242,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,93,1 -243,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,94,-72 -244,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,95,57 -245,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,96,6 -246,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,97,-15 -247,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,98,-15 -248,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,99,-46 -249,3,0,1000,100,10,5,49,42,9,2598,33,2631,2046,100,58 diff --git a/examples/boltzmann_wealth_model_experimental/model.py b/examples/boltzmann_wealth_model_experimental/model.py deleted file mode 100644 index 0dd39404..00000000 --- a/examples/boltzmann_wealth_model_experimental/model.py +++ /dev/null @@ -1,69 +0,0 @@ -import mesa - - -def compute_gini(model): - agent_wealths = [agent.wealth for agent in model.agents] - x = sorted(agent_wealths) - N = model.num_agents - B = sum(xi * (N - i) for i, xi in enumerate(x)) / (N * sum(x)) - return 1 + (1 / N) - 2 * B - - -class BoltzmannWealthModel(mesa.Model): - """A simple model of an economy where agents exchange currency at random. - - All the agents begin with one unit of currency, and each time step can give - a unit of currency to another agent. Note how, over time, this produces a - highly skewed distribution of wealth. - """ - - def __init__(self, N=100, width=10, height=10): - super().__init__() - self.num_agents = N - self.grid = mesa.experimental.cell_space.OrthogonalMooreGrid( - (width, height), torus=True, random=self.random - ) - - self.datacollector = mesa.DataCollector( - model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"} - ) - # Create agents - for _ in range(self.num_agents): - agent = MoneyAgent(self) - - # Add the agent to a random grid cell - x = self.random.randrange(width) - y = self.random.randrange(height) - agent.move_to(self.grid[(x, y)]) - - self.running = True - self.datacollector.collect(self) - - def step(self): - self.agents.shuffle().do("step") - # collect data - self.datacollector.collect(self) - - def run_model(self, n): - for i in range(n): - self.step() - - -class MoneyAgent(mesa.experimental.cell_space.CellAgent): - """An agent with fixed initial wealth.""" - - def __init__(self, model): - super().__init__(model) - self.wealth = 1 - - def give_money(self): - cellmates = [agent for agent in self.cell.agents if agent is not self] - if len(cellmates) > 0: - other = self.random.choice(cellmates) - other.wealth += 1 - self.wealth -= 1 - - def step(self): - self.cell = self.cell.neighborhood.select_random_cell() - if self.wealth > 0: - self.give_money() diff --git a/examples/schelling_experimental/model.py b/examples/schelling_experimental/model.py deleted file mode 100644 index 862d8c0e..00000000 --- a/examples/schelling_experimental/model.py +++ /dev/null @@ -1,73 +0,0 @@ -import mesa -from mesa.experimental.cell_space import CellAgent, OrthogonalMooreGrid - - -class SchellingAgent(CellAgent): - """ - Schelling segregation agent - """ - - def __init__(self, model, agent_type): - """ - Create a new Schelling agent. - - Args: - agent_type: Indicator for the agent's type (minority=1, majority=0) - """ - super().__init__(model) - self.type = agent_type - - def step(self): - similar = 0 - for neighbor in self.cell.neighborhood.agents: - if neighbor.type == self.type: - similar += 1 - - # If unhappy, move: - if similar < self.model.homophily: - self.cell = self.model.grid.select_random_empty_cell() - else: - self.model.happy += 1 - - -class Schelling(mesa.Model): - """ - Model class for the Schelling segregation model. - """ - - def __init__(self, width=20, height=20, density=0.8, minority_pc=0.2, homophily=3): - super().__init__() - self.width = width - self.height = height - self.homophily = homophily - - self.grid = OrthogonalMooreGrid((width, height), torus=True) - - self.happy = 0 - self.datacollector = mesa.DataCollector( - {"happy": "happy"}, # Model-level count of happy agents - ) - - # Set up agents - # We use a grid iterator that returns - # the coordinates of a cell as well as - # its contents. (coord_iter) - for cell in self.grid.all_cells: - if self.random.random() < density: - agent_type = 1 if self.random.random() < minority_pc else 0 - agent = SchellingAgent(self, agent_type) - agent.cell = cell - - self.datacollector.collect(self) - - def step(self): - """ - Run one step of the model. If All agents are happy, halt the model. - """ - self.happy = 0 # Reset counter of happy agents - self.agents.shuffle_do("step") - # collect data - self.datacollector.collect(self) - - if self.happy == len(self.agents): - self.running = False