📄 wealthmodel.java
字号:
NumAgents = num; } public int getMaxInitialWealth() { return MaxInitialWealth; } public void setMaxInitialWealth(int maxInitWealth) { MaxInitialWealth = maxInitWealth; } public int getMinInitialWealth() { return MinInitialWealth; } public void setMinInitialWealth(int minInitWealth) { MinInitialWealth = minInitWealth; } public boolean getROI() { return ROI; } public void setROI(boolean newROI) { ROI = newROI; } public boolean getBoth() { return Both; } public void setBoth(boolean newBoth) { Both = newBoth; } public double getMinWealth() { return MinWealth; } public void setMinWealth(double newMinWealth) { MinWealth = newMinWealth; } public boolean getRandomWalk() { return RandomWalk; } public void setRandomWalk(boolean newRandomWalk) { RandomWalk = newRandomWalk; } public boolean getSmarter() { return Smarter; } public void setSmarter(boolean newSmarter) { Smarter = newSmarter; } public int getSmarterNum() { return SmarterNum; } public void setSmarterNum(int newSmarterNum) { SmarterNum = newSmarterNum; } public boolean getDeathTax() { return DeathTax; } public void setDeathTax(boolean newDeathTax) { DeathTax = newDeathTax; } public boolean getMoving() { return Moving; } public void setMoving(boolean newMoving) { Moving = newMoving; } public boolean getSync() { return Sync; } public void setSync(boolean newSync) { Sync = newSync; } public boolean getSyncRegion() { return SyncRegion; } public void setSyncRegion(boolean newSyncRegion) { SyncRegion = newSyncRegion; } public double getSyncLatency() { return SyncLatency; } public void setSyncLatency(double newSyncLatency) { SyncLatency = newSyncLatency; } public int getSyncMax() { return SyncMax; } public void setSyncMax(int newSyncMax) { SyncMax = newSyncMax; } public int getNumLogLogBins() { return NumLogLogBins; } public void setNumLogLogBins(int newNumLogLogBins) { NumLogLogBins = newNumLogLogBins; } public int getNumPlainBins() { return NumPlainBins; } public void setNumPlainBins(int newNumPlainBins) { NumPlainBins = newNumPlainBins; } public double getPlainPlotXMax() { return PlainPlotXMax; } public void setPlainPlotXMax(double newPlainPlotXMax) { PlainPlotXMax = newPlainPlotXMax; } public double getPlainPlotYMax() { return PlainPlotYMax; } public void setPlainPlotYMax(double newPlainPlotYMax) { PlainPlotYMax = newPlainPlotYMax; } public boolean getPlotLogLog() { return PlotLogLog; } public void setPlotLogLog(boolean newPlotLogLog) { PlotLogLog = newPlotLogLog; } public boolean getPlotPlain() { return PlotPlain; } public void setPlotPlain(boolean newPlotPlain) { PlotPlain = newPlotPlain; } public boolean getViewStats() { return ViewStats; } public void setViewStats(boolean newViewStats) { ViewStats = newViewStats; } public boolean getViewAvg() { return ViewAvg; } public void setViewAvg(boolean newViewAvg) { ViewAvg = newViewAvg; } public boolean getViewStDev() { return ViewStDev; } public void setViewStDev(boolean newViewStDev) { ViewStDev = newViewStDev; } public boolean getViewStDAvg() { return ViewStDAvg; } public void setViewStDAvg(boolean newViewStDAvg) { ViewStDAvg = newViewStDAvg; } public boolean getWriteStats() { return WriteStats; } public void setWriteStats(boolean newWriteStats) { WriteStats = newWriteStats; } public int getMaxAge() { return MaxAge; } public void setMaxAge(int newMaxAge) { MaxAge = newMaxAge; } public int getTaxPCT() { return TaxPCT; } public void setTaxPCT(int newTaxPCT) { TaxPCT = newTaxPCT; } public double getROIMean() { return ROIMean; } public void setROIMean(double newROIMean) { ROIMean = newROIMean; } public double getROIStdDev() { return ROIStdDev; } public void setROIStdDev(double newROIStdDev) { ROIStdDev = newROIStdDev; } public boolean getViewPowerLawExp() { return ViewPowerLawExp; } public void setViewPowerLawExp(boolean newViewPowerLawExp) { ViewPowerLawExp = newViewPowerLawExp; } public int getRichMinPct() { return RichMinPct; } public void setRichMinPct(int newRichMinPct) { RichMinPct = newRichMinPct; } public boolean getViewEntropy() { return ViewEntropy; } public void setentropyBin(int newentropyBin) { entropyBin = newentropyBin; } public int getentropyBin() { return entropyBin; } public void setViewEntropy(boolean newViewEntropy) { ViewEntropy = newViewEntropy; } public String getBehaviour() { return behaviour; } public void setBehaviour(String behaviour) { this.behaviour = behaviour; } public String[] getInitParam() { String[] params = {"NumAgents", "Behaviour", "Moving", "DeathTax", "TaxPCT", "MaxAge", "MaxInitialWealth", "MinInitialWealth", "MinWealth", "NumLogLogBins", "NumPlainBins", "PlainPlotXMax", "PlainPlotYMax", "PlotLogLog", "PlotPlain", "ROIMean", "ROIStdDev", "Smarter", "SmarterNum", "SyncLatency", "SyncMax", "SyncRegion", "ViewAvg", "ViewStDAvg", "ViewStDev", "ViewStats", "ViewPowerLawExp", "RichMinPct", "ViewEntropy", "entropyBin", "WriteStats" }; return params; } // Every model must have begin() and setup() methods (required for implementing // the SimModel inteface). // begin() should intialize the model for the start of a run. Consequently, // the build* methods are called here, and any displays are displayed. build() // is called whenever the start button (or the step button if the run has // not yet started) is clicked. public void begin() { buildModel(); buildDisplay(); buildSchedule(); Exchange = false; Both = false; ROI = false; RandomWalk = false; Sync = false; step = 0; if (behaviour == "Exchange") { Exchange = true; setViewPowerLawExp(false); } if (behaviour == "Both") { Both = true; ROI = true; Exchange = true; } if (behaviour == "ROI") ROI = true; if (behaviour == "RandomWalk") { RandomWalk = true; setViewPowerLawExp(false); } if (behaviour == "Sync") { Sync = true; setPlotLogLog(false); setPlotPlain(false); setViewPowerLawExp(false); setViewAvg(false); setViewStDAvg(false); setViewStDev(false); setViewStats(false); setViewEntropy(false); } dsurf.display(); bar.display(); if (ViewPowerLawExp) powerlawGraph.display(); if (ViewEntropy) entropyGraph.display(); if (ViewStats || ViewAvg || ViewStDev || ViewStDAvg) statsGraph.display(); if (PlotLogLog) { logLogPlot.display(); logLogPlot.addLegend(1, "log(1-cumul.)", java.awt.Color.green); logLogPlot.addLegend(2, "log:log plot", java.awt.Color.blue); } if (PlotPlain) { plainPlot.display(); plainPlot.setConnected(false); }// if (DeathTax)// barAge.display(); } // setup() prepares the model for another run. Called whenver the setup button // is clicked. Setup should set any objects that are created over the course // of the run to null, and dispose of any DisplaySurfaces or graphs. While // not strictly necessary this should some prevent memory leaks and calling // System.gc() helps too. The initial parameters should be set to whatever // defaults the user wants to see initially. public void setup() { schedule = null; agentList = new ArrayList(); birthList = new Vector(); space = null; agentGrid = null; reaperQueue = new Vector(); Both = false; ROI = false; RandomWalk = false; Sync = false; if (behaviour == "Both") Both = true; if (behaviour == "ROI") ROI = true; if (behaviour == "RandomWalk") RandomWalk = true; if (behaviour == "Sync") Sync = true; if (dsurf != null) dsurf.dispose(); dsurf = null; if (powerlawGraph != null) powerlawGraph.dispose(); powerlawGraph = null; if (entropyGraph != null) entropyGraph.dispose(); entropyGraph = null; if (statsGraph != null) statsGraph.dispose(); statsGraph = null; if (ViewStDAvg) for (int i = 0; i < MAvgRange; i++) StDAvg[i] = 0.0; if (bar != null) bar.dispose(); bar = null; if (logLogPlot != null) logLogPlot.dispose(); logLogPlot = null; if (plainPlot != null) plainPlot.dispose(); plainPlot = null; // if (barAge != null)// barAge.dispose();// barAge = null; System.gc(); // create a schedule with an interval of one. schedule = new Schedule(1); dsurf = new DisplaySurface(this, "Wealth Scape"); // By registering a DisplaySurface, you are allowing Repast to automate // some tasks on the displays surface, such as making movies or taking // snapshots. registerDisplaySurface("Wealth Scape", dsurf); // creates a dynamic histogram of the distribution of wealth over the // agents. bar = new OpenHistogram("Agent Wealth Distribution", 16, 0, this); this.registerMediaProducer("Hist", bar); // barAge = new OpenHistogram("Agent Age Distribution", 16, 0, this);// this.registerMediaProducer("Hist", barAge); // agent properties// numAgents = 1600;// maxInitialWealth = 100;// minInitialWealth = 100; } // a required method public Schedule getSchedule() { return schedule; } // a required method - displayed on the Controller toolbar. public String getName() { return "WealthScape"; } public static void main(String[] args) { SimInit init = new SimInit(); WealthModel model = new WealthModel(); init.loadModel(model, "", false); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -