WealthModel - RePast netstart

(Last update September, 2015)

 

This is an example of a stand-alone network accessible RePast model. It was built using RePast 3.1 and the NetBeans system on a Mac. You can give it a try by clicking on the .jnlp file here. (Note: in order to run, it will download a 1.6 megabyte file . . .). (It will ask you if you want to trust me -- I guess that will be up to you :-)
Note: Java is much more finicky these days . . . you probably will need to use some "Java sophistication" to get things to run . . . sorry about that :-)

WealthModel.jnlp

It is possible you will have to find the file and fire it up with a Java Web Start application (e.g., Safari under MacOSX just downloads WealthModel.jnlp to my Desktop . . .)

The .jar file (1.6 megabytes) (which can also serve as a stand-alone version of the model that can run natively on your machine) is here:

WealthModel_signed.jar

The Java source is here:

WealthModel Java source



There are two basic "wealth" models here (with an extra bonus of a "synchronization" model :-)

The first wealth model is a very simple (!!!) "exchange" model. Each agent starts with (essentially) the same amount of wealth (by default, about 100 "dollars"). Then, during each time step, each agent chooses another agent at random, and gives that agent a dollar. The only other rule is that agents are not allowed to go totally broke or into debt -- i.e., if an agent has only one dollar, they just sit and wait for someone else to give them a dollar. Then they proceed as before.

The second wealth model is a very simple (!!!) "investment" model. Again, each agent starts with (essentially) the same amount of wealth. Then, during each time step, each agent "invests" their entire wealth, and makes a "return" r on their investment, which is normally distributed around RoiM (Return on investment Mean -- detrended . . .) with standard deviation RoiSD (Return on investment Standard Deviation). Their new wealth is just:

wealth <- wealth * exp(r)

where r is their individual return on investment rate for this time step.

That's it for the wealth models. (With the "Both" option, each agent does both things each time step . . .)

(Sometime I'll get around to writing about the "Sync" model . . .)


  // default and modifiable parameters of the model

private String behaviour = "Both"; // Behaviour of agents
public static boolean Exchange = false; // Do exchange model
public static boolean Both = false; // Combine exchange and investment economies
public static boolean DeathTax = false; // Implement "death tax"
public static int MaxAge = 1200; // Age for "death tax" (if turned on)
private int MaxInitialWealth = 110; // Maximum initial wealth for agents
private int MinInitialWealth = 90; // Minimum initial wealth for agents
public static double MinWealth = 1.0; // Minimum wealth
public static boolean Moving = false; // Do agents move (for exchange or "synch" models)
private static int NumAgents = 1500; // Total number of agents (must be <= 2500)
private static int NumLogLogBins = 30; // Number of bins for log:log plot
private static int NumPlainBins = 100; // Number of bins for plain plot
private static double PlainPlotXMax = 300.0;// Maximum X (wealth) plotted in plain plot (-1 = any)
private static double PlainPlotYMax = -1.0; // Maximum Y (P_i) plotted in plain plot (-1 = any)
private static boolean PlotLogLog = true; // Whether to display log:log plot
private static boolean PlotPlain = true; // Whether to display plain plot
public static boolean ROI = false; // Whether to do investment economy (only)
public static double ROIMean = 0.00; // Mean return on investment
public static double ROIStdDev = 0.05; // Standard deviation of normal dist. of return
public static boolean RandomWalk = false; // Whether to do individual random walk
public static boolean Smarter = false; // Are some agents smarter?
public static int SmarterNum = 50; // 1 in SmarterNum is smarter.
public static boolean Sync = false; // Whether to run the sync model instead
public static double SyncLatency = 3.0; // Latency in sync mode after "flash"
public static int SyncMax = 150; // Max value in sync model
public static double SyncIncrement = 0.925; // boost given by nearby flashers
public static boolean SyncRegion = true; // Do agents affect only nearbys or everybody (in sync)
public static int RegionSize = 8; // size of region for sync
public static int TaxPCT = 10; // Tax rate for death tax
public static boolean ViewPlots = true; // Whether to turn on all the graphs
private static boolean ViewAvg = true; // Whether to show average wealth of all agents
private static boolean ViewStDAvg = true; // Whether to show moving average of Std. Dev. of wealth of all agents
private static boolean ViewStDev = true; // Whether to show standard deviation of wealth of all agents
private static boolean ViewStats = true; // Whether to show average wealth of all agents
private static boolean WriteStats = false; // Whether to write stats out to a file on pause or stop
private static boolean ViewPowerLawExp = true; // Whether to show power law exponent
private static boolean ViewGiniPlot = true; // Whether to show Gini plot
private static boolean ViewGiniCoeff = true; // Whether to show Gini Coefficient
private static int NumGiniBins = 100; // Number of bins for Gini plot
private static int RichMinPct = 90; // Rich above what per cent . . .
private static boolean ViewEntropy = true; // Whether to show entropy
private static int entropyBin = 5; // size of bins for calculating entropy
private static boolean logEntropy = true; // scale entropy bins by logarithm . . .
private static int numLogEntropyBins = 50; // number of log-entropy bins . . .


Colors of the agents:
if (wealth > 250)
      Color = magenta;
    else if (wealth > 200)
      Color = pink;
    else if (wealth > 150)
      Color = red);
    else if (wealth > 12)
      Color = orange;
    else if (wealth > 100)
      Color = yellow;
    else if (wealth > 75)
      Color = cyan;
    else if (wealth > 50)
      Color = blue;
    else if (wealth > 30)
      Color = green;
    else if (wealth > 20)
      Color = lightGray;
    else if (wealth > 10)
      Color = gray;
    else if (wealth > 5)
      Color = darkGray;
    else
      Color = black;