<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.santafe.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Seoc</id>
	<title>Santa Fe Institute Events Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.santafe.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Seoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php/Special:Contributions/Seoc"/>
	<updated>2026-04-27T19:31:32Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3786</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3786"/>
		<updated>2006-06-22T22:42:37Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0622-1640)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0622-1640)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0622-1640)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(APBS:0618-2315)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3785</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3785"/>
		<updated>2006-06-22T22:42:10Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 19, 2006 18:20 by Jack&lt;br /&gt;
 * Modified June 22, 2006 00:16 by Andrew&lt;br /&gt;
 * Modified June 22, 2006 16:40 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
	// weight of current reputation in new opinion&lt;br /&gt;
	public double repWeight;&lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    //public int voteType;&lt;br /&gt;
&lt;br /&gt;
	// intVoteValue, the intrinsic value of an agent&#039;s vote&lt;br /&gt;
	// vote weight = intVoteValue + (1-intVoteValue)*reputation&lt;br /&gt;
	// now have continuous scale between democratic and meritocratic,&lt;br /&gt;
	// and also avoid divide by zero for zero rep agents voting.&lt;br /&gt;
	// 1 = democratic&lt;br /&gt;
	// 0 = complete meritocratic&lt;br /&gt;
	public double intVoteValue;&lt;br /&gt;
&lt;br /&gt;
		//public int opScheme; // opinion scheme: 1 = old, 2 = new (AS rep feedback)&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public double noiseSlope;&lt;br /&gt;
		&lt;br /&gt;
		public int numTopAgents = 5; // Andrew hacking TopRep calculation&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	//parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;iVV&amp;quot;, &amp;quot;intVoteValue&amp;quot;);&lt;br /&gt;
	//parametersMap.put( &amp;quot;oS&amp;quot;, &amp;quot;opScheme&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rW&amp;quot;, &amp;quot;repWeight&amp;quot;); // still not sure what this does...&lt;br /&gt;
	parametersMap.put( &amp;quot;nS&amp;quot;, &amp;quot;noiseSlope&amp;quot;);&lt;br /&gt;
        parametersMap.put( &amp;quot;nTA&amp;quot;, &amp;quot;numTopAgents&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &amp;quot;noiseSlope&amp;quot;,&lt;br /&gt;
					&amp;quot;numTopAgents&amp;quot;, // AS added for top agents param&lt;br /&gt;
					/*&amp;quot;opScheme&amp;quot;, // AS for new opinion scheme*/&lt;br /&gt;
					&amp;quot;repWeight&amp;quot;, // AS for new opinion scheme&lt;br /&gt;
					&amp;quot;intVoteValue&amp;quot;,&lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
	/*&lt;br /&gt;
    public void setVoteType(int i) {&lt;br /&gt;
	voteType = i;&lt;br /&gt;
	CustomNode.setVoteType(i);&lt;br /&gt;
    }&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
		*/&lt;br /&gt;
	public void setIntVoteValue(double i) {&lt;br /&gt;
		intVoteValue = i;&lt;br /&gt;
		CustomNode.setIntVoteValue(i);&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public double getIntVoteValue() {return intVoteValue;}&lt;br /&gt;
&lt;br /&gt;
		//public void setOpScheme(int i) {opScheme = i;}&lt;br /&gt;
		//public int getOpScheme() { return opScheme;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {&lt;br /&gt;
	histWeight = i;&lt;br /&gt;
	CustomNode.setHistWeight(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
		&lt;br /&gt;
		public void setRepWeight(double w) {&lt;br /&gt;
			repWeight = w;&lt;br /&gt;
			CustomNode.setRepWeight(w);&lt;br /&gt;
		}&lt;br /&gt;
		public double getRepWeight() {return repWeight;}&lt;br /&gt;
&lt;br /&gt;
    public void setNoiseSlope(double i) {&lt;br /&gt;
	noiseSlope = i;&lt;br /&gt;
	CustomNode.setNoiseSlope(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
		// AS added for top agents param&lt;br /&gt;
		public int getNumTopAgents() {return numTopAgents;}&lt;br /&gt;
		public void setNumTopAgents(int n) {numTopAgents = n;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setRepWeight(repWeight); // AS for new op scheme&lt;br /&gt;
	//CustomNode.setVoteType(voteType);&lt;br /&gt;
	CustomNode.setIntVoteValue(intVoteValue);&lt;br /&gt;
	CustomNode.setNoiseSlope(noiseSlope);&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1;&lt;br /&gt;
	pajekUpdateInterval    = 1000000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	//voteType = 0;&lt;br /&gt;
	intVoteValue = 1;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
	noiseSlope = 1;&lt;br /&gt;
	repWeight = 0;&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
			// AS added for top agents param&lt;br /&gt;
			numTopAgents = 5;&lt;br /&gt;
		&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
			/*if (opScheme == 2) { // new opinion scheme&lt;br /&gt;
				for(CustomNode node : agentList) { // that&#039;s syntax I don&#039;t know...&lt;br /&gt;
					node.voteAll2();&lt;br /&gt;
				}&lt;br /&gt;
				for(CustomNode node : agentList) {&lt;br /&gt;
					node.calcReputation();&lt;br /&gt;
				}&lt;br /&gt;
			} else {*/&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
		node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
 			//}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
		// AS: could be changed to just use numTopAgents directly, &lt;br /&gt;
		// but I&#039;m gonna change it at call time only--&lt;br /&gt;
		// lower impact if I fuck something up.&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = tempList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f %f %f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble(), calcTopRepSkills(numTopAgents),&lt;br /&gt;
			  calcRepSkillMatch());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time  topSkill  RepSkillMatch&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3784</id>
		<title>CustomNode.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3784"/>
		<updated>2006-06-22T22:41:55Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * CustomNode.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 2:41 PM&lt;br /&gt;
 * Modified on June 18, 2006, 13:55 by Jack&lt;br /&gt;
 * Modified June 22, 2006 00:16 by Andrew&lt;br /&gt;
 * Modified June 22, 2006 16:40 by Jack&lt;br /&gt;
 *&lt;br /&gt;
 * This class contains the parameters and methods&lt;br /&gt;
 *  for an agent acting on the network&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultDrawableNode lets us draw it in the GUI&lt;br /&gt;
// CustomProbeable lets us define which attributes appear when&lt;br /&gt;
//  probed in the GUI&lt;br /&gt;
public class CustomNode extends DefaultDrawableNode implements CustomProbeable {&lt;br /&gt;
    //***********************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // tracks next unique id&lt;br /&gt;
    public static int                   nextID = 0;      &lt;br /&gt;
    &lt;br /&gt;
    public static GUIModel              guiModel = null;&lt;br /&gt;
    public static RepMod           model;&lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    // public static int    voteType; &lt;br /&gt;
&lt;br /&gt;
	// intVoteValue, the intrinsic value of an agent&#039;s vote&lt;br /&gt;
	// vote weight = intVoteValue + (1-intVoteValue)*reputation&lt;br /&gt;
	// now have continuous scale between democratic and meritocratic,&lt;br /&gt;
	// and also avoid divide by zero for zero rep agents voting.&lt;br /&gt;
	// 1 = democratic&lt;br /&gt;
	// 0 = complete meritocratic&lt;br /&gt;
	public static double intVoteValue;&lt;br /&gt;
&lt;br /&gt;
    // the degree by which the historical opinion is weighted&lt;br /&gt;
    public static double histWeight;&lt;br /&gt;
		// weight of current reputation of focus when assigning new opinion&lt;br /&gt;
		public static double repWeight;     &lt;br /&gt;
&lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public static double noiseSlope;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //********************************8**&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
&lt;br /&gt;
    // Two colormaps are generated for color-coding the nodes in GUI&lt;br /&gt;
    public static ColorMap              centerColorMap;    &lt;br /&gt;
    public static ColorMap              edgeColorMap;&lt;br /&gt;
    public static final int             colorMapSize = 16;&lt;br /&gt;
    public static final int             colorMapMax = colorMapSize - 1;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    private int   id;                   // uniquely ids node&lt;br /&gt;
    public Color  myColor;              // used to draw color in GUI&lt;br /&gt;
    public String myPajekColor = &amp;quot;Red&amp;quot;; // color to appear in Pajek output&lt;br /&gt;
    public double reputation;              // current wealth or stored reputation&lt;br /&gt;
    public double skill;          // skill parameter&lt;br /&gt;
    //public int    numVotes;              // the number of vote rounds &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
       &lt;br /&gt;
&lt;br /&gt;
    //public double success;              // most recent success&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////&lt;br /&gt;
    // constructor&lt;br /&gt;
    // Inputs: NetworkDrawable drawable, to draw in GUI&lt;br /&gt;
    //         double skill, the skill parameter&lt;br /&gt;
    public CustomNode (NetworkDrawable drawable, double skill) {&lt;br /&gt;
	super(drawable);&lt;br /&gt;
	id = nextID++;              // set id and iterate to next&lt;br /&gt;
	this.skill = skill;&lt;br /&gt;
	reputation = 0.5;	            // Generalize.  Currently hard-coded&lt;br /&gt;
	if (guiModel != null)&lt;br /&gt;
	    setNodeEdgeColorFromSkill();&lt;br /&gt;
	//numVotes = 0;&lt;br /&gt;
	//success = 0;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getProbedProperties&lt;br /&gt;
    // Required to implement CustomProbeable&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: array of strings holding parameter names&lt;br /&gt;
    public String[] getProbedProperties(){&lt;br /&gt;
	return new String[] {&amp;quot;id&amp;quot;, &amp;quot;reputation&amp;quot;, &amp;quot;skill&amp;quot;};&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // (Can be) Called by main model to have nodes execute a single step&lt;br /&gt;
    public void step(){&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeColorFromReputation&lt;br /&gt;
    // Input:  maxReputation, the highest reputation from all agents&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node color to the colormap leval depending on reputation&lt;br /&gt;
    public void setNodeColorFromReputation(double maxReputation){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*(reputation)/ (maxReputation));&lt;br /&gt;
	this.setColor(centerColorMap.getColor(i));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeEdgeColorFromSkill&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node edge color to the colormap level depending on skill&lt;br /&gt;
    public void setNodeEdgeColorFromSkill(){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*skill);&lt;br /&gt;
	this.setBorderColor(edgeColorMap.getColor(i));&lt;br /&gt;
	this.setBorderWidth(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // getDegree&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: int degree&lt;br /&gt;
    // Calculates the degree of the node (assuming symmetric)&lt;br /&gt;
    public int getDegree(){	&lt;br /&gt;
	return (this.getOutNodes()).size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
///////////////////////////////////////////////////////&lt;br /&gt;
    // formOpinion&lt;br /&gt;
    // Input: double success, the focus&#039; real skill&lt;br /&gt;
    // Output: double vote, the voter&#039;s estimate of focus&#039; skill&lt;br /&gt;
    public double formOpinion(double fSkill, double prevOp, double fRep){&lt;br /&gt;
	double op = fSkill + model.getNormalDouble(0, getNoiseFromSkill(this.skill));&lt;br /&gt;
	op = histWeight*prevOp + repWeight*fRep + (1 - histWeight- repWeight)*op;&lt;br /&gt;
	return op;&lt;br /&gt;
    }&lt;br /&gt;
	// it should /really/ be (arguably, of course):&lt;br /&gt;
	// opinion = (1 - weight) * (focus&#039; real skill + noise)&lt;br /&gt;
	//  + weight * [opinion-weighted average of common nbrs opinions of focus]&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
///////////////////////////////////////////////////////&lt;br /&gt;
    // formOpinion&lt;br /&gt;
    // Input: double success, the focus&#039; real skill&lt;br /&gt;
    // Output: double vote, the voter&#039;s estimate of focus&#039; skill&lt;br /&gt;
    public double formOpinion(double fSkill, double prevOp){&lt;br /&gt;
	double op = fSkill + model.getNormalDouble(0, getNoiseFromSkill(this.skill));&lt;br /&gt;
	op = histWeight*prevOp + (1-histWeight)*op;&lt;br /&gt;
	return op;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
	// new formOpinion&lt;br /&gt;
	public double formOpinion2(double fSkill, double fRep){&lt;br /&gt;
		// opinion = (1- repweight) * (focus&#039; real skill + noise)&lt;br /&gt;
		//  + repweight * focus&#039; reputation&lt;br /&gt;
		double op = fSkill+model.getNormalDouble(0,getNoiseFromSkill(this.skill));&lt;br /&gt;
		op = repWeight*fRep + (1-repWeight)*op;&lt;br /&gt;
		// here I truncate to [0,1] -- this is open to further discussion&lt;br /&gt;
		if (op &amp;gt; 1) op = 1; // must...not...write...Python...&lt;br /&gt;
		if (op &amp;lt; 0) op = 0; // too many languages in one head!&lt;br /&gt;
		return op;		&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
*/&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // voteAll&lt;br /&gt;
    public void voteAll(){&lt;br /&gt;
	ArrayList edgeList = this.getOutEdges();&lt;br /&gt;
	double opinion = 0;&lt;br /&gt;
	int vote = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getTo();&lt;br /&gt;
	    opinion = formOpinion(node.getSkill(), edge.getOpinion(), node.getReputation());&lt;br /&gt;
	    edge.setOpinion(opinion);&lt;br /&gt;
	    if (opinion &amp;gt; 0.5)&lt;br /&gt;
		vote = 1;&lt;br /&gt;
	    else&lt;br /&gt;
		vote = 0;&lt;br /&gt;
	    edge.setVote(vote);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
	// new voteAll&lt;br /&gt;
	/*&lt;br /&gt;
	public void voteAll2(){&lt;br /&gt;
		ArrayList edgeList = this.getOutEdges();&lt;br /&gt;
		double opinion = 0;&lt;br /&gt;
		int vote = 0;&lt;br /&gt;
		for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
		// for each neighbor&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getTo();&lt;br /&gt;
			// get opinion (truncated 0 to 1)&lt;br /&gt;
			opinion = formOpinion2(node.getSkill(), node.getReputation());&lt;br /&gt;
			// (optionally) locally normalize - omitted for now&lt;br /&gt;
			// set those opinions&lt;br /&gt;
			edge.setOpinion(opinion);&lt;br /&gt;
			// votes are opinions&lt;br /&gt;
			edge.setVote(opinion); // Java lines get semicolons, dipshit.&lt;br /&gt;
		}&lt;br /&gt;
	}*/&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // calcReputation&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Ouput: none&lt;br /&gt;
    public void calcReputation(){&lt;br /&gt;
	ArrayList edgeList = this.getInEdges();&lt;br /&gt;
	double repSum = 0;&lt;br /&gt;
	double normSum = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getFrom();&lt;br /&gt;
		repSum += edge.getVote() *(intVoteValue + (1-intVoteValue)*node.getReputation());&lt;br /&gt;
		normSum += (intVoteValue + (1-intVoteValue)*node.getReputation());&lt;br /&gt;
		/*&lt;br /&gt;
	    if (voteType ==0){&lt;br /&gt;
		repSum += edge.getVote();&lt;br /&gt;
		normSum ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (voteType ==1){&lt;br /&gt;
		repSum += edge.getVote() * node.getReputation();&lt;br /&gt;
		normSum += node.getReputation();&lt;br /&gt;
	    }*/&lt;br /&gt;
	}&lt;br /&gt;
	reputation = repSum/normSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
    public int      getID() {return id;}&lt;br /&gt;
&lt;br /&gt;
    public void     setMyPajekColor(String i) {myPajekColor = i;}&lt;br /&gt;
    public String   getMyPajekColor() {return myPajekColor;}&lt;br /&gt;
    &lt;br /&gt;
    public double   getReputation() {return reputation;}&lt;br /&gt;
    public void     setReputation(double i) {reputation = i;}&lt;br /&gt;
&lt;br /&gt;
    public double   getSkill() {return skill;}&lt;br /&gt;
    public void     setSkill(double i) {skill = i;}&lt;br /&gt;
&lt;br /&gt;
    //public double   getSuccess() {return success;}&lt;br /&gt;
    //public void     setSuccess(double i) {success = i;}&lt;br /&gt;
    &lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(RepMod m) {model = m;}&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setUpNodeDrawing&lt;br /&gt;
    // Input: GUIModel m, a pointer to the GUIModel&lt;br /&gt;
    // Output: none&lt;br /&gt;
    public static void setUpNodeDrawing (GUIModel m) {&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	centerColorMap = new ColorMap();&lt;br /&gt;
	edgeColorMap   = new ColorMap();&lt;br /&gt;
	double minColor = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracColor = minColor + ( (1.0-minColor)*i/colorMapMax );&lt;br /&gt;
&lt;br /&gt;
	    centerColorMap.mapColor(i, 0, 0, fracColor);&lt;br /&gt;
	    edgeColorMap.mapColor(i, 0, fracColor, 0);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // resetNextID&lt;br /&gt;
    // Inputs:  none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Resets nextID.  Called when the model is reset, and a &lt;br /&gt;
    //  new set of nodes is generated&lt;br /&gt;
    public static void resetNextID(){&lt;br /&gt;
	nextID = 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getNoiseFromSkill&lt;br /&gt;
    // Inputs: double skill&lt;br /&gt;
    // Outputs: double, the noise variance&lt;br /&gt;
    public static double getNoiseFromSkill(double skill){&lt;br /&gt;
	return (1-skill)*noiseSlope;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //public static int getVoteType() {return voteType;}&lt;br /&gt;
    //public static void setVoteType(int i) {voteType = i;}&lt;br /&gt;
&lt;br /&gt;
	public static double getIntVoteValue() {return intVoteValue;}&lt;br /&gt;
	public static void setIntVoteValue(double i) {intVoteValue = i;}&lt;br /&gt;
&lt;br /&gt;
    public static double getHistWeight() {return histWeight;}&lt;br /&gt;
    public static void   setHistWeight(double i) {histWeight = i;}&lt;br /&gt;
		&lt;br /&gt;
		public static double getRepWeight() {return repWeight;}&lt;br /&gt;
		public static void setRepWeight(double w) {repWeight = w;}&lt;br /&gt;
&lt;br /&gt;
    public static double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
    public static void   setNoiseSlope(double i) {noiseSlope = i;}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3783</id>
		<title>CustomEdge.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3783"/>
		<updated>2006-06-22T22:41:25Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * CustomEdge.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 5:55 PM&lt;br /&gt;
 * Modified on June 19 2006, 08:50 by Jack&lt;br /&gt;
 * Modified June 22, 2006 00:16 by Andrew&lt;br /&gt;
 * Modified June 22, 2006 16:40 by Jack&lt;br /&gt;
 *&lt;br /&gt;
 * This class is for the edges in a netwok&lt;br /&gt;
 * It points from a voter to the subject&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.gui.DrawableEdge;&lt;br /&gt;
import uchicago.src.sim.gui.SimGraphics;&lt;br /&gt;
import uchicago.src.sim.network.DefaultEdge;&lt;br /&gt;
import uchicago.src.sim.network.Node;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultEdge gives us the standard edge methods&lt;br /&gt;
// DrawableEdge lets us draw it in the GUI&lt;br /&gt;
public class CustomEdge extends DefaultEdge implements DrawableEdge {&lt;br /&gt;
    //*************************************************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // These are for drawing the edge in GUI&lt;br /&gt;
    public static GUIModel          guiModel = null;&lt;br /&gt;
    public static ColorMap          redColorMap, blueColorMap;&lt;br /&gt;
    public static final int         colorMapSize = 64;&lt;br /&gt;
    public static final int         colorMapMax = colorMapSize - 1;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    //Instance parameters&lt;br /&gt;
    &lt;br /&gt;
    private Color  color = Color.red;  // Edge color&lt;br /&gt;
    //public  int    vote = 0;&lt;br /&gt;
		public double vote = 0; // AS for [0-1] voting&lt;br /&gt;
    public  double opinion = 0.5;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public CustomEdge() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor (overloaded)&lt;br /&gt;
    // Inputs: Node from, the (generic class) Node from which the edge emerges&lt;br /&gt;
    //         Node to, the (generic) Node to which the edge points&lt;br /&gt;
    public CustomEdge(Node from, Node to) {&lt;br /&gt;
        super(from, to, &amp;quot;&amp;quot;);   // Calls DefaultEdge constructor&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // draw&lt;br /&gt;
    // Inputs: SimGraphics g&lt;br /&gt;
    //         int fromX, toX, fromY, toY&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Required to implement DrawableEdge.&lt;br /&gt;
    public void draw(SimGraphics g, int fromX, int toX, int fromY, int toY) {&lt;br /&gt;
        g.drawDirectedLink(color, fromX, toX, fromY, toY);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //getters and setters&lt;br /&gt;
    public void setColor(Color c) {color = c;}&lt;br /&gt;
    public Color getColor() {return color;}&lt;br /&gt;
&lt;br /&gt;
    //public void setVote(int i) {vote = i;}&lt;br /&gt;
    //public int  getVote() {return vote;}&lt;br /&gt;
		public void setVote(double i) {vote = i;}&lt;br /&gt;
    public double  getVote() {return vote;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public void setOpinion(double i) {opinion = i;}&lt;br /&gt;
    public double getOpinion() {return opinion;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //******************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////&lt;br /&gt;
    // setUpEdgeDrawing&lt;br /&gt;
    // Inputs: GUIModel m, a pointer to the GUIModel instance&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Prepares the edge to be drawn in the GUI&lt;br /&gt;
    public static void setUpEdgeDrawing (GUIModel m) {&lt;br /&gt;
	//System.out.printf(&amp;quot;Setting up Edge Color Map\n&amp;quot;);&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	redColorMap = new ColorMap();&lt;br /&gt;
	double minRed = 0.5;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracR = minRed + ( (1.0-minRed)*i/colorMapMax );&lt;br /&gt;
	    fracR = 1.0 + minRed - fracR;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    redColorMap.mapColor(i, fracR, 0, 0);		   &lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	blueColorMap = new ColorMap();&lt;br /&gt;
	double minBlue = 0.5;&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracB = minBlue + ( (1.0-minBlue)*i/colorMapMax );&lt;br /&gt;
	    fracB = 1.0 + minBlue - fracB;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    blueColorMap.mapColor(i, 0, 0, fracB);		   &lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3671</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3671"/>
		<updated>2006-06-20T00:20:34Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0619-1820)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0619-0850)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(APBS:0618-2315)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3670</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3670"/>
		<updated>2006-06-20T00:20:15Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 19, 2006 18:20 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public double noiseSlope;&lt;br /&gt;
		&lt;br /&gt;
		public int numTopAgents = 5; // Andrew hacking TopRep calculation&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nS&amp;quot;, &amp;quot;noiseSlope&amp;quot;);&lt;br /&gt;
        parametersMap.put( &amp;quot;nTA&amp;quot;, &amp;quot;numTopAgents&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &amp;quot;noiseSlope&amp;quot;,&lt;br /&gt;
					&amp;quot;numTopAgents&amp;quot;, // AS added for top agents param&lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {&lt;br /&gt;
	voteType = i;&lt;br /&gt;
	CustomNode.setVoteType(i);&lt;br /&gt;
    }&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {&lt;br /&gt;
	histWeight = i;&lt;br /&gt;
	CustomNode.setHistWeight(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
    public void setNoiseSlope(double i) {&lt;br /&gt;
	noiseSlope = i;&lt;br /&gt;
	CustomNode.setNoiseSlope(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
		// AS added for top agents param&lt;br /&gt;
		public int getNumTopAgents() {return numTopAgents;}&lt;br /&gt;
		public void setNumTopAgents(int n) {numTopAgents = n;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
	CustomNode.setNoiseSlope(noiseSlope);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1;&lt;br /&gt;
	pajekUpdateInterval    = 1000000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
	noiseSlope = 1;&lt;br /&gt;
&lt;br /&gt;
			// AS added for top agents param&lt;br /&gt;
			numTopAgents = 5;&lt;br /&gt;
		&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
		// AS: could be changed to just use numTopAgents directly, &lt;br /&gt;
		// but I&#039;m gonna change it at call time only--&lt;br /&gt;
		// lower impact if I fuck something up.&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = tempList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f %f %f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble(), calcTopRepSkills(numTopAgents),&lt;br /&gt;
			  calcRepSkillMatch());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time  topSkill  RepSkillMatch&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3663</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3663"/>
		<updated>2006-06-19T14:49:53Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(APBS:0618-2315)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0619-0850)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(APBS:0618-2315)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3662</id>
		<title>CustomEdge.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3662"/>
		<updated>2006-06-19T14:49:32Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * CustomEdge.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 5:55 PM&lt;br /&gt;
 * Modified on June 19 2006, 08:50 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class is for the edges in a netwok&lt;br /&gt;
 * It points from a voter to the subject&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.gui.DrawableEdge;&lt;br /&gt;
import uchicago.src.sim.gui.SimGraphics;&lt;br /&gt;
import uchicago.src.sim.network.DefaultEdge;&lt;br /&gt;
import uchicago.src.sim.network.Node;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultEdge gives us the standard edge methods&lt;br /&gt;
// DrawableEdge lets us draw it in the GUI&lt;br /&gt;
public class CustomEdge extends DefaultEdge implements DrawableEdge {&lt;br /&gt;
    //*************************************************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // These are for drawing the edge in GUI&lt;br /&gt;
    public static GUIModel          guiModel = null;&lt;br /&gt;
    public static ColorMap          redColorMap, blueColorMap;&lt;br /&gt;
    public static final int         colorMapSize = 64;&lt;br /&gt;
    public static final int         colorMapMax = colorMapSize - 1;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    //Instance parameters&lt;br /&gt;
    &lt;br /&gt;
    private Color  color = Color.red;  // Edge color&lt;br /&gt;
    public  int    vote = 0;&lt;br /&gt;
    public  double opinion = 0.5;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public CustomEdge() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor (overloaded)&lt;br /&gt;
    // Inputs: Node from, the (generic class) Node from which the edge emerges&lt;br /&gt;
    //         Node to, the (generic) Node to which the edge points&lt;br /&gt;
    public CustomEdge(Node from, Node to) {&lt;br /&gt;
        super(from, to, &amp;quot;&amp;quot;);   // Calls DefaultEdge constructor&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // draw&lt;br /&gt;
    // Inputs: SimGraphics g&lt;br /&gt;
    //         int fromX, toX, fromY, toY&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Required to implement DrawableEdge.&lt;br /&gt;
    public void draw(SimGraphics g, int fromX, int toX, int fromY, int toY) {&lt;br /&gt;
        g.drawDirectedLink(color, fromX, toX, fromY, toY);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //getters and setters&lt;br /&gt;
    public void setColor(Color c) {color = c;}&lt;br /&gt;
    public Color getColor() {return color;}&lt;br /&gt;
&lt;br /&gt;
    public void setVote(int i) {vote = i;}&lt;br /&gt;
    public int  getVote() {return vote;}&lt;br /&gt;
&lt;br /&gt;
    public void setOpinion(double i) {opinion = i;}&lt;br /&gt;
    public double getOpinion() {return opinion;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //******************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////&lt;br /&gt;
    // setUpEdgeDrawing&lt;br /&gt;
    // Inputs: GUIModel m, a pointer to the GUIModel instance&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Prepares the edge to be drawn in the GUI&lt;br /&gt;
    public static void setUpEdgeDrawing (GUIModel m) {&lt;br /&gt;
	//System.out.printf(&amp;quot;Setting up Edge Color Map\n&amp;quot;);&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	redColorMap = new ColorMap();&lt;br /&gt;
	double minRed = 0.5;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracR = minRed + ( (1.0-minRed)*i/colorMapMax );&lt;br /&gt;
	    fracR = 1.0 + minRed - fracR;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    redColorMap.mapColor(i, fracR, 0, 0);		   &lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	blueColorMap = new ColorMap();&lt;br /&gt;
	double minBlue = 0.5;&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracB = minBlue + ( (1.0-minBlue)*i/colorMapMax );&lt;br /&gt;
	    fracB = 1.0 + minBlue - fracB;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    blueColorMap.mapColor(i, 0, 0, fracB);		   &lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3661</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3661"/>
		<updated>2006-06-19T13:55:15Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 18, 2006 13:55 by Jack&lt;br /&gt;
 * Modified slightly 6-18-06 23:10 by Andrew&lt;br /&gt;
 * ReModified very slightly June 19 07:55 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public double noiseSlope;&lt;br /&gt;
		&lt;br /&gt;
		public int numTopAgents = 5; // Andrew hacking TopRep calculation&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nS&amp;quot;, &amp;quot;noiseSlope&amp;quot;);&lt;br /&gt;
        parametersMap.put( &amp;quot;nTA&amp;quot;, &amp;quot;numTopAgents&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &amp;quot;noiseSlope&amp;quot;,&lt;br /&gt;
					&amp;quot;numTopAgents&amp;quot;, // AS added for top agents param&lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {&lt;br /&gt;
	voteType = i;&lt;br /&gt;
	CustomNode.setVoteType(i);&lt;br /&gt;
    }&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {&lt;br /&gt;
	histWeight = i;&lt;br /&gt;
	CustomNode.setHistWeight(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
    public void setNoiseSlope(double i) {&lt;br /&gt;
	noiseSlope = i;&lt;br /&gt;
	CustomNode.setNoiseSlope(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
		// AS added for top agents param&lt;br /&gt;
		public int getNumTopAgents() {return numTopAgents;}&lt;br /&gt;
		public void setNumTopAgents(int n) {numTopAgents = n;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
	CustomNode.setNoiseSlope(noiseSlope);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1;&lt;br /&gt;
	pajekUpdateInterval    = 1000000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
	noiseSlope = 1;&lt;br /&gt;
&lt;br /&gt;
			// AS added for top agents param&lt;br /&gt;
			numTopAgents = 5;&lt;br /&gt;
		&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
		// AS: could be changed to just use numTopAgents directly, &lt;br /&gt;
		// but I&#039;m gonna change it at call time only--&lt;br /&gt;
		// lower impact if I fuck something up.&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = tempList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f %f %f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble(), calcTopRepSkills(numTopAgents),&lt;br /&gt;
			  calcRepSkillMatch());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time  topSkill  RepSkillMatch&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3649</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3649"/>
		<updated>2006-06-18T23:09:20Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3648</id>
		<title>CustomNode.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3648"/>
		<updated>2006-06-18T23:09:04Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * CustomNode.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 2:41 PM&lt;br /&gt;
 * Modified on June 18, 2006, 13:55 by Jack&lt;br /&gt;
 *&lt;br /&gt;
 * This class contains the parameters and methods&lt;br /&gt;
 *  for an agent acting on the network&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultDrawableNode lets us draw it in the GUI&lt;br /&gt;
// CustomProbeable lets us define which attributes appear when&lt;br /&gt;
//  probed in the GUI&lt;br /&gt;
public class CustomNode extends DefaultDrawableNode implements CustomProbeable {&lt;br /&gt;
    //***********************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // tracks next unique id&lt;br /&gt;
    public static int                   nextID = 0;      &lt;br /&gt;
    &lt;br /&gt;
    public static GUIModel              guiModel = null;&lt;br /&gt;
    public static RepMod           model;&lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public static int    voteType; &lt;br /&gt;
&lt;br /&gt;
    // the degree by which the historical opinion is weighted&lt;br /&gt;
    public static double histWeight;            &lt;br /&gt;
&lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public static double noiseSlope;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //********************************8**&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
&lt;br /&gt;
    // Two colormaps are generated for color-coding the nodes in GUI&lt;br /&gt;
    public static ColorMap              centerColorMap;    &lt;br /&gt;
    public static ColorMap              edgeColorMap;&lt;br /&gt;
    public static final int             colorMapSize = 16;&lt;br /&gt;
    public static final int             colorMapMax = colorMapSize - 1;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    private int   id;                   // uniquely ids node&lt;br /&gt;
    public Color  myColor;              // used to draw color in GUI&lt;br /&gt;
    public String myPajekColor = &amp;quot;Red&amp;quot;; // color to appear in Pajek output&lt;br /&gt;
    public double reputation;              // current wealth or stored reputation&lt;br /&gt;
    public double skill;          // skill parameter&lt;br /&gt;
    //public int    numVotes;              // the number of vote rounds &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
       &lt;br /&gt;
&lt;br /&gt;
    //public double success;              // most recent success&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////&lt;br /&gt;
    // constructor&lt;br /&gt;
    // Inputs: NetworkDrawable drawable, to draw in GUI&lt;br /&gt;
    //         double skill, the skill parameter&lt;br /&gt;
    public CustomNode (NetworkDrawable drawable, double skill) {&lt;br /&gt;
	super(drawable);&lt;br /&gt;
	id = nextID++;              // set id and iterate to next&lt;br /&gt;
	this.skill = skill;&lt;br /&gt;
	reputation = 0.5;	            // Generalize.  Currently hard-coded&lt;br /&gt;
	if (guiModel != null)&lt;br /&gt;
	    setNodeEdgeColorFromSkill();&lt;br /&gt;
	//numVotes = 0;&lt;br /&gt;
	//success = 0;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getProbedProperties&lt;br /&gt;
    // Required to implement CustomProbeable&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: array of strings holding parameter names&lt;br /&gt;
    public String[] getProbedProperties(){&lt;br /&gt;
	return new String[] {&amp;quot;id&amp;quot;, &amp;quot;reputation&amp;quot;, &amp;quot;skill&amp;quot;};&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // (Can be) Called by main model to have nodes execute a single step&lt;br /&gt;
    public void step(){&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeColorFromReputation&lt;br /&gt;
    // Input:  maxReputation, the highest reputation from all agents&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node color to the colormap leval depending on reputation&lt;br /&gt;
    public void setNodeColorFromReputation(double maxReputation){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*(reputation)/ (maxReputation));&lt;br /&gt;
	this.setColor(centerColorMap.getColor(i));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeEdgeColorFromSkill&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node edge color to the colormap level depending on skill&lt;br /&gt;
    public void setNodeEdgeColorFromSkill(){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*skill);&lt;br /&gt;
	this.setBorderColor(edgeColorMap.getColor(i));&lt;br /&gt;
	this.setBorderWidth(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // getDegree&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: int degree&lt;br /&gt;
    // Calculates the degree of the node (assuming symmetric)&lt;br /&gt;
    public int getDegree(){	&lt;br /&gt;
	return (this.getOutNodes()).size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // formOpinion&lt;br /&gt;
    // Input: double success, the focus&#039; real skill&lt;br /&gt;
    // Output: double vote, the voter&#039;s estimate of focus&#039; skill&lt;br /&gt;
    public double formOpinion(double fSkill, double prevOp){&lt;br /&gt;
	double op = fSkill + model.getNormalDouble(0, getNoiseFromSkill(this.skill));&lt;br /&gt;
	op = histWeight*prevOp + (1-histWeight)*op;&lt;br /&gt;
	return op;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // voteAll&lt;br /&gt;
    public void voteAll(){&lt;br /&gt;
	ArrayList edgeList = this.getOutEdges();&lt;br /&gt;
	double opinion = 0;&lt;br /&gt;
	int vote = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getTo();&lt;br /&gt;
	    opinion = formOpinion(node.getSkill(), edge.getOpinion());&lt;br /&gt;
	    edge.setOpinion(opinion);&lt;br /&gt;
	    if (opinion &amp;gt; 0.5)&lt;br /&gt;
		vote = 1;&lt;br /&gt;
	    else&lt;br /&gt;
		vote = 0;&lt;br /&gt;
	    edge.setVote(vote);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // calcReputation&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Ouput: none&lt;br /&gt;
    public void calcReputation(){&lt;br /&gt;
	ArrayList edgeList = this.getInEdges();&lt;br /&gt;
	double repSum = 0;&lt;br /&gt;
	double normSum = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getFrom();&lt;br /&gt;
	    if (voteType ==0){&lt;br /&gt;
		repSum += edge.getVote();&lt;br /&gt;
		normSum ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (voteType ==1){&lt;br /&gt;
		repSum += edge.getVote() * node.getReputation();&lt;br /&gt;
		normSum += node.getReputation();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	reputation = repSum/normSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
    public int      getID() {return id;}&lt;br /&gt;
&lt;br /&gt;
    public void     setMyPajekColor(String i) {myPajekColor = i;}&lt;br /&gt;
    public String   getMyPajekColor() {return myPajekColor;}&lt;br /&gt;
    &lt;br /&gt;
    public double   getReputation() {return reputation;}&lt;br /&gt;
    public void     setReputation(double i) {reputation = i;}&lt;br /&gt;
&lt;br /&gt;
    public double   getSkill() {return skill;}&lt;br /&gt;
    public void     setSkill(double i) {skill = i;}&lt;br /&gt;
&lt;br /&gt;
    //public double   getSuccess() {return success;}&lt;br /&gt;
    //public void     setSuccess(double i) {success = i;}&lt;br /&gt;
    &lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(RepMod m) {model = m;}&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setUpNodeDrawing&lt;br /&gt;
    // Input: GUIModel m, a pointer to the GUIModel&lt;br /&gt;
    // Output: none&lt;br /&gt;
    public static void setUpNodeDrawing (GUIModel m) {&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	centerColorMap = new ColorMap();&lt;br /&gt;
	edgeColorMap   = new ColorMap();&lt;br /&gt;
	double minColor = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracColor = minColor + ( (1.0-minColor)*i/colorMapMax );&lt;br /&gt;
&lt;br /&gt;
	    centerColorMap.mapColor(i, 0, 0, fracColor);&lt;br /&gt;
	    edgeColorMap.mapColor(i, 0, fracColor, 0);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // resetNextID&lt;br /&gt;
    // Inputs:  none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Resets nextID.  Called when the model is reset, and a &lt;br /&gt;
    //  new set of nodes is generated&lt;br /&gt;
    public static void resetNextID(){&lt;br /&gt;
	nextID = 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getNoiseFromSkill&lt;br /&gt;
    // Inputs: double skill&lt;br /&gt;
    // Outputs: double, the noise variance&lt;br /&gt;
    public static double getNoiseFromSkill(double skill){&lt;br /&gt;
	return (1-skill)*noiseSlope;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public static int getVoteType() {return voteType;}&lt;br /&gt;
    public static void setVoteType(int i) {voteType = i;}&lt;br /&gt;
&lt;br /&gt;
    public static double getHistWeight() {return histWeight;}&lt;br /&gt;
    public static void   setHistWeight(double i) {histWeight = i;}&lt;br /&gt;
&lt;br /&gt;
    public static double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
    public static void   setNoiseSlope(double i) {noiseSlope = i;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3646</id>
		<title>GUIModel.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3646"/>
		<updated>2006-06-18T19:54:45Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * GUIModel.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 30, 2005, 12:21 PM&lt;br /&gt;
 * Modified June 18, 2006 13:55 by Jack&lt;br /&gt;
 * This runs the graphical interface for the RepMod model&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.Value2DDisplay;&lt;br /&gt;
import uchicago.src.sim.space.Object2DTorus;&lt;br /&gt;
import uchicago.src.sim.engine.AbstractGUIController;&lt;br /&gt;
import uchicago.src.sim.analysis.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class GUIModel extends RepMod{&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance Parameters&lt;br /&gt;
&lt;br /&gt;
    // The actual display surface, where things are put on the screen&lt;br /&gt;
    private DisplaySurface              surface;&lt;br /&gt;
    &lt;br /&gt;
    // A layout, which tells the surface where to put nodes and edges&lt;br /&gt;
    private AbstractGraphLayout         layout;&lt;br /&gt;
&lt;br /&gt;
    // A graph of the agreement between rep and skill&lt;br /&gt;
    private OpenSequenceGraph           repSkillGraph;&lt;br /&gt;
&lt;br /&gt;
    // A graph of the running sum of the skill of the top repped agents&lt;br /&gt;
    private OpenSequenceGraph           topSkillGraph;&lt;br /&gt;
&lt;br /&gt;
    // A plot&lt;br /&gt;
    private Plot                        histPlot;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    // private OpenHistogram               wealthHist;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    // private OpenHistogram               degreeHist;&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // setup&lt;br /&gt;
    //&lt;br /&gt;
    // This runs automatically when the model starts&lt;br /&gt;
    // and when you click the reload button, to &amp;quot;tear down&amp;quot; any &lt;br /&gt;
    // existing display objects, and get ready to initialize &lt;br /&gt;
    // them at the start of the next &#039;run&#039;.&lt;br /&gt;
    //&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	// the super class does conceptual-model setup (RepMod)&lt;br /&gt;
	super.setup();  &lt;br /&gt;
	&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() begin.\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// NOTE: you may want to set these next two to &#039;true&#039;&lt;br /&gt;
	// if you are on a windows machine.  that would tell repast&lt;br /&gt;
	// to by default send System.out and .err output to&lt;br /&gt;
	// a special repast output window.&lt;br /&gt;
	AbstractGUIController.CONSOLE_ERR = false;&lt;br /&gt;
	AbstractGUIController.CONSOLE_OUT = false;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// For restart purposes, dispose of any displays&lt;br /&gt;
	if ( surface != null ) surface.dispose();&lt;br /&gt;
	if ( repSkillGraph != null ) repSkillGraph.dispose();&lt;br /&gt;
	if ( topSkillGraph != null ) topSkillGraph.dispose();&lt;br /&gt;
	//if ( wealthHist != null) wealthHist.dispose();&lt;br /&gt;
	//if ( degreeHist != null) degreeHist.dispose();&lt;br /&gt;
&lt;br /&gt;
	// Create and register the abstract surface&lt;br /&gt;
	surface = null;&lt;br /&gt;
	surface = new DisplaySurface( this, &amp;quot;Network Display&amp;quot; );&lt;br /&gt;
	registerDisplaySurface( &amp;quot;Main Display&amp;quot;, surface );&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	// Add Custom Buttons&lt;br /&gt;
	modelManipulator.init();&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Circular&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutCircular();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);						   &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Kamada&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutKamada();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Rep Sorted Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printRepSortedNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
              &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Kill All Edges&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     killAllEdges();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Plot Reputation vs. Skill&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     plotRepSkill();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() done.\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    //&lt;br /&gt;
    // This runs when you click the &amp;quot;initialize&amp;quot; button&lt;br /&gt;
    // (the button with the single arrow that goes around in a circle)&lt;br /&gt;
    // or at the first step&lt;br /&gt;
    public void begin()	{&lt;br /&gt;
	DMSG(1, &amp;quot;==&amp;gt; enter GUIModel-begin()&amp;quot; );&lt;br /&gt;
	// Set up drawables&lt;br /&gt;
	CustomNode.setUpNodeDrawing(this);&lt;br /&gt;
	CustomEdge.setUpEdgeDrawing(this);&lt;br /&gt;
	&lt;br /&gt;
	buildModel();  // Calls in the base model (RepMod)&lt;br /&gt;
	&lt;br /&gt;
	buildDisplay();  // Constructs the displays&lt;br /&gt;
	if (rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Display Built Successfully. \n&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	// Constructs the schedule; If defined in GUIModel, ignores buildSchedule in base model&lt;br /&gt;
	buildSchedule(); &lt;br /&gt;
&lt;br /&gt;
	surface.display(); // displays the surface on the display&lt;br /&gt;
&lt;br /&gt;
	writeHeaderCommentsToReportFile();&lt;br /&gt;
	&lt;br /&gt;
	DMSG(1, &amp;quot;&amp;lt;== leave GUIModel-begin() done.&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildDisplay&lt;br /&gt;
    //&lt;br /&gt;
    // builds the display and display related things&lt;br /&gt;
    //&lt;br /&gt;
    public void buildDisplay() {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;==&amp;gt; GUIModel buildDisplay...\n&amp;quot; );&lt;br /&gt;
        &lt;br /&gt;
	// Layout specifies the arrangement of nodes and edges&lt;br /&gt;
	// This specifically uses the Kamada-Kawai method&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	Network2DDisplay display = new Network2DDisplay(layout);&lt;br /&gt;
	&lt;br /&gt;
	layout.updateLayout();  // actually execute the laying out&lt;br /&gt;
&lt;br /&gt;
	// Register the layout with the display surface for drawing&lt;br /&gt;
	surface.addDisplayableProbeable(display, &amp;quot;Network Display&amp;quot;);&lt;br /&gt;
	surface.addZoomable (display);&lt;br /&gt;
	surface.setBackground (java.awt.Color.black);&lt;br /&gt;
	&lt;br /&gt;
	addSimEventListener (surface);&lt;br /&gt;
	&lt;br /&gt;
	// Makes a graph&lt;br /&gt;
	repSkillGraph = new OpenSequenceGraph(&amp;quot;RepSkillMatch&amp;quot;, this); // constructs graph&lt;br /&gt;
	repSkillGraph.setXRange(0, 2000);                     // sets ranges&lt;br /&gt;
	repSkillGraph.setYRange(-1.1, 1.1);&lt;br /&gt;
	repSkillGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;frac. match&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class repSkillSequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcRepSkillMatch();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	repSkillGraph.addSequence(&amp;quot;frace. match&amp;quot;, new repSkillSequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	repSkillGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	topSkillGraph = new OpenSequenceGraph(&amp;quot;Top Rep Skills&amp;quot;, this); // constructs graph&lt;br /&gt;
	topSkillGraph.setXRange(0, 2000);                     // sets ranges&lt;br /&gt;
	topSkillGraph.setYRange(0, 5);&lt;br /&gt;
	topSkillGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;Skills&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class topSkillSequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcTopRepSkills(5);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	topSkillGraph.addSequence(&amp;quot;Skill of Top Rep Agents&amp;quot;, new topSkillSequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	topSkillGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent wealth&lt;br /&gt;
	/*&lt;br /&gt;
	wealthHist = new OpenHistogram(&amp;quot;Agent Wealth Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	wealthHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource histSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getReputation();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	wealthHist.createHistogramItem(&amp;quot;Wealth&amp;quot;, agentList, histSource);&lt;br /&gt;
	wealthHist.display();&lt;br /&gt;
	*/&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent degree&lt;br /&gt;
	/*&lt;br /&gt;
	degreeHist = new OpenHistogram(&amp;quot;Agent Degree Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	degreeHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource degreeSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getDegree();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	degreeHist.createHistogramItem(&amp;quot;Degree&amp;quot;, agentList, degreeSource);&lt;br /&gt;
	degreeHist.display();&lt;br /&gt;
	*/&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Adds to buildSchedule in main model&lt;br /&gt;
    // Note, model-type changes should also be included in&lt;br /&gt;
    // batchmodel&#039;s buildSchedule if one wants to ever run in batch&lt;br /&gt;
    &lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	&lt;br /&gt;
	schedule = new Schedule(1);&lt;br /&gt;
	super.buildSchedule();  // Get base model schedule&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    //&lt;br /&gt;
    // Ask the super-class (RepMod) to do its step() method,&lt;br /&gt;
    // and then this does display related activities.&lt;br /&gt;
    public void step() {&lt;br /&gt;
	&lt;br /&gt;
	super.step();	  // the base model does whatever it does&lt;br /&gt;
	&lt;br /&gt;
	// add things after this for all displays (graphs, etc)&lt;br /&gt;
	drawNodes();&lt;br /&gt;
	surface.updateDisplay();&lt;br /&gt;
	repSkillGraph.step();&lt;br /&gt;
	topSkillGraph.step();&lt;br /&gt;
	//wealthHist.step();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // drawNodes&lt;br /&gt;
    // has nodes re-draw themselves based on Reputation&lt;br /&gt;
    public void drawNodes(){&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
	double maxReputation = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    if (node.getReputation() &amp;gt; maxReputation)&lt;br /&gt;
		maxReputation = node.getReputation();&lt;br /&gt;
        }&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.setNodeColorFromReputation(maxReputation);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // called once, at end of run.&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== GUIModel processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	super.addAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	super.delAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // updateLayoutAgentList&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Update layout&#039;s agentList.  Model&#039;s agentlist&lt;br /&gt;
    //  is updated with gm&#039;s (since they both point to &lt;br /&gt;
    //  the same object).  Layout is dumb, and evidently&lt;br /&gt;
    //  re-stores pointers to objects in list, rather than&lt;br /&gt;
    //  the list.&lt;br /&gt;
    public void updateLayoutAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	layout.setList(agentList); &lt;br /&gt;
	// update the layout, re-executing layout method (e.g. Kamada)&lt;br /&gt;
	layout.updateLayout(); &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutCircular&lt;br /&gt;
    // Uses circular rather than Kamada layout&lt;br /&gt;
    public void changeLayoutCircular(){&lt;br /&gt;
        layout = new CircularGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutKamada&lt;br /&gt;
    // Uses kamada-kawai layout, rather than circular&lt;br /&gt;
    public void changeLayoutKamada(){&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
    public void printNodes(){&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode aNode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %1.3f rep with skill %1.3f.\n&amp;quot;, &lt;br /&gt;
		     aNode.getID(), aNode.getReputation(), aNode.getSkill());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printRepSortedNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
&lt;br /&gt;
    public void printRepSortedNodes(){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(CustomNode agent : tempList){&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %1.3f rep with skill %1.3f.\n&amp;quot;, &lt;br /&gt;
		     agent.getID(), agent.getReputation(), agent.getSkill());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // killAllEdges&lt;br /&gt;
    // deletes all edges&lt;br /&gt;
    // Mainly used for debugging, or being a bastard&lt;br /&gt;
    public void killAllEdges(){&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.clearInEdges();&lt;br /&gt;
	    node.clearOutEdges();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // plotRepSkill()&lt;br /&gt;
    public void plotRepSkill(){&lt;br /&gt;
	Plot repSkillPlot = new Plot(&amp;quot;Reputation v. Skill&amp;quot;);&lt;br /&gt;
	repSkillPlot.display();&lt;br /&gt;
	repSkillPlot.setConnected(false);&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; numAgents; i++) {&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    repSkillPlot.plotPoint(node.getSkill(), node.getReputation(), 0);&lt;br /&gt;
	}&lt;br /&gt;
	repSkillPlot.updateGraph();&lt;br /&gt;
	repSkillPlot.setXRange(0, 1);	&lt;br /&gt;
	repSkillPlot.setYRange(0, 1);&lt;br /&gt;
	//aPlot.fillPlot();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //   ****  NO NEEd TO CHANGE THE REST OF THIS  *****&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // main entry point&lt;br /&gt;
    public static void main( String[] args ) {&lt;br /&gt;
	&lt;br /&gt;
	uchicago.src.sim.engine.SimInit init =&lt;br /&gt;
	    new uchicago.src.sim.engine.SimInit();&lt;br /&gt;
	GUIModel model = new GUIModel();&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;==&amp;gt; GUIMOdel main...\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// set the type of model class, this is necessary&lt;br /&gt;
	// so the parameters object knows whether or not&lt;br /&gt;
	// to do GUI related updates of panels,etc when a&lt;br /&gt;
	// parameter is changed&lt;br /&gt;
	model.setModelType(&amp;quot;GUIModel&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
        // Do this to set the Update Probes option to true in the&lt;br /&gt;
        // Repast Actions panel&lt;br /&gt;
        Controller.UPDATE_PROBES = true;&lt;br /&gt;
	&lt;br /&gt;
	model.setCommandLineArgs( args );&lt;br /&gt;
	init.loadModel( model, null, false ); // does setup()&lt;br /&gt;
	&lt;br /&gt;
	// this new function calls ProbeUtilities.updateProbePanels() and &lt;br /&gt;
	// ProbeUtilities.updateModelProbePanel()&lt;br /&gt;
	model.updateAllProbePanels();&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Creates a new instance of GUIModel */&lt;br /&gt;
    public GUIModel() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3645</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3645"/>
		<updated>2006-06-18T19:54:09Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 18, 2006 13:55 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    // the (negative of) slope of skill vs variance of noise&lt;br /&gt;
    public double noiseSlope;&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nS&amp;quot;, &amp;quot;noiseSlope&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &amp;quot;noiseSlope&amp;quot;,&lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {&lt;br /&gt;
	voteType = i;&lt;br /&gt;
	CustomNode.setVoteType(i);&lt;br /&gt;
    }&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {&lt;br /&gt;
	histWeight = i;&lt;br /&gt;
	CustomNode.setHistWeight(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
    public void setNoiseSlope(double i) {&lt;br /&gt;
	noiseSlope = i;&lt;br /&gt;
	CustomNode.setNoiseSlope(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getNoiseSlope() {return noiseSlope;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
	CustomNode.setNoiseSlope(noiseSlope);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1;&lt;br /&gt;
	pajekUpdateInterval    = 1000000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
	noiseSlope = 1;&lt;br /&gt;
&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = tempList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f %f %f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble(), calcTopRepSkills(5),&lt;br /&gt;
			  calcRepSkillMatch());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time  topSkill  RepSkillMatch&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3644</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3644"/>
		<updated>2006-06-18T19:53:35Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1355)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=BatchModel.java.wp&amp;diff=3643</id>
		<title>BatchModel.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=BatchModel.java.wp&amp;diff=3643"/>
		<updated>2006-06-18T19:52:59Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package RepMod;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *   BatchModel is a non-gui extension of base RepMod&lt;br /&gt;
 *   Modified June 18, 2006 13:52 by Jack&lt;br /&gt;
**/&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.space.*;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
&lt;br /&gt;
public class BatchModel extends RepMod {&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // main entry point&lt;br /&gt;
    public static void main( String[] args ) {&lt;br /&gt;
	&lt;br /&gt;
	BatchModel model = new BatchModel();&lt;br /&gt;
	&lt;br /&gt;
	// set the type of model class, this is necessary&lt;br /&gt;
	// so the parameters object knows whether or not&lt;br /&gt;
	// to do GUI related updates of panels, etc when a&lt;br /&gt;
	// parameter is changed&lt;br /&gt;
	model.setModelType(&amp;quot;BatchModel&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	model.setCommandLineArgs(args);&lt;br /&gt;
	&lt;br /&gt;
	PlainController control = new PlainController();&lt;br /&gt;
	model.setController(control);&lt;br /&gt;
	control.setExitOnExit(true);&lt;br /&gt;
	control.setModel(model);&lt;br /&gt;
	model.addSimEventListener(control);&lt;br /&gt;
	&lt;br /&gt;
	if ( model.getRDebug() &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf(&amp;quot;\n==&amp;gt; BatchModel main...about to startSimulation...\n&amp;quot;);&lt;br /&gt;
	control.startSimulation();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // setup() -- BatchModel just does what the super class does.&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	super.setup();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////&lt;br /&gt;
    // begin()&lt;br /&gt;
    // ask the super class to do its building, then build a schedule.&lt;br /&gt;
    public void begin() {&lt;br /&gt;
	// set schedule to null so buildModel knows not to &lt;br /&gt;
	// record changes ( changes are recorded if &lt;br /&gt;
	// schedule != null ).  in buildSchedule() the &lt;br /&gt;
	// schedule is allocated before the actual schedule is created.&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	buildModel();     // the base Model class does this&lt;br /&gt;
	buildSchedule();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // &lt;br /&gt;
    // This may need to be changed, depending on what you want to&lt;br /&gt;
    // happen in a batch run (vs a GUI run).&lt;br /&gt;
    &lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	&lt;br /&gt;
	schedule = new Schedule(1);&lt;br /&gt;
	&lt;br /&gt;
	super.buildSchedule();&lt;br /&gt;
	&lt;br /&gt;
	// schedule the current BatchModel&#039;s processEndOfRun() &lt;br /&gt;
	// function to execute at the end of the Batch Run.&lt;br /&gt;
	// You need to specify the time to schedule it (instead &lt;br /&gt;
	// of doing scheduleActionAtEnd() or it will just run forever&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // we need this to tell it to stop running!&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	super.processEndOfRun();&lt;br /&gt;
	this.fireEndSim();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// Why this class below?&lt;br /&gt;
//&lt;br /&gt;
// the reason we did that is because the repast &amp;quot;BatchController&amp;quot; had methods&lt;br /&gt;
// in it that started GUI stuff.  this caused problems when we ssh&#039;d into&lt;br /&gt;
// another machine and run a job--when we tried to disconnect, the ssh&lt;br /&gt;
// session would stay hung until the job was finished because the job needed&lt;br /&gt;
// the X11-forwarding to be open to run.&lt;br /&gt;
&lt;br /&gt;
class PlainController extends BaseController {&lt;br /&gt;
    private boolean exitonexit;&lt;br /&gt;
    &lt;br /&gt;
    public PlainController() {&lt;br /&gt;
	super();&lt;br /&gt;
	exitonexit = false;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void startSimulation() {&lt;br /&gt;
	startSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void stopSimulation() {&lt;br /&gt;
	stopSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void exitSim(){ exitSim(); }&lt;br /&gt;
    &lt;br /&gt;
    public void pauseSimulation() {&lt;br /&gt;
	pauseSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public boolean isBatch() {&lt;br /&gt;
	return true;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    protected void onTickCountUpdate() {}&lt;br /&gt;
    &lt;br /&gt;
    // this might not be necessary&lt;br /&gt;
    public void setExitOnExit(boolean in_Exitonexit) {&lt;br /&gt;
	exitonexit = in_Exitonexit;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void simEventPerformed(SimEvent evt) {&lt;br /&gt;
	if(evt.getId() == SimEvent.STOP_EVENT) {&lt;br /&gt;
	    stopSimulation();&lt;br /&gt;
	}&lt;br /&gt;
	else if(evt.getId() == SimEvent.END_EVENT) {&lt;br /&gt;
	    if(exitonexit) {&lt;br /&gt;
		System.exit(0);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	else if(evt.getId() == SimEvent.PAUSE_EVENT) {&lt;br /&gt;
	    pauseSimulation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // function added because it is required for repast 2.2&lt;br /&gt;
    public long getRunCount() {&lt;br /&gt;
	return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // function added because it is required for repast 2.2&lt;br /&gt;
    public boolean isGUI() {&lt;br /&gt;
	return false;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3642</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3642"/>
		<updated>2006-06-18T19:19:48Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 18, 2006 13:20 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {&lt;br /&gt;
	voteType = i;&lt;br /&gt;
	CustomNode.setVoteType(i);&lt;br /&gt;
    }&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {&lt;br /&gt;
	histWeight = i;&lt;br /&gt;
	CustomNode.setHistWeight(i);&lt;br /&gt;
    }&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1000;&lt;br /&gt;
	pajekUpdateInterval    = 5000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = tempList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3641</id>
		<title>GUIModel.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3641"/>
		<updated>2006-06-18T19:19:11Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GUIModel.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 30, 2005, 12:21 PM&lt;br /&gt;
 * Modified June 18, 2006 13:20 by Jack&lt;br /&gt;
 * This runs the graphical interface for the RepMod model&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.Value2DDisplay;&lt;br /&gt;
import uchicago.src.sim.space.Object2DTorus;&lt;br /&gt;
import uchicago.src.sim.engine.AbstractGUIController;&lt;br /&gt;
import uchicago.src.sim.analysis.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class GUIModel extends RepMod{&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance Parameters&lt;br /&gt;
&lt;br /&gt;
    // The actual display surface, where things are put on the screen&lt;br /&gt;
    private DisplaySurface              surface;&lt;br /&gt;
    &lt;br /&gt;
    // A layout, which tells the surface where to put nodes and edges&lt;br /&gt;
    private AbstractGraphLayout         layout;&lt;br /&gt;
&lt;br /&gt;
    // A graph of the agreement between rep and skill&lt;br /&gt;
    private OpenSequenceGraph           repSkillGraph;&lt;br /&gt;
&lt;br /&gt;
    // A graph of the running sum of the skill of the top repped agents&lt;br /&gt;
    private OpenSequenceGraph           topSkillGraph;&lt;br /&gt;
&lt;br /&gt;
    // A plot&lt;br /&gt;
    private Plot                        histPlot;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    // private OpenHistogram               wealthHist;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    // private OpenHistogram               degreeHist;&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // setup&lt;br /&gt;
    //&lt;br /&gt;
    // This runs automatically when the model starts&lt;br /&gt;
    // and when you click the reload button, to &amp;quot;tear down&amp;quot; any &lt;br /&gt;
    // existing display objects, and get ready to initialize &lt;br /&gt;
    // them at the start of the next &#039;run&#039;.&lt;br /&gt;
    //&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	// the super class does conceptual-model setup (RepMod)&lt;br /&gt;
	super.setup();  &lt;br /&gt;
	&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() begin.\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// NOTE: you may want to set these next two to &#039;true&#039;&lt;br /&gt;
	// if you are on a windows machine.  that would tell repast&lt;br /&gt;
	// to by default send System.out and .err output to&lt;br /&gt;
	// a special repast output window.&lt;br /&gt;
	AbstractGUIController.CONSOLE_ERR = false;&lt;br /&gt;
	AbstractGUIController.CONSOLE_OUT = false;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// For restart purposes, dispose of any displays&lt;br /&gt;
	if ( surface != null ) surface.dispose();&lt;br /&gt;
	if ( repSkillGraph != null ) repSkillGraph.dispose();&lt;br /&gt;
	if ( topSkillGraph != null ) topSkillGraph.dispose();&lt;br /&gt;
	//if ( wealthHist != null) wealthHist.dispose();&lt;br /&gt;
	//if ( degreeHist != null) degreeHist.dispose();&lt;br /&gt;
&lt;br /&gt;
	// Create and register the abstract surface&lt;br /&gt;
	surface = null;&lt;br /&gt;
	surface = new DisplaySurface( this, &amp;quot;Network Display&amp;quot; );&lt;br /&gt;
	registerDisplaySurface( &amp;quot;Main Display&amp;quot;, surface );&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	// Add Custom Buttons&lt;br /&gt;
	modelManipulator.init();&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Circular&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutCircular();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);						   &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Kamada&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutKamada();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Rep Sorted Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printRepSortedNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
              &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Kill All Edges&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     killAllEdges();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Plot Reputation vs. Skill&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     plotRepSkill();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() done.\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    //&lt;br /&gt;
    // This runs when you click the &amp;quot;initialize&amp;quot; button&lt;br /&gt;
    // (the button with the single arrow that goes around in a circle)&lt;br /&gt;
    // or at the first step&lt;br /&gt;
    public void begin()	{&lt;br /&gt;
	DMSG(1, &amp;quot;==&amp;gt; enter GUIModel-begin()&amp;quot; );&lt;br /&gt;
	// Set up drawables&lt;br /&gt;
	CustomNode.setUpNodeDrawing(this);&lt;br /&gt;
	CustomEdge.setUpEdgeDrawing(this);&lt;br /&gt;
	&lt;br /&gt;
	buildModel();  // Calls in the base model (RepMod)&lt;br /&gt;
	&lt;br /&gt;
	buildDisplay();  // Constructs the displays&lt;br /&gt;
	if (rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Display Built Successfully. \n&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	// Constructs the schedule; If defined in GUIModel, ignores buildSchedule in base model&lt;br /&gt;
	buildSchedule(); &lt;br /&gt;
&lt;br /&gt;
	surface.display(); // displays the surface on the display&lt;br /&gt;
&lt;br /&gt;
	writeHeaderCommentsToReportFile();&lt;br /&gt;
	&lt;br /&gt;
	DMSG(1, &amp;quot;&amp;lt;== leave GUIModel-begin() done.&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildDisplay&lt;br /&gt;
    //&lt;br /&gt;
    // builds the display and display related things&lt;br /&gt;
    //&lt;br /&gt;
    public void buildDisplay() {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;==&amp;gt; GUIModel buildDisplay...\n&amp;quot; );&lt;br /&gt;
        &lt;br /&gt;
	// Layout specifies the arrangement of nodes and edges&lt;br /&gt;
	// This specifically uses the Kamada-Kawai method&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	Network2DDisplay display = new Network2DDisplay(layout);&lt;br /&gt;
	&lt;br /&gt;
	layout.updateLayout();  // actually execute the laying out&lt;br /&gt;
&lt;br /&gt;
	// Register the layout with the display surface for drawing&lt;br /&gt;
	surface.addDisplayableProbeable(display, &amp;quot;Network Display&amp;quot;);&lt;br /&gt;
	surface.addZoomable (display);&lt;br /&gt;
	surface.setBackground (java.awt.Color.black);&lt;br /&gt;
	&lt;br /&gt;
	addSimEventListener (surface);&lt;br /&gt;
	&lt;br /&gt;
	// Makes a graph&lt;br /&gt;
	repSkillGraph = new OpenSequenceGraph(&amp;quot;RepSkillMatch&amp;quot;, this); // constructs graph&lt;br /&gt;
	repSkillGraph.setXRange(0, 2000);                     // sets ranges&lt;br /&gt;
	repSkillGraph.setYRange(-1.1, 1.1);&lt;br /&gt;
	repSkillGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;frac. match&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class repSkillSequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcRepSkillMatch();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	repSkillGraph.addSequence(&amp;quot;frace. match&amp;quot;, new repSkillSequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	repSkillGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	topSkillGraph = new OpenSequenceGraph(&amp;quot;Top Rep Skills&amp;quot;, this); // constructs graph&lt;br /&gt;
	topSkillGraph.setXRange(0, 2000);                     // sets ranges&lt;br /&gt;
	topSkillGraph.setYRange(0, 5);&lt;br /&gt;
	topSkillGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;Skills&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class topSkillSequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcTopRepSkills(5);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	topSkillGraph.addSequence(&amp;quot;Skill of Top Rep Agents&amp;quot;, new topSkillSequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	topSkillGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent wealth&lt;br /&gt;
	/*&lt;br /&gt;
	wealthHist = new OpenHistogram(&amp;quot;Agent Wealth Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	wealthHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource histSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getReputation();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	wealthHist.createHistogramItem(&amp;quot;Wealth&amp;quot;, agentList, histSource);&lt;br /&gt;
	wealthHist.display();&lt;br /&gt;
	*/&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent degree&lt;br /&gt;
	/*&lt;br /&gt;
	degreeHist = new OpenHistogram(&amp;quot;Agent Degree Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	degreeHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource degreeSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getDegree();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	degreeHist.createHistogramItem(&amp;quot;Degree&amp;quot;, agentList, degreeSource);&lt;br /&gt;
	degreeHist.display();&lt;br /&gt;
	*/&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Adds to buildSchedule in main model&lt;br /&gt;
    // Note, model-type changes should also be included in&lt;br /&gt;
    // batchmodel&#039;s buildSchedule if one wants to ever run in batch&lt;br /&gt;
    &lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	&lt;br /&gt;
	schedule = new Schedule(1);&lt;br /&gt;
	super.buildSchedule();  // Get base model schedule&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    //&lt;br /&gt;
    // Ask the super-class (RepMod) to do its step() method,&lt;br /&gt;
    // and then this does display related activities.&lt;br /&gt;
    public void step() {&lt;br /&gt;
	&lt;br /&gt;
	super.step();	  // the base model does whatever it does&lt;br /&gt;
	&lt;br /&gt;
	// add things after this for all displays (graphs, etc)&lt;br /&gt;
	drawNodes();&lt;br /&gt;
	surface.updateDisplay();&lt;br /&gt;
	repSkillGraph.step();&lt;br /&gt;
	topSkillGraph.step();&lt;br /&gt;
	//wealthHist.step();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // drawNodes&lt;br /&gt;
    // has nodes re-draw themselves based on Reputation&lt;br /&gt;
    public void drawNodes(){&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
	double maxReputation = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    if (node.getReputation() &amp;gt; maxReputation)&lt;br /&gt;
		maxReputation = node.getReputation();&lt;br /&gt;
        }&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.setNodeColorFromReputation(maxReputation);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // called once, at end of run.&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== GUIModel processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	super.addAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	super.delAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // updateLayoutAgentList&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Update layout&#039;s agentList.  Model&#039;s agentlist&lt;br /&gt;
    //  is updated with gm&#039;s (since they both point to &lt;br /&gt;
    //  the same object).  Layout is dumb, and evidently&lt;br /&gt;
    //  re-stores pointers to objects in list, rather than&lt;br /&gt;
    //  the list.&lt;br /&gt;
    public void updateLayoutAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	layout.setList(agentList); &lt;br /&gt;
	// update the layout, re-executing layout method (e.g. Kamada)&lt;br /&gt;
	layout.updateLayout(); &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutCircular&lt;br /&gt;
    // Uses circular rather than Kamada layout&lt;br /&gt;
    public void changeLayoutCircular(){&lt;br /&gt;
        layout = new CircularGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutKamada&lt;br /&gt;
    // Uses kamada-kawai layout, rather than circular&lt;br /&gt;
    public void changeLayoutKamada(){&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
    public void printNodes(){&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode aNode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %1.3f rep with skill %1.3f.\n&amp;quot;, &lt;br /&gt;
		     aNode.getID(), aNode.getReputation(), aNode.getSkill());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printRepSortedNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
&lt;br /&gt;
    public void printRepSortedNodes(){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(CustomNode agent : tempList){&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %1.3f rep with skill %1.3f.\n&amp;quot;, &lt;br /&gt;
		     agent.getID(), agent.getReputation(), agent.getSkill());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // killAllEdges&lt;br /&gt;
    // deletes all edges&lt;br /&gt;
    // Mainly used for debugging, or being a bastard&lt;br /&gt;
    public void killAllEdges(){&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.clearInEdges();&lt;br /&gt;
	    node.clearOutEdges();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // plotRepSkill()&lt;br /&gt;
    public void plotRepSkill(){&lt;br /&gt;
	Plot repSkillPlot = new Plot(&amp;quot;Reputation v. Skill&amp;quot;);&lt;br /&gt;
	repSkillPlot.display();&lt;br /&gt;
	repSkillPlot.setConnected(false);&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; numAgents; i++) {&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    repSkillPlot.plotPoint(node.getSkill(), node.getReputation(), 0);&lt;br /&gt;
	}&lt;br /&gt;
	repSkillPlot.updateGraph();&lt;br /&gt;
	repSkillPlot.setXRange(0, 1);	&lt;br /&gt;
	repSkillPlot.setYRange(0, 1);&lt;br /&gt;
	//aPlot.fillPlot();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //   ****  NO NEEd TO CHANGE THE REST OF THIS  *****&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // main entry point&lt;br /&gt;
    public static void main( String[] args ) {&lt;br /&gt;
	&lt;br /&gt;
	uchicago.src.sim.engine.SimInit init =&lt;br /&gt;
	    new uchicago.src.sim.engine.SimInit();&lt;br /&gt;
	GUIModel model = new GUIModel();&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;==&amp;gt; GUIMOdel main...\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// set the type of model class, this is necessary&lt;br /&gt;
	// so the parameters object knows whether or not&lt;br /&gt;
	// to do GUI related updates of panels,etc when a&lt;br /&gt;
	// parameter is changed&lt;br /&gt;
	model.setModelType(&amp;quot;GUIModel&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
        // Do this to set the Update Probes option to true in the&lt;br /&gt;
        // Repast Actions panel&lt;br /&gt;
        Controller.UPDATE_PROBES = true;&lt;br /&gt;
	&lt;br /&gt;
	model.setCommandLineArgs( args );&lt;br /&gt;
	init.loadModel( model, null, false ); // does setup()&lt;br /&gt;
	&lt;br /&gt;
	// this new function calls ProbeUtilities.updateProbePanels() and &lt;br /&gt;
	// ProbeUtilities.updateModelProbePanel()&lt;br /&gt;
	model.updateAllProbePanels();&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Creates a new instance of GUIModel */&lt;br /&gt;
    public GUIModel() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3640</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3640"/>
		<updated>2006-06-18T19:18:49Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0618-1320)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0618-1320)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3637</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3637"/>
		<updated>2006-06-18T18:47:35Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0618-1245)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* GUIModel.java.wp   : The GUI for the model &amp;lt;font color=green&amp;gt;(Current)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3636</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3636"/>
		<updated>2006-06-18T18:47:12Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 18, 2006 12:45 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {voteType = i;}&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {histWeight = i;}&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1000;&lt;br /&gt;
	pajekUpdateInterval    = 5000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
	calcTopRepSkills(5);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
	double skillSum = 0;&lt;br /&gt;
	CustomNode node;&lt;br /&gt;
	for (int i = numAgents -x; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    node = agentList.get(i);&lt;br /&gt;
	    skillSum += node.getSkill();&lt;br /&gt;
	}&lt;br /&gt;
	return skillSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcRepSkillMatch&lt;br /&gt;
    // inputs: none&lt;br /&gt;
    // outputs: double, the fraction of cases that a Rep and Skill match &lt;br /&gt;
    // (High/Low)&lt;br /&gt;
    public double calcRepSkillMatch(){&lt;br /&gt;
	double count = 0;&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    if (node.getReputation() &amp;lt;= 0.5 &amp;amp; node.getSkill() &amp;lt;= 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (node.getReputation() &amp;gt; 0.5 &amp;amp; node.getSkill() &amp;gt; 0.5){&lt;br /&gt;
		count ++;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	return count / ((double) numAgents); &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3635</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3635"/>
		<updated>2006-06-18T18:46:47Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0618-1245)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3634</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3634"/>
		<updated>2006-06-18T18:38:01Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* RepMod.java.wp     : The main model &amp;lt;font color=green&amp;gt;(Current)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3584</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3584"/>
		<updated>2006-06-17T23:29:43Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
Jack Waddell at June 17, at 5:20pm, for instance, is indicated &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3583</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3583"/>
		<updated>2006-06-17T23:28:41Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
The code for our model.  Last modifications indicated in green.&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3582</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3582"/>
		<updated>2006-06-17T23:28:05Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model &amp;lt;font color=green&amp;gt;(JNW:0617-1720)&amp;lt;/font&amp;gt;&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) &amp;lt;font color=green&amp;gt;(JNW:0612-0000)&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3581</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3581"/>
		<updated>2006-06-17T23:27:00Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model (JNW:0617-1720)&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class. (JNW:0617-1720)&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class. (JNW:0617-1720)&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network. (JNW:0617-1720)&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model (JNW:0617-1720)&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s) (JNW:0612-0000)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3580</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3580"/>
		<updated>2006-06-17T23:25:36Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation. Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes. Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3579</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3579"/>
		<updated>2006-06-17T23:25:14Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* --CompNodeRep.java--   : Out moded. The comparator for sorting by reputation.&lt;br /&gt;
                             Absorbed as inner class into RepMod&lt;br /&gt;
* --GameMaster.java.wp-- : Out moded. The class that organizes the votes.&lt;br /&gt;
                             Methods absorbed into CustomNode and RepMod.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3578</id>
		<title>RepMod.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=RepMod.java.wp&amp;diff=3578"/>
		<updated>2006-06-17T23:23:36Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * RepMod.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 17, 2006 17:20 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class RepMod extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt; (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public CompNodeRep compNodes;       // compares node reputations&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
    // the degree to weight the voter&#039;s historical opinion vs. new opinion&lt;br /&gt;
    public double histWeight; &lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public int voteType;&lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of RepMod */&lt;br /&gt;
    public RepMod() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;vT&amp;quot;, &amp;quot;voteType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;hW&amp;quot;, &amp;quot;histWeight&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;, &amp;quot;voteType&amp;quot;,&lt;br /&gt;
			    &amp;quot;histWeight&amp;quot;, &lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {numAgents = i;}&lt;br /&gt;
&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
    &lt;br /&gt;
    public void setVoteType(int i) {voteType = i;}&lt;br /&gt;
    public int  getVoteType() {return voteType;}&lt;br /&gt;
&lt;br /&gt;
    public void   setHistWeight(double i) {histWeight = i;}&lt;br /&gt;
    public double getHistWeight() {return histWeight;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// set static parameters in node class&lt;br /&gt;
	CustomNode.setHistWeight(histWeight);&lt;br /&gt;
	CustomNode.setVoteType(voteType);&lt;br /&gt;
&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	compNodes = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1000;&lt;br /&gt;
	pajekUpdateInterval    = 5000;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	voteType = 0;&lt;br /&gt;
	histWeight = 0;&lt;br /&gt;
&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	stepNodes();&lt;br /&gt;
	calcTopRepSkills(5);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    //  Has each vote for neighbors, then has each calculation&lt;br /&gt;
    //   own reputation.&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.voteAll();&lt;br /&gt;
	}&lt;br /&gt;
	for(CustomNode node : agentList){&lt;br /&gt;
	    node.calcReputation();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgReputation()&lt;br /&gt;
    public double calcAvgReputation(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getReputation();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSkills&lt;br /&gt;
    // inputs: int x, the number of top agents include&lt;br /&gt;
    // outputs: double, the reputation of the top x agents&lt;br /&gt;
    //  This calculates the sum of the skils of the top x agents&lt;br /&gt;
    public double calcTopRepSkills(int x){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compNodes);&lt;br /&gt;
&lt;br /&gt;
	for(CustomNode agent : tempList){&lt;br /&gt;
	    &lt;br /&gt;
	    System.out.printf(&amp;quot;Agent %d has rep %f\n&amp;quot;, agent.getID(), agent.getReputation());&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        RepMod model = new RepMod ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Inner classes&lt;br /&gt;
&lt;br /&gt;
    private class CompNodeRep implements Comparator{&lt;br /&gt;
	&lt;br /&gt;
	public CompNodeRep(){&lt;br /&gt;
	}&lt;br /&gt;
	public int compare(Object o1, Object o2){&lt;br /&gt;
	    CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	    CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	    if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
		return -1;&lt;br /&gt;
	    else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
		return 1;&lt;br /&gt;
	    else&lt;br /&gt;
		return 0;&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=Network.java.wp&amp;diff=3577</id>
		<title>Network.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=Network.java.wp&amp;diff=3577"/>
		<updated>2006-06-17T23:22:38Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * Network.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 18, 2005, 4:09 PM&lt;br /&gt;
 * Modified June 17, 2006 17:20, by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class generates a network, runs some&lt;br /&gt;
 * net statistics, and writes it to a pajek-formatted file&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
//import java.util.Random;&lt;br /&gt;
import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
import uchicago.src.sim.network.EdgeFactory;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import rlriolo.ioutils.*;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Vector;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class Network {&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // static parameters&lt;br /&gt;
&lt;br /&gt;
    // the main model&lt;br /&gt;
    public static RepMod model;&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
    public int[][]     adjacencyMatrix;  // Yes, it is Aij = 1 if j -&amp;gt; i.&lt;br /&gt;
    public int         networkSize;      // The number of agents&lt;br /&gt;
    public int         connectRadius;    // The radius for grid or SWN inits&lt;br /&gt;
    public double      reconnectProb;    // The prob or (re)wiring in (SWN) or random net&lt;br /&gt;
    // a pointer to the agent list,&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
    &lt;br /&gt;
    // These are for writing a pajek-formatted file&lt;br /&gt;
    protected String		pajekFileName = &amp;quot;pajek&amp;quot;;&lt;br /&gt;
    protected String 		outputDirName = &amp;quot;./&amp;quot;;&lt;br /&gt;
    protected PrintWriter	pajekFile, plaintextPajekFile;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public Network(int networkSize, int connectRadius, double reconnectProb){&lt;br /&gt;
	this.networkSize = networkSize;&lt;br /&gt;
	this.connectRadius = connectRadius;&lt;br /&gt;
	this.reconnectProb = reconnectProb;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAdjacencyMatrix&lt;br /&gt;
    // Inputs: int netType, selects which specific type of matrix to form&lt;br /&gt;
    // Outputs: int[][], the adjacency matrix&lt;br /&gt;
    public int[][] buildAdjacencyMatrix(int netType){&lt;br /&gt;
	switch(netType){&lt;br /&gt;
	case 0 : return buildAdjacencyMatrix2DWS();&lt;br /&gt;
	case 1 : return buildAdjacencyMatrixWS();&lt;br /&gt;
	case 2 : return buildAdjacencyMatrixRand();&lt;br /&gt;
	default: return buildAdjacencyMatrix2DWS();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrixWS&lt;br /&gt;
    // Develops an adjacency matrix for a Watts-Strogatz Small World &lt;br /&gt;
    // network based on the given parameters.  Note that this &lt;br /&gt;
    // implementation uses a disconnecting rewire, so that it is&lt;br /&gt;
    // possible to disconnect groups in the network.  It is also &lt;br /&gt;
    // possible to have less than an average degree of 2x connectRadius, &lt;br /&gt;
    // since a connection can be &amp;quot;overwritten&amp;quot; during the rewire.&lt;br /&gt;
    //&lt;br /&gt;
    //  Inputs:  double reconnectProb:  each neighbor connection &lt;br /&gt;
    // has a probability p of being disconnected from the outgoing side (i) &lt;br /&gt;
    // and reattached to a random node (including the one from which it &lt;br /&gt;
    // was just disconnected, and any other nodes that j goes to.)]&lt;br /&gt;
    // connectRadius: the number of neighbors to either side of each node.  &lt;br /&gt;
    // Note that this often leads to cycles.&lt;br /&gt;
    &lt;br /&gt;
    public int[][] buildAdjacencyMatrixWS(){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
	&lt;br /&gt;
	// Make the regular gride&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = i; j&amp;lt; networkSize; j++){&lt;br /&gt;
                if( (j &amp;lt;= (i + connectRadius) ) &amp;amp;&amp;amp; (i!=j) ){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                else if( (j &amp;gt;= (networkSize - connectRadius + i) ) &amp;amp;&amp;amp; (i!=j)){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                else{&lt;br /&gt;
                    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
	// Do random rewiring&lt;br /&gt;
	double randomDouble;        &lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 1; j &amp;lt; networkSize; j++){&lt;br /&gt;
                randomDouble = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
                if((randomDouble &amp;lt; reconnectProb)&amp;amp;&amp;amp;&lt;br /&gt;
		                 (adjacencyMatrix[i][j]==1)){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
		    int randomi = j;&lt;br /&gt;
		    do{&lt;br /&gt;
			randomi = model.getUniformIntFromTo(0, networkSize - 1);&lt;br /&gt;
			if(model.rDebug &amp;gt; 2)&lt;br /&gt;
			    System.out.printf(&amp;quot;j = %d, randomi = %d, A[i][j] = %d\n&amp;quot;,&lt;br /&gt;
					      j,randomi, adjacencyMatrix[randomi][j]);&lt;br /&gt;
		    } while (randomi == j || adjacencyMatrix[randomi][j] ==1);&lt;br /&gt;
		    &lt;br /&gt;
		    adjacencyMatrix[randomi][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][randomi] = 1;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrix2DWS&lt;br /&gt;
    // Develops an adjacency matrix for a Toroidal - Watts-Strogatz Small &lt;br /&gt;
    // World network based on the given parameters.  Note that this &lt;br /&gt;
    // implementation uses a disconnecting rewire, so that it is&lt;br /&gt;
    // possible to disconnect groups in the network. &lt;br /&gt;
    public int[][] buildAdjacencyMatrix2DWS(){&lt;br /&gt;
        // Make regular grid&lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int ix, iy, jx, jy;&lt;br /&gt;
        int size = (int) Math.floor(Math.sqrt(networkSize));&lt;br /&gt;
        System.out.printf(&amp;quot;Size = %d \n&amp;quot;, size);&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = i; j&amp;lt; networkSize; j++){&lt;br /&gt;
                &lt;br /&gt;
                ix = i % size;&lt;br /&gt;
                iy = i / size;&lt;br /&gt;
                &lt;br /&gt;
                jx = j % size;&lt;br /&gt;
                jy = j / size;&lt;br /&gt;
                &lt;br /&gt;
                double dx = Math.min( Math.min( Math.pow(jx - ix,2), &lt;br /&gt;
						Math.pow(jx + size - ix, 2)), &lt;br /&gt;
				      Math.pow(jx - size - ix, 2) );&lt;br /&gt;
                double dy = Math.min( Math.min( Math.pow(jy - iy,2), &lt;br /&gt;
						Math.pow(jy + size - iy, 2)), &lt;br /&gt;
				      Math.pow(jy - size - iy, 2) );&lt;br /&gt;
&lt;br /&gt;
                if( (Math.sqrt(dx + dy) &amp;lt;= (connectRadius) ) &amp;amp;&amp;amp; (i!=j) ){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                &lt;br /&gt;
                else{&lt;br /&gt;
                    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        double randomDouble;&lt;br /&gt;
        // Do random rewiring&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 1; j &amp;lt; networkSize; j++){&lt;br /&gt;
                randomDouble = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
                if((randomDouble &amp;lt; reconnectProb)&amp;amp;&amp;amp;&lt;br /&gt;
		                    (adjacencyMatrix[i][j]==1)){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
		    int randomi = j;&lt;br /&gt;
		    do{&lt;br /&gt;
			randomi = model.getUniformIntFromTo(0, networkSize - 1);&lt;br /&gt;
			if(model.rDebug &amp;gt; 2)&lt;br /&gt;
			    System.out.printf(&amp;quot;j = %d, randomi = %d, A[i][j] = %d\n&amp;quot;,&lt;br /&gt;
					  j,randomi, adjacencyMatrix[randomi][j]);&lt;br /&gt;
		    } while (randomi == j || adjacencyMatrix[randomi][j] ==1);&lt;br /&gt;
		    &lt;br /&gt;
		    adjacencyMatrix[randomi][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][randomi] = 1;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished 2DWS Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrixStar&lt;br /&gt;
    // Develops an adjacency matrix for a Star Network, centered on i.&lt;br /&gt;
    public int[][] buildAdjacencyMatrixStar(int i){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int ix, iy, jx, jy;&lt;br /&gt;
        for(int k = 0; k &amp;lt; networkSize; k++){&lt;br /&gt;
	    for(int j = 0; j&amp;lt; networkSize; j++){&lt;br /&gt;
		adjacencyMatrix[k][j] = 0;&lt;br /&gt;
		adjacencyMatrix[j][k] = 0;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
        &lt;br /&gt;
	for(int j = 0; j&amp;lt; networkSize; j++){&lt;br /&gt;
	    if(i!=j){&lt;br /&gt;
		adjacencyMatrix[i][j] = 1;&lt;br /&gt;
		adjacencyMatrix[j][i] = 1;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished Star Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAdjacencyMatrixRand&lt;br /&gt;
    // Develops a symmetric, random adjacency matrix, so that the&lt;br /&gt;
    //  probability of an edge existing between any pair of nodes is&lt;br /&gt;
    //  reconnectProb.&lt;br /&gt;
    public int[][] buildAdjacencyMatrixRand(){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int i, j;&lt;br /&gt;
	double randn;&lt;br /&gt;
        for(i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
	    for(j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
		randn = model.getUniformDoubleFromTo(0, 1);&lt;br /&gt;
		&lt;br /&gt;
		if (randn &amp;lt; reconnectProb){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
		}&lt;br /&gt;
		//else&lt;br /&gt;
		//    System.out.printf(&amp;quot;Randn = %f vs %f\n&amp;quot;, randn, reconnectProb);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
        &lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished Random Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAgentList&lt;br /&gt;
    // Develops an arrayList of CustomNodes interconnected based on the&lt;br /&gt;
    // adjacency matrix developed.&lt;br /&gt;
    public void buildAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	// Create all the agents&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            OvalNetworkItem drawable = new OvalNetworkItem(0,0);&lt;br /&gt;
	    &lt;br /&gt;
	    double skill = model.getUniformDoubleFromTo(0, 1);&lt;br /&gt;
	    &lt;br /&gt;
            CustomNode agent = new CustomNode(drawable, skill);&lt;br /&gt;
            agentList.add(agent);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
	// Create the edges between them, governed by the adjacency&lt;br /&gt;
	//  matrix&lt;br /&gt;
        CustomEdge edge;&lt;br /&gt;
        double cc;&lt;br /&gt;
        CustomNode jnode, inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
                if(adjacencyMatrix[i][j] == 1){&lt;br /&gt;
                    jnode = (CustomNode) agentList.get(j);&lt;br /&gt;
                    inode = (CustomNode) agentList.get(i);&lt;br /&gt;
                    edge = new CustomEdge(jnode, inode);&lt;br /&gt;
                    jnode.addOutEdge(edge);&lt;br /&gt;
                    inode.addInEdge(edge);&lt;br /&gt;
&lt;br /&gt;
		    // This symmetritizes the network&lt;br /&gt;
		    // i.e. makes undirected&lt;br /&gt;
		    edge = new CustomEdge(inode, jnode);&lt;br /&gt;
		    inode.addOutEdge(edge);&lt;br /&gt;
		    jnode.addInEdge(edge);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // printAdjacencyMatrix&lt;br /&gt;
    // a debugging tool.  Prints the adjacency matrix to the terminal&lt;br /&gt;
    public void printAdjacencyMatrix(){&lt;br /&gt;
        System.out.printf(&amp;quot;--- Printing Adjacency Matrix, size %d ---\n&amp;quot;, &lt;br /&gt;
			  networkSize);&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, adjacencyMatrix[i][j]);&lt;br /&gt;
            }&lt;br /&gt;
            System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // writePajekNetwork&lt;br /&gt;
    // Writes the network to a file in pajek&lt;br /&gt;
    //  format.  Note: this version writes DOS type line feeds.&lt;br /&gt;
    public void writePajekNetwork(ArrayList&amp;lt;CustomNode&amp;gt; agentList){&lt;br /&gt;
	String verts, arcs;&lt;br /&gt;
	// These are carriage return and line feed in DOS format.&lt;br /&gt;
	char cr = (char) 13;&lt;br /&gt;
	char lf = (char) 10;&lt;br /&gt;
	&lt;br /&gt;
	// pajek requires the vertices and arcs separately.&lt;br /&gt;
	verts = String.format(&amp;quot;*Vertices %d%c%c&amp;quot;, networkSize, cr, lf);	&lt;br /&gt;
	arcs = String.format(&amp;quot;*Arcs %c%c&amp;quot;, cr, lf);&lt;br /&gt;
	&lt;br /&gt;
	// step through all nodes&lt;br /&gt;
	for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
	    CustomNode inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    verts += String.format(&amp;quot;%d \&amp;quot;N%d: %f\&amp;quot;&amp;quot;,&lt;br /&gt;
		   inode.getID() + 1, inode.getID(), inode.getReputation());&lt;br /&gt;
	   &lt;br /&gt;
	    verts += String.format(&amp;quot; ic %s%c%c&amp;quot;, inode.getMyPajekColor(),cr, lf);&lt;br /&gt;
	    &lt;br /&gt;
	    ArrayList edgesInList = inode.getInEdges();&lt;br /&gt;
	    int numEdges = edgesInList.size();&lt;br /&gt;
	    CustomNode testNode = (CustomNode) (model.agentList).get(i);&lt;br /&gt;
	    if (testNode != inode)&lt;br /&gt;
		System.out.printf(&amp;quot;Nodes(%d) not equal\n&amp;quot;, i);&lt;br /&gt;
	    if ( (testNode.getOutDegree() != inode.getOutDegree()) || (testNode.getInDegree() != inode.getInDegree()))&lt;br /&gt;
		System.out.printf(&amp;quot;Nodes(%d) have different degree\n&amp;quot;, i);&lt;br /&gt;
	    if (numEdges &amp;gt; 0)&lt;br /&gt;
		// if node has at least one neighbor, write the edges&lt;br /&gt;
		for(int j = 0;  j &amp;lt; numEdges; j++){&lt;br /&gt;
		    CustomEdge edge = (CustomEdge)edgesInList.get(j);&lt;br /&gt;
		    arcs += String.format(&amp;quot;%d %d %c%c&amp;quot;,&lt;br /&gt;
			    ((CustomNode)edge.getFrom()).getID() + 1,&lt;br /&gt;
			    ((CustomNode)edge.getTo()).getID() + 1, cr, lf);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	String s = verts + arcs;&lt;br /&gt;
	writeToPajekFile(s);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeLineToPajekFile&lt;br /&gt;
    // writes a single line to the pajek file&lt;br /&gt;
    public void writeLineToPajekFile ( String line ) {&lt;br /&gt;
	if ( pajekFile == null ) {&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    pajekFile.println( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // writeToPajekFile&lt;br /&gt;
    // Does the same.&lt;br /&gt;
    public void writeToPajekFile ( String line ) {&lt;br /&gt;
	if ( pajekFile == null ) {&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    pajekFile.print( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // startPajekFile&lt;br /&gt;
    // opens a file to write the pajek network to.&lt;br /&gt;
    public PrintWriter startPajekFile () {&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile called!&amp;quot; );&lt;br /&gt;
	pajekFile = null;&lt;br /&gt;
	String fullFileName = pajekFileName + String.format( &amp;quot;%02d.net&amp;quot;,&lt;br /&gt;
			      model.runNumber );&lt;br /&gt;
	&lt;br /&gt;
	pajekFile = IOUtils.openFileToWrite( outputDirName, fullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile completed!&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	return pajekFile;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // startPajekFile - overload&lt;br /&gt;
    // opens a file to write the pajek network to.  Calls it&lt;br /&gt;
    // by integer i&lt;br /&gt;
    public PrintWriter startPajekFile (int i) {&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile called!&amp;quot; );&lt;br /&gt;
	pajekFile = null;&lt;br /&gt;
	String fullFileName = pajekFileName + String.format(&lt;br /&gt;
			     &amp;quot;%03d.%02d.net&amp;quot;, i, model.runNumber );&lt;br /&gt;
	&lt;br /&gt;
	pajekFile = IOUtils.openFileToWrite( outputDirName, &lt;br /&gt;
					     fullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile completed!&amp;quot; );&lt;br /&gt;
	return pajekFile;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // endPajekFile&lt;br /&gt;
    // closes the open pajekFile&lt;br /&gt;
    public void endPajekFile ( ) {&lt;br /&gt;
	IOUtils.closePWFile( pajekFile );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getAverageCC1&lt;br /&gt;
    // Calculates the average 1-neighborhood clustering coefficient&lt;br /&gt;
    public double getAverageCC1(){&lt;br /&gt;
	CustomNode node = null;&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i ++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += getNodeCC1(node);&lt;br /&gt;
	}&lt;br /&gt;
	return sum / (double) agentList.size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getAverageCC2&lt;br /&gt;
    // Calculates the average 2-neighborhood clustering coefficient&lt;br /&gt;
    public double getAverageCC2(){&lt;br /&gt;
	CustomNode node = null;&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i ++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += getNodeCC2(node);&lt;br /&gt;
	}&lt;br /&gt;
	return sum / (double) agentList.size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // union&lt;br /&gt;
    // Support function.&lt;br /&gt;
    // Returns the union of two array lists of nodes&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; union(ArrayList&amp;lt;CustomNode&amp;gt; l1, &lt;br /&gt;
				       ArrayList&amp;lt;CustomNode&amp;gt; l2){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; unionList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	unionList.addAll(l1);&lt;br /&gt;
	for(int i = 0; i &amp;lt; l2.size(); i ++){&lt;br /&gt;
	    CustomNode node = (CustomNode) l2.get(i);&lt;br /&gt;
	    if (!unionList.contains(node))&lt;br /&gt;
		unionList.add(node);&lt;br /&gt;
	}&lt;br /&gt;
	return unionList;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // intersection&lt;br /&gt;
    // Support function&lt;br /&gt;
    // Return the intersection of two array lists of nodes&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; intersection(ArrayList&amp;lt;CustomNode&amp;gt; l1, &lt;br /&gt;
				       ArrayList&amp;lt;CustomNode&amp;gt; l2){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; interList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	for(int i = 0; i &amp;lt; l1.size(); i ++){&lt;br /&gt;
	    CustomNode node = (CustomNode) l1.get(i);&lt;br /&gt;
	    if (l2.indexOf(node) &amp;gt;-1)&lt;br /&gt;
		interList.add(node);&lt;br /&gt;
	}&lt;br /&gt;
	return interList;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // getNodeCC1&lt;br /&gt;
    // Computes the clustering coefficient CC1, as per Pajek documentation&lt;br /&gt;
    // This is the 1-neighborhood clustering coefficient&lt;br /&gt;
    public double getNodeCC1 (CustomNode node){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighborsList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	// Get all neighbors&lt;br /&gt;
	neighborsList = union(node.getOutNodes(), node.getInNodes());&lt;br /&gt;
	int sum = 0;&lt;br /&gt;
	int k = neighborsList.size();&lt;br /&gt;
	for(int j = 0; j &amp;lt; k; j ++){&lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighborsList.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
	    &lt;br /&gt;
	    sum += (intersection(nOut, neighborsList)).size();&lt;br /&gt;
	    sum += (intersection(nIn, neighborsList)).size();&lt;br /&gt;
	   &lt;br /&gt;
	}&lt;br /&gt;
	double cc1 = 0;&lt;br /&gt;
	if (k &amp;gt; 1)&lt;br /&gt;
	    cc1 = (double)sum/( 2* (double)k * (double)(k-1));&lt;br /&gt;
	return cc1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // getNodeCC2&lt;br /&gt;
    // computes the clustering coefficient CC2, as per Pajek documentation&lt;br /&gt;
    // E(G1(v))/E(G2(v))&lt;br /&gt;
    // This is the 2-neighboorhood clustering coefficient&lt;br /&gt;
    public double getNodeCC2 (CustomNode node){&lt;br /&gt;
	&lt;br /&gt;
	// calc E(G1(v)) = sum1&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighbors1List = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighbors2List = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	neighbors1List = union(node.getOutNodes(), node.getInNodes());&lt;br /&gt;
	neighbors2List.addAll(neighbors1List);&lt;br /&gt;
&lt;br /&gt;
	int sum1 = 0;&lt;br /&gt;
	int k = neighbors1List.size();&lt;br /&gt;
	for(int j = 0; j &amp;lt; k; j ++){&lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighbors1List.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
	    &lt;br /&gt;
	    sum1 += (intersection(nOut, neighbors1List)).size();&lt;br /&gt;
	    //sum1 += (intersection(nIn, neighbors1List)).size();&lt;br /&gt;
&lt;br /&gt;
	    neighbors2List = union(neighbors2List, union(nOut, nIn));&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;For node %d sum1 = %d\n&amp;quot;, node.getID(), sum1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	int index = neighbors2List.indexOf(node);&lt;br /&gt;
	while (index &amp;gt; 0){&lt;br /&gt;
	    //System.out.printf(&amp;quot;node index = %d\n&amp;quot;, index);&lt;br /&gt;
	    neighbors2List.remove(index);&lt;br /&gt;
	    index = neighbors2List.indexOf(node);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// calc E(G2(v)) = sum2&lt;br /&gt;
	int sum2 = 0;&lt;br /&gt;
	int ind1, ind2;&lt;br /&gt;
	for(int j = 0; j &amp;lt; neighbors2List.size(); j++){&lt;br /&gt;
	    &lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighbors2List.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
&lt;br /&gt;
	    sum2 += (intersection(nOut, neighbors2List)).size();&lt;br /&gt;
	    //sum2 += (intersection(nIn, neighbors2List)).size();&lt;br /&gt;
&lt;br /&gt;
	    ind1 = neighbors2List.indexOf(jnode);&lt;br /&gt;
	    ind2 = neighbors2List.lastIndexOf(jnode);&lt;br /&gt;
	    if (ind1 != ind2)&lt;br /&gt;
		System.out.printf (&amp;quot;Node %d in list multiple times\n&amp;quot;, jnode.getID());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;For node %d sum1 = %d\n&amp;quot;, node.getID(), sum2);&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	double cc2 = 0;&lt;br /&gt;
	if (sum2 &amp;gt; 0)&lt;br /&gt;
	    cc2 = (double)sum1/(double)sum2;&lt;br /&gt;
	return cc2;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // printList&lt;br /&gt;
    // Debug tool&lt;br /&gt;
    // Prints the contents of an ArrayList&lt;br /&gt;
    public void printList(ArrayList&amp;lt;CustomNode&amp;gt; list){&lt;br /&gt;
	for(int i = 0; i &amp;lt; list.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) list.get(i);&lt;br /&gt;
	    System.out.printf(&amp;quot;%d, &amp;quot;, node.getID());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // PickRandomEdge&lt;br /&gt;
    // Picks a random edge with uniform probability in O(m/(n*n))&lt;br /&gt;
    //   (I think)&lt;br /&gt;
    public CustomEdge pickRandomEdge(){&lt;br /&gt;
	CustomEdge edge = null;&lt;br /&gt;
	CustomNode inode;&lt;br /&gt;
	CustomNode jnode;&lt;br /&gt;
	do{&lt;br /&gt;
	    inode = agentList.get(model.getUniformIntFromTo(0, agentList.size() -1));&lt;br /&gt;
	    do{&lt;br /&gt;
		jnode = agentList.get(model.getUniformIntFromTo(0, agentList.size() -1));&lt;br /&gt;
	    } while (inode == jnode);&lt;br /&gt;
	    &lt;br /&gt;
	    if ( (jnode.getOutNodes()).contains(inode))&lt;br /&gt;
		edge = getEdgeFromTo(jnode, inode);&lt;br /&gt;
	} while (edge == null);&lt;br /&gt;
	return edge;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // selectRandomUncoupledPair&lt;br /&gt;
    // Selectrs a random pair of nodes with uniform probability.&lt;br /&gt;
    public CustomNode[] selectRandomUncoupledPair(){&lt;br /&gt;
	boolean pass = false;&lt;br /&gt;
	CustomNode inode, jnode;&lt;br /&gt;
	int i, j;&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	do{&lt;br /&gt;
	    i = model.getUniformIntFromTo(0, agentList.size() -1);&lt;br /&gt;
	    do{&lt;br /&gt;
		j = model.getUniformIntFromTo(0, agentList.size() -1);	&lt;br /&gt;
	    } while (i == j);&lt;br /&gt;
		&lt;br /&gt;
	    inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    jnode = (CustomNode) agentList.get(j);&lt;br /&gt;
	    if ( !(jnode.getOutNodes()).contains(inode)){&lt;br /&gt;
		pass = true;&lt;br /&gt;
	    }&lt;br /&gt;
	} while (!pass);&lt;br /&gt;
	CustomNode[] nodes = {inode, jnode};&lt;br /&gt;
	return nodes;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // selectRandomUncoupledNode&lt;br /&gt;
    // &lt;br /&gt;
    public CustomNode selectRandomUncoupledNode(CustomNode jnode){&lt;br /&gt;
	boolean pass = false;&lt;br /&gt;
	CustomNode inode = null;&lt;br /&gt;
	int i, j = jnode.getID();&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	// get a list of the nodes, but make sure it isn&#039;t the main list&lt;br /&gt;
	// &#039;cause we&#039;re gonna shuffle it&lt;br /&gt;
	ArrayList &amp;lt;CustomNode&amp;gt; nodesList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	nodesList.addAll(agentList);&lt;br /&gt;
	SimUtilities.shuffle(nodesList, Random.uniform);&lt;br /&gt;
	&lt;br /&gt;
	i = 0;&lt;br /&gt;
	int k = 0;&lt;br /&gt;
	do{&lt;br /&gt;
	    &lt;br /&gt;
	    inode = (CustomNode) nodesList.get(i);&lt;br /&gt;
	    if (inode != jnode){&lt;br /&gt;
		if ( !(jnode.getOutNodes()).contains(inode)){&lt;br /&gt;
		    pass = true;&lt;br /&gt;
		}&lt;br /&gt;
	    }&lt;br /&gt;
	    i++;&lt;br /&gt;
	    if (i == nodesList.size()){&lt;br /&gt;
		i = 0;&lt;br /&gt;
		k ++;&lt;br /&gt;
	    }&lt;br /&gt;
	} while ( !pass &amp;amp;&amp;amp; k &amp;lt; 2 );&lt;br /&gt;
&lt;br /&gt;
	if (k == 2){&lt;br /&gt;
	    do{&lt;br /&gt;
		i = model.getUniformIntFromTo(0, agentList.size() - 1);&lt;br /&gt;
		inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    } while ( i == j || (jnode.getOutNodes()).contains(inode));&lt;br /&gt;
	}&lt;br /&gt;
	return inode;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    public String getPajekFileName () { return pajekFileName; }&lt;br /&gt;
    public void setPajekFileName ( String s ) {&lt;br /&gt;
	pajekFileName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    public String getOutputDirName () { return outputDirName; }&lt;br /&gt;
    public void setOutputDirName ( String s ) {&lt;br /&gt;
	outputDirName = s;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public int getNetworkSize() {return networkSize;}&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public PrintWriter getPajekFile () { return pajekFile; }&lt;br /&gt;
    &lt;br /&gt;
    public CustomEdge getEdgeFromTo(CustomNode jnode, CustomNode inode){&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	HashSet edgeList = inode.getEdgesFrom(jnode);&lt;br /&gt;
	Object[] edges = edgeList.toArray();&lt;br /&gt;
	// get the edge object connected to jnode&lt;br /&gt;
	edge = ((CustomEdge)edges[0]);&lt;br /&gt;
	return edge;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //**************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
    public static void setModel(RepMod m){model = m;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3576</id>
		<title>GUIModel.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GUIModel.java.wp&amp;diff=3576"/>
		<updated>2006-06-17T23:22:00Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * GUIModel.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 30, 2005, 12:21 PM&lt;br /&gt;
 * Modified June 17, 2006 17:20 by Jack&lt;br /&gt;
 * This runs the graphical interface for the RepMod model&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.Value2DDisplay;&lt;br /&gt;
import uchicago.src.sim.space.Object2DTorus;&lt;br /&gt;
import uchicago.src.sim.engine.AbstractGUIController;&lt;br /&gt;
import uchicago.src.sim.analysis.*;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class GUIModel extends RepMod{&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance Parameters&lt;br /&gt;
&lt;br /&gt;
    // The actual display surface, where things are put on the screen&lt;br /&gt;
    private DisplaySurface              surface;&lt;br /&gt;
    &lt;br /&gt;
    // A layout, which tells the surface where to put nodes and edges&lt;br /&gt;
    private AbstractGraphLayout         layout;&lt;br /&gt;
&lt;br /&gt;
    // A graph&lt;br /&gt;
    private OpenSequenceGraph           reputationGraph;&lt;br /&gt;
&lt;br /&gt;
    // A plot&lt;br /&gt;
    private Plot                        histPlot;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    private OpenHistogram               wealthHist;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    private OpenHistogram               degreeHist;&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // setup&lt;br /&gt;
    //&lt;br /&gt;
    // This runs automatically when the model starts&lt;br /&gt;
    // and when you click the reload button, to &amp;quot;tear down&amp;quot; any &lt;br /&gt;
    // existing display objects, and get ready to initialize &lt;br /&gt;
    // them at the start of the next &#039;run&#039;.&lt;br /&gt;
    //&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	// the super class does conceptual-model setup (RepMod)&lt;br /&gt;
	super.setup();  &lt;br /&gt;
	&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() begin.\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// NOTE: you may want to set these next two to &#039;true&#039;&lt;br /&gt;
	// if you are on a windows machine.  that would tell repast&lt;br /&gt;
	// to by default send System.out and .err output to&lt;br /&gt;
	// a special repast output window.&lt;br /&gt;
	AbstractGUIController.CONSOLE_ERR = false;&lt;br /&gt;
	AbstractGUIController.CONSOLE_OUT = false;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// For restart purposes, dispose of any displays&lt;br /&gt;
	if ( surface != null ) surface.dispose();&lt;br /&gt;
	if ( reputationGraph != null ) reputationGraph.dispose();&lt;br /&gt;
	if ( wealthHist != null) wealthHist.dispose();&lt;br /&gt;
	if ( degreeHist != null) degreeHist.dispose();&lt;br /&gt;
&lt;br /&gt;
	// Create and register the abstract surface&lt;br /&gt;
	surface = null;&lt;br /&gt;
	surface = new DisplaySurface( this, &amp;quot;Network Display&amp;quot; );&lt;br /&gt;
	registerDisplaySurface( &amp;quot;Main Display&amp;quot;, surface );&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	// Add Custom Buttons&lt;br /&gt;
	modelManipulator.init();&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Circular&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutCircular();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);						   &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Kamada&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutKamada();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
              &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Kill All Edges&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     killAllEdges();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Plot Reputation vs. Skill&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     plotRepSkill();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() done.\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    //&lt;br /&gt;
    // This runs when you click the &amp;quot;initialize&amp;quot; button&lt;br /&gt;
    // (the button with the single arrow that goes around in a circle)&lt;br /&gt;
    // or at the first step&lt;br /&gt;
    public void begin()	{&lt;br /&gt;
	DMSG(1, &amp;quot;==&amp;gt; enter GUIModel-begin()&amp;quot; );&lt;br /&gt;
	// Set up drawables&lt;br /&gt;
	CustomNode.setUpNodeDrawing(this);&lt;br /&gt;
	CustomEdge.setUpEdgeDrawing(this);&lt;br /&gt;
	&lt;br /&gt;
	buildModel();  // Calls in the base model (RepMod)&lt;br /&gt;
	&lt;br /&gt;
	buildDisplay();  // Constructs the displays&lt;br /&gt;
	if (rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Display Built Successfully. \n&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	// Constructs the schedule; If defined in GUIModel, ignores buildSchedule in base model&lt;br /&gt;
	buildSchedule(); &lt;br /&gt;
&lt;br /&gt;
	surface.display(); // displays the surface on the display&lt;br /&gt;
&lt;br /&gt;
	writeHeaderCommentsToReportFile();&lt;br /&gt;
	&lt;br /&gt;
	DMSG(1, &amp;quot;&amp;lt;== leave GUIModel-begin() done.&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildDisplay&lt;br /&gt;
    //&lt;br /&gt;
    // builds the display and display related things&lt;br /&gt;
    //&lt;br /&gt;
    public void buildDisplay() {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;==&amp;gt; GUIModel buildDisplay...\n&amp;quot; );&lt;br /&gt;
        &lt;br /&gt;
	// Layout specifies the arrangement of nodes and edges&lt;br /&gt;
	// This specifically uses the Kamada-Kawai method&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	Network2DDisplay display = new Network2DDisplay(layout);&lt;br /&gt;
	&lt;br /&gt;
	layout.updateLayout();  // actually execute the laying out&lt;br /&gt;
&lt;br /&gt;
	// Register the layout with the display surface for drawing&lt;br /&gt;
	surface.addDisplayableProbeable(display, &amp;quot;Network Display&amp;quot;);&lt;br /&gt;
	surface.addZoomable (display);&lt;br /&gt;
	surface.setBackground (java.awt.Color.black);&lt;br /&gt;
	&lt;br /&gt;
	addSimEventListener (surface);&lt;br /&gt;
	&lt;br /&gt;
	// Makes a graph&lt;br /&gt;
	reputationGraph = new OpenSequenceGraph(&amp;quot;Reputation&amp;quot;, this); // constructs graph&lt;br /&gt;
	reputationGraph.setXRange(0, 200000);                     // sets ranges&lt;br /&gt;
	reputationGraph.setYRange(-1.1, 1.1);&lt;br /&gt;
	reputationGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;reputation&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class reputationSequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcAvgReputation();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	reputationGraph.addSequence(&amp;quot;Ave Reputation&amp;quot;, new reputationSequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	reputationGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent wealth&lt;br /&gt;
	wealthHist = new OpenHistogram(&amp;quot;Agent Wealth Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	wealthHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource histSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getReputation();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	wealthHist.createHistogramItem(&amp;quot;Wealth&amp;quot;, agentList, histSource);&lt;br /&gt;
	wealthHist.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent degree&lt;br /&gt;
	degreeHist = new OpenHistogram(&amp;quot;Agent Degree Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	degreeHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource degreeSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getDegree();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	degreeHist.createHistogramItem(&amp;quot;Degree&amp;quot;, agentList, degreeSource);&lt;br /&gt;
	degreeHist.display();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Adds to buildSchedule in main model&lt;br /&gt;
    // Note, model-type changes should also be included in&lt;br /&gt;
    // batchmodel&#039;s buildSchedule if one wants to ever run in batch&lt;br /&gt;
    &lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	&lt;br /&gt;
	schedule = new Schedule(1);&lt;br /&gt;
	super.buildSchedule();  // Get base model schedule&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    //&lt;br /&gt;
    // Ask the super-class (RepMod) to do its step() method,&lt;br /&gt;
    // and then this does display related activities.&lt;br /&gt;
    public void step() {&lt;br /&gt;
	&lt;br /&gt;
	super.step();	  // the base model does whatever it does&lt;br /&gt;
	&lt;br /&gt;
	// add things after this for all displays (graphs, etc)&lt;br /&gt;
	drawNodes();&lt;br /&gt;
	surface.updateDisplay();&lt;br /&gt;
	reputationGraph.step();&lt;br /&gt;
	wealthHist.step();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // drawNodes&lt;br /&gt;
    // has nodes re-draw themselves based on Reputation&lt;br /&gt;
    public void drawNodes(){&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
	double maxReputation = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    if (node.getReputation() &amp;gt; maxReputation)&lt;br /&gt;
		maxReputation = node.getReputation();&lt;br /&gt;
        }&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.setNodeColorFromReputation(maxReputation);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // called once, at end of run.&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== GUIModel processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	super.addAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	super.delAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // updateLayoutAgentList&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Update layout&#039;s agentList.  Model&#039;s agentlist&lt;br /&gt;
    //  is updated with gm&#039;s (since they both point to &lt;br /&gt;
    //  the same object).  Layout is dumb, and evidently&lt;br /&gt;
    //  re-stores pointers to objects in list, rather than&lt;br /&gt;
    //  the list.&lt;br /&gt;
    public void updateLayoutAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	layout.setList(agentList); &lt;br /&gt;
	// update the layout, re-executing layout method (e.g. Kamada)&lt;br /&gt;
	layout.updateLayout(); &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutCircular&lt;br /&gt;
    // Uses circular rather than Kamada layout&lt;br /&gt;
    public void changeLayoutCircular(){&lt;br /&gt;
        layout = new CircularGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutKamada&lt;br /&gt;
    // Uses kamada-kawai layout, rather than circular&lt;br /&gt;
    public void changeLayoutKamada(){&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
    public void printNodes(){&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode aNode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %d bucks with skill %1.3f.\n&amp;quot;, &lt;br /&gt;
		     aNode.getID(), aNode.getReputation(), aNode.getSkill());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // killAllEdges&lt;br /&gt;
    // deletes all edges&lt;br /&gt;
    // Mainly used for debugging, or being a bastard&lt;br /&gt;
    public void killAllEdges(){&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.clearInEdges();&lt;br /&gt;
	    node.clearOutEdges();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // plotRepSkill()&lt;br /&gt;
    public void plotRepSkill(){&lt;br /&gt;
	Plot repSkillPlot = new Plot(&amp;quot;Reputation v. Skill&amp;quot;);&lt;br /&gt;
	repSkillPlot.display();&lt;br /&gt;
	repSkillPlot.setConnected(false);&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; numAgents; i++) {&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    repSkillPlot.plotPoint(node.getSkill(), node.getReputation(), 0);&lt;br /&gt;
	}&lt;br /&gt;
	repSkillPlot.updateGraph();&lt;br /&gt;
	repSkillPlot.setXRange(0, 1);	&lt;br /&gt;
	//aPlot.fillPlot();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //   ****  NO NEEd TO CHANGE THE REST OF THIS  *****&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // main entry point&lt;br /&gt;
    public static void main( String[] args ) {&lt;br /&gt;
	&lt;br /&gt;
	uchicago.src.sim.engine.SimInit init =&lt;br /&gt;
	    new uchicago.src.sim.engine.SimInit();&lt;br /&gt;
	GUIModel model = new GUIModel();&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;==&amp;gt; GUIMOdel main...\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// set the type of model class, this is necessary&lt;br /&gt;
	// so the parameters object knows whether or not&lt;br /&gt;
	// to do GUI related updates of panels,etc when a&lt;br /&gt;
	// parameter is changed&lt;br /&gt;
	model.setModelType(&amp;quot;GUIModel&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
        // Do this to set the Update Probes option to true in the&lt;br /&gt;
        // Repast Actions panel&lt;br /&gt;
        Controller.UPDATE_PROBES = true;&lt;br /&gt;
	&lt;br /&gt;
	model.setCommandLineArgs( args );&lt;br /&gt;
	init.loadModel( model, null, false ); // does setup()&lt;br /&gt;
	&lt;br /&gt;
	// this new function calls ProbeUtilities.updateProbePanels() and &lt;br /&gt;
	// ProbeUtilities.updateModelProbePanel()&lt;br /&gt;
	model.updateAllProbePanels();&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Creates a new instance of GUIModel */&lt;br /&gt;
    public GUIModel() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3575</id>
		<title>CustomNode.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomNode.java.wp&amp;diff=3575"/>
		<updated>2006-06-17T23:21:26Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * CustomNode.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 2:41 PM&lt;br /&gt;
 * Modified on June 17, 2006, 17:20 by Jack&lt;br /&gt;
 *&lt;br /&gt;
 * This class contains the parameters and methods&lt;br /&gt;
 *  for an agent acting on the network&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultDrawableNode lets us draw it in the GUI&lt;br /&gt;
// CustomProbeable lets us define which attributes appear when&lt;br /&gt;
//  probed in the GUI&lt;br /&gt;
public class CustomNode extends DefaultDrawableNode implements CustomProbeable {&lt;br /&gt;
    //***********************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // tracks next unique id&lt;br /&gt;
    public static int                   nextID = 0;      &lt;br /&gt;
    &lt;br /&gt;
    public static GUIModel              guiModel = null;&lt;br /&gt;
    public static RepMod           model;&lt;br /&gt;
&lt;br /&gt;
    // voteType, whether to use democratic or meritocratic votes&lt;br /&gt;
    // 0 = democratic&lt;br /&gt;
    // 1 = meritocratic&lt;br /&gt;
    public static int    voteType; &lt;br /&gt;
&lt;br /&gt;
    // the degree by which the historical opinion is weighted&lt;br /&gt;
    public static double histWeight;            &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //********************************8**&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
&lt;br /&gt;
    // Two colormaps are generated for color-coding the nodes in GUI&lt;br /&gt;
    public static ColorMap              centerColorMap;    &lt;br /&gt;
    public static ColorMap              edgeColorMap;&lt;br /&gt;
    public static final int             colorMapSize = 16;&lt;br /&gt;
    public static final int             colorMapMax = colorMapSize - 1;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    private int   id;                   // uniquely ids node&lt;br /&gt;
    public Color  myColor;              // used to draw color in GUI&lt;br /&gt;
    public String myPajekColor = &amp;quot;Red&amp;quot;; // color to appear in Pajek output&lt;br /&gt;
    public double reputation;              // current wealth or stored reputation&lt;br /&gt;
    public double skill;          // skill parameter&lt;br /&gt;
    //public int    numVotes;              // the number of vote rounds &lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
       &lt;br /&gt;
&lt;br /&gt;
    //public double success;              // most recent success&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////&lt;br /&gt;
    // constructor&lt;br /&gt;
    // Inputs: NetworkDrawable drawable, to draw in GUI&lt;br /&gt;
    //         double skill, the skill parameter&lt;br /&gt;
    public CustomNode (NetworkDrawable drawable, double skill) {&lt;br /&gt;
	super(drawable);&lt;br /&gt;
	id = nextID++;              // set id and iterate to next&lt;br /&gt;
	this.skill = skill;&lt;br /&gt;
	reputation = 0.5;	            // Generalize.  Currently hard-coded&lt;br /&gt;
	if (guiModel != null)&lt;br /&gt;
	    setNodeEdgeColorFromSkill();&lt;br /&gt;
	//numVotes = 0;&lt;br /&gt;
	//success = 0;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getProbedProperties&lt;br /&gt;
    // Required to implement CustomProbeable&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: array of strings holding parameter names&lt;br /&gt;
    public String[] getProbedProperties(){&lt;br /&gt;
	return new String[] {&amp;quot;id&amp;quot;, &amp;quot;reputation&amp;quot;, &amp;quot;skill&amp;quot;};&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // (Can be) Called by main model to have nodes execute a single step&lt;br /&gt;
    public void step(){&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeColorFromReputation&lt;br /&gt;
    // Input:  maxReputation, the highest reputation from all agents&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node color to the colormap leval depending on reputation&lt;br /&gt;
    public void setNodeColorFromReputation(double maxReputation){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*(reputation)/ (maxReputation));&lt;br /&gt;
	this.setColor(centerColorMap.getColor(i));&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeEdgeColorFromSkill&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node edge color to the colormap level depending on skill&lt;br /&gt;
    public void setNodeEdgeColorFromSkill(){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*skill);&lt;br /&gt;
	this.setBorderColor(edgeColorMap.getColor(i));&lt;br /&gt;
	this.setBorderWidth(3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // getDegree&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: int degree&lt;br /&gt;
    // Calculates the degree of the node (assuming symmetric)&lt;br /&gt;
    public int getDegree(){	&lt;br /&gt;
	return (this.getOutNodes()).size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // formOpinion&lt;br /&gt;
    // Input: double success, the focus&#039; real skill&lt;br /&gt;
    // Output: double vote, the voter&#039;s estimate of focus&#039; skill&lt;br /&gt;
    public double formOpinion(double fSkill, double prevOp){&lt;br /&gt;
	double op = fSkill + model.getNormalDouble(0, getNoiseFromSkill(this.skill));&lt;br /&gt;
	op = histWeight*prevOp + (1-histWeight)*op;&lt;br /&gt;
	return op;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // voteAll&lt;br /&gt;
    public void voteAll(){&lt;br /&gt;
	ArrayList edgeList = this.getOutEdges();&lt;br /&gt;
	double opinion = 0;&lt;br /&gt;
	int vote = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getTo();&lt;br /&gt;
	    opinion = formOpinion(node.getSkill(), edge.getOpinion());&lt;br /&gt;
	    edge.setOpinion(opinion);&lt;br /&gt;
	    if (opinion &amp;gt; 0.5)&lt;br /&gt;
		vote = 1;&lt;br /&gt;
	    else&lt;br /&gt;
		vote = 0;&lt;br /&gt;
	    edge.setVote(vote);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // calcReputation&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Ouput: none&lt;br /&gt;
    public void calcReputation(){&lt;br /&gt;
	ArrayList edgeList = this.getInEdges();&lt;br /&gt;
	double repSum = 0;&lt;br /&gt;
	double normSum = 0;&lt;br /&gt;
	for (int i = 0; i &amp;lt; edgeList.size(); i++){&lt;br /&gt;
	    CustomEdge edge = (CustomEdge) edgeList.get(i);&lt;br /&gt;
	    CustomNode node = (CustomNode) edge.getFrom();&lt;br /&gt;
	    if (voteType ==0){&lt;br /&gt;
		repSum += edge.getVote();&lt;br /&gt;
		normSum ++;&lt;br /&gt;
	    }&lt;br /&gt;
	    else if (voteType ==1){&lt;br /&gt;
		repSum += edge.getVote() * node.getReputation();&lt;br /&gt;
		normSum += node.getReputation();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	reputation = repSum/normSum;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
    public int      getID() {return id;}&lt;br /&gt;
&lt;br /&gt;
    public void     setMyPajekColor(String i) {myPajekColor = i;}&lt;br /&gt;
    public String   getMyPajekColor() {return myPajekColor;}&lt;br /&gt;
    &lt;br /&gt;
    public double   getReputation() {return reputation;}&lt;br /&gt;
    public void     setReputation(double i) {reputation = i;}&lt;br /&gt;
&lt;br /&gt;
    public double   getSkill() {return skill;}&lt;br /&gt;
    public void     setSkill(double i) {skill = i;}&lt;br /&gt;
&lt;br /&gt;
    //public double   getSuccess() {return success;}&lt;br /&gt;
    //public void     setSuccess(double i) {success = i;}&lt;br /&gt;
    &lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(RepMod m) {model = m;}&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setUpNodeDrawing&lt;br /&gt;
    // Input: GUIModel m, a pointer to the GUIModel&lt;br /&gt;
    // Output: none&lt;br /&gt;
    public static void setUpNodeDrawing (GUIModel m) {&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	centerColorMap = new ColorMap();&lt;br /&gt;
	edgeColorMap   = new ColorMap();&lt;br /&gt;
	double minColor = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracColor = minColor + ( (1.0-minColor)*i/colorMapMax );&lt;br /&gt;
&lt;br /&gt;
	    centerColorMap.mapColor(i, 0, 0, fracColor);&lt;br /&gt;
	    edgeColorMap.mapColor(i, 0, fracColor, 0);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // resetNextID&lt;br /&gt;
    // Inputs:  none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Resets nextID.  Called when the model is reset, and a &lt;br /&gt;
    //  new set of nodes is generated&lt;br /&gt;
    public static void resetNextID(){&lt;br /&gt;
	nextID = 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getNoiseFromSkill&lt;br /&gt;
    // Inputs: double skill&lt;br /&gt;
    // Outputs: double, the noise variance&lt;br /&gt;
    public static double getNoiseFromSkill(double skill){&lt;br /&gt;
	return skill/1.0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public static int getVoteType() {return voteType;}&lt;br /&gt;
    public static void setVoteType(int i) {voteType = i;}&lt;br /&gt;
&lt;br /&gt;
    public static double getHistWeight() {return histWeight;}&lt;br /&gt;
    public static void   setHistWeight(double i) {histWeight = i;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3574</id>
		<title>CustomEdge.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomEdge.java.wp&amp;diff=3574"/>
		<updated>2006-06-17T23:20:55Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * CustomEdge.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 5:55 PM&lt;br /&gt;
 * Modified on June 17 2006, 17:20 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class is for the edges in a netwok&lt;br /&gt;
 * It points from a voter to the subject&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.gui.DrawableEdge;&lt;br /&gt;
import uchicago.src.sim.gui.SimGraphics;&lt;br /&gt;
import uchicago.src.sim.network.DefaultEdge;&lt;br /&gt;
import uchicago.src.sim.network.Node;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultEdge gives us the standard edge methods&lt;br /&gt;
// DrawableEdge lets us draw it in the GUI&lt;br /&gt;
public class CustomEdge extends DefaultEdge implements DrawableEdge {&lt;br /&gt;
    //*************************************************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // These are for drawing the edge in GUI&lt;br /&gt;
    public static GUIModel          guiModel = null;&lt;br /&gt;
    public static ColorMap          redColorMap, blueColorMap;&lt;br /&gt;
    public static final int         colorMapSize = 64;&lt;br /&gt;
    public static final int         colorMapMax = colorMapSize - 1;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    //Instance parameters&lt;br /&gt;
    &lt;br /&gt;
    private Color  color = Color.red;  // Edge color&lt;br /&gt;
    public  int    vote = 0;&lt;br /&gt;
    public  double opinion = 0;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public CustomEdge() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor (overloaded)&lt;br /&gt;
    // Inputs: Node from, the (generic class) Node from which the edge emerges&lt;br /&gt;
    //         Node to, the (generic) Node to which the edge points&lt;br /&gt;
    public CustomEdge(Node from, Node to) {&lt;br /&gt;
        super(from, to, &amp;quot;&amp;quot;);   // Calls DefaultEdge constructor&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // draw&lt;br /&gt;
    // Inputs: SimGraphics g&lt;br /&gt;
    //         int fromX, toX, fromY, toY&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Required to implement DrawableEdge.&lt;br /&gt;
    public void draw(SimGraphics g, int fromX, int toX, int fromY, int toY) {&lt;br /&gt;
        g.drawDirectedLink(color, fromX, toX, fromY, toY);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //getters and setters&lt;br /&gt;
    public void setColor(Color c) {color = c;}&lt;br /&gt;
    public Color getColor() {return color;}&lt;br /&gt;
&lt;br /&gt;
    public void setVote(int i) {vote = i;}&lt;br /&gt;
    public int  getVote() {return vote;}&lt;br /&gt;
&lt;br /&gt;
    public void setOpinion(double i) {opinion = i;}&lt;br /&gt;
    public double getOpinion() {return opinion;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //******************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////&lt;br /&gt;
    // setUpEdgeDrawing&lt;br /&gt;
    // Inputs: GUIModel m, a pointer to the GUIModel instance&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Prepares the edge to be drawn in the GUI&lt;br /&gt;
    public static void setUpEdgeDrawing (GUIModel m) {&lt;br /&gt;
	//System.out.printf(&amp;quot;Setting up Edge Color Map\n&amp;quot;);&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	redColorMap = new ColorMap();&lt;br /&gt;
	double minRed = 0.5;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracR = minRed + ( (1.0-minRed)*i/colorMapMax );&lt;br /&gt;
	    fracR = 1.0 + minRed - fracR;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    redColorMap.mapColor(i, fracR, 0, 0);		   &lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	blueColorMap = new ColorMap();&lt;br /&gt;
	double minBlue = 0.5;&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracB = minBlue + ( (1.0-minBlue)*i/colorMapMax );&lt;br /&gt;
	    fracB = 1.0 + minBlue - fracB;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    blueColorMap.mapColor(i, 0, 0, fracB);		   &lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3536</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3536"/>
		<updated>2006-06-16T21:47:25Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* [[GameMaster.java.wp]] : The class that organizes the votes, polls, and challenges&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;br /&gt;
* [[CompNodeRep.java]] : The comparator for sorting by reputation.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3535</id>
		<title>CompNodeRep.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3535"/>
		<updated>2006-06-16T21:47:04Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GameMaster.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on June 16 2006&lt;br /&gt;
 * Last Modified June 16 2006 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class compares two agents based on their reputation&lt;br /&gt;
 */&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class CompNodeRep implements Comparator{&lt;br /&gt;
&lt;br /&gt;
    public CompNodeRep(){&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int compare(Object o1, Object o2){&lt;br /&gt;
	CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
	    return -1;&lt;br /&gt;
	else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
	    return 1;&lt;br /&gt;
	else&lt;br /&gt;
	    return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3534</id>
		<title>CompNodeRep.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3534"/>
		<updated>2006-06-16T21:46:46Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeer Code]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GameMaster.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on June 16 2006&lt;br /&gt;
 * Last Modified June 16 2006 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class compares two agents based on their reputation&lt;br /&gt;
 */&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class CompNodeRep implements Comparator{&lt;br /&gt;
&lt;br /&gt;
    public CompNodeRep(){&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int compare(Object o1, Object o2){&lt;br /&gt;
	CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
	    return -1;&lt;br /&gt;
	else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
	    return 1;&lt;br /&gt;
	else&lt;br /&gt;
	    return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3533</id>
		<title>CompNodeRep.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CompNodeRep.java&amp;diff=3533"/>
		<updated>2006-06-16T21:46:38Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeer Code]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GameMaster.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on June 16 2006&lt;br /&gt;
 * Last Modified June 16 2006 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class compares two agents based on their reputation&lt;br /&gt;
 */&lt;br /&gt;
package RepMod;&lt;br /&gt;
import java.util.Comparator;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class CompNodeRep implements Comparator{&lt;br /&gt;
&lt;br /&gt;
    public CompNodeRep(){&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int compare(Object o1, Object o2){&lt;br /&gt;
	CustomNode nodei = (CustomNode) o1;&lt;br /&gt;
	CustomNode nodej = (CustomNode) o2;&lt;br /&gt;
	if (nodei.getReputation() &amp;lt; nodej.getReputation())&lt;br /&gt;
	    return -1;&lt;br /&gt;
	else if (nodei.getReputation() &amp;gt; nodej.getReputation())&lt;br /&gt;
	    return 1;&lt;br /&gt;
	else&lt;br /&gt;
	    return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GameMaster.java.wp&amp;diff=3532</id>
		<title>GameMaster.java.wp</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GameMaster.java.wp&amp;diff=3532"/>
		<updated>2006-06-16T21:45:37Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[WikiPeerCode]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GameMaster.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on June 13 2006&lt;br /&gt;
 * Last Modified June 16 2006 by Jack&lt;br /&gt;
 * &lt;br /&gt;
 * This class oversees games played between agents&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package RepMod;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Collections;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// GameMaster Constructor&lt;br /&gt;
public class GameMaster {&lt;br /&gt;
     &lt;br /&gt;
    // GUIModel: Stores the model class that runs the graphics&lt;br /&gt;
    public static GUIModel        guiModel = null;&lt;br /&gt;
&lt;br /&gt;
    // model: stores the base model&lt;br /&gt;
    public static RepMod     model;&lt;br /&gt;
&lt;br /&gt;
    // agentList: Stores a pointer to the agents list&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt;  agentList;&lt;br /&gt;
&lt;br /&gt;
    // compare: the comparator for node reputation&lt;br /&gt;
    public CompNodeRep            compare = new CompNodeRep();&lt;br /&gt;
&lt;br /&gt;
    // &lt;br /&gt;
    public double topRepSuccess;&lt;br /&gt;
    &lt;br /&gt;
    public GameMaster (ArrayList agentList) {&lt;br /&gt;
	// If the agent list pointer is sent from RepMod&lt;br /&gt;
	//  then changing the list here changes it there as well.&lt;br /&gt;
	this.agentList = agentList;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // voteAll&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Traverses the agent list, playing a game once between&lt;br /&gt;
    //  all pairs of neighbors on the network.&lt;br /&gt;
    public void voteAll(){&lt;br /&gt;
	 //for (CustomNode nodej : agentList){&lt;br /&gt;
	 CustomNode voter, focus;&lt;br /&gt;
	 &lt;br /&gt;
	 double rSum = 0;&lt;br /&gt;
	 // Traverse the agent list&lt;br /&gt;
	 for (int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	     focus = agentList.get(i);&lt;br /&gt;
	     &lt;br /&gt;
	     // Get current node&#039;s neighbors: symmetric network&lt;br /&gt;
	     //  means that out neighbors are just neighbors.&lt;br /&gt;
	     ArrayList&amp;lt;CustomNode&amp;gt; neighbors = focus.getOutNodes();&lt;br /&gt;
	     for (int j = 0; j &amp;lt; neighbors.size(); j++){&lt;br /&gt;
		 voter = neighbors.get(j);&lt;br /&gt;
		 rSum += voter.vote(focus.getSuccess());&lt;br /&gt;
	     }&lt;br /&gt;
	     focus.updateReputation(rSum);&lt;br /&gt;
	 }&lt;br /&gt;
	 //double blah = calcTopRepSuccesses();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcTopRepSuccesses&lt;br /&gt;
    public double calcTopRepSuccesses(){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; tempList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	tempList.addAll(agentList);&lt;br /&gt;
	Collections.sort(tempList, compare);&lt;br /&gt;
&lt;br /&gt;
	for(CustomNode agent : tempList){&lt;br /&gt;
	    //System.out.printf(&amp;quot;Agent %d has rep %f\n&amp;quot;, agent.getID(), agent.getReputation());&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // challengeAll&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    public void challengeAll(){&lt;br /&gt;
	//for (CustomNode nodej : agentList){&lt;br /&gt;
	 CustomNode node;&lt;br /&gt;
	 double difficulty = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
	 // Traverse the agent list&lt;br /&gt;
	 for (int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	     node = agentList.get(i);&lt;br /&gt;
	     node.challenge(difficulty);&lt;br /&gt;
	 }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(RepMod m) {model = m;}&lt;br /&gt;
    public static void setGUIModel(GUIModel m) {guiModel = m;}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3531</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3531"/>
		<updated>2006-06-16T21:44:32Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* --[[GameMaster.java.wp]] Jack is editing-- : The class that organizes the votes, polls, and challenges&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;br /&gt;
* [[CompNodeRep.java]] : The comparator for sorting by reputation.&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3530</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3530"/>
		<updated>2006-06-16T21:28:02Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* --[[GameMaster.java.wp]] Jack is editing-- : The class that organizes the votes, polls, and challenges&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CSSS_2006_Santa_Fe-Schedule&amp;diff=3481</id>
		<title>CSSS 2006 Santa Fe-Schedule</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CSSS_2006_Santa_Fe-Schedule&amp;diff=3481"/>
		<updated>2006-06-16T13:47:50Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{CSSS 2006--Santa Fe}}&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; width=&amp;quot;450&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
!  !! Week One (June 4-10) Emphasis on biology&lt;br /&gt;
|-&lt;br /&gt;
!valign=&amp;quot;top&amp;quot; | &lt;br /&gt;
| &#039;&#039;&#039;Sunday, June 4&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
!valign=&amp;quot;top&amp;quot; | 12-6 pm&lt;br /&gt;
| Registration&lt;br /&gt;
|-&lt;br /&gt;
!valign=&amp;quot;top&amp;quot; | 6-8 pm &lt;br /&gt;
| Welcome reception and buffet dinner&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Monday, June 5&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-9:30 am&lt;br /&gt;
| Welcome-Geoffrey West, President of SFI &lt;br /&gt;
|-&lt;br /&gt;
! 9:30-9:35 am&lt;br /&gt;
| Greeting-Michael Peters, President of St. John&#039;s College&lt;br /&gt;
|-&lt;br /&gt;
! 9:35-10:30 am &lt;br /&gt;
| Introduction and overview of the program-Dan Rockmore&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 10:45 am &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:45 - 12 pm&lt;br /&gt;
| Introduction to nonlinear dynamics I-Elizabeth Bradley&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Dynamics models of viral infections in humans I-Alan Perelson&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 5 pm &lt;br /&gt;
| Student introductions/tutorial organization&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Tuesday, June 6&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Introduction to nonlinear dynamics II-Bradley &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Dynamic models of viral infectors in humans II-Perelson&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Dynamics of complex systems I-Alfred Hubler&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| RNA I-Peter Stadler&lt;br /&gt;
|-&lt;br /&gt;
! 4:30 - 5 pm &lt;br /&gt;
| Introduction to Santa Fe&lt;br /&gt;
|-&lt;br /&gt;
! 5:15 - 6 pm&lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Introduction to Matlab-Jack Waddell&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Wednesday, June 7&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Introduction to nonlinear dynamics III-Bradley &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| RNA II-Stadler&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Dynamics of complex systems II-Alfred Hubler&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Biological networks I-Andreas Wagner&lt;br /&gt;
|-&lt;br /&gt;
! 7:00 pm &lt;br /&gt;
| Agent-based modeling- Owen Densmore and Stephen Guerin, with refreshments &lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Thursday, June 8&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Introduction to nonlinear dynamics IV-Bradley &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| RNA III-Stadler&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Dynamics of complex systems III-Hubler&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Biological networks II- Wagner&lt;br /&gt;
|-&lt;br /&gt;
! 4:30 - 5:15&lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Theories and models-Tom Carter&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Friday, June 9&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Power laws changed to Monday afternoon&amp;lt;/font&amp;gt; &lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Dynamics of complex systems IV-Hubler &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Coalescence- Jon Wilkins&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Student group session&lt;br /&gt;
&amp;lt;font color=green&amp;gt;Markov Chain Monte Carlo tutorial-Lukas Kroc&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 5 pm &lt;br /&gt;
| Student group session&lt;br /&gt;
&amp;lt;font color=green&amp;gt;Population Genetics-Sussane&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! 5:30 pm &lt;br /&gt;
| Barbeque at the Santa Fe Institute&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; width=&amp;quot;450&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
!  !! Week Two (June 10-16) Emphasis on ecology          &lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Monday, June 12&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Information theory I-Tom Carter &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Network structure and dynamics I-Mark Newman&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Student group session&lt;br /&gt;
&amp;lt;font color=green&amp;gt;Noise-induced transitions-Andreea Munteanu&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| Student group session&lt;br /&gt;
&amp;lt;font color=green&amp;gt;Power laws-Ryan Woodard&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Student group session&lt;br /&gt;
|-&lt;br /&gt;
! 7:00 pm  &lt;br /&gt;
| Tee-shirt design contest&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Tuesday, June 13&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Information theory II-Carter &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Network structure and dynamics II-Newman&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Food webs I-Jennifer Dunne&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Climate Change I-Gidon Eshel&lt;br /&gt;
|-&lt;br /&gt;
! 6:30 - 8:30 pm &lt;br /&gt;
| Physics Lab-Hubler&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Wednesday, June 14&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Food webs II-Dunne &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Network structure and dynamics III-Newman&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Climate Change II-Eshel&lt;br /&gt;
|-&lt;br /&gt;
! 3:30 - 5:30 pm&lt;br /&gt;
| Physics Lab-Hubler&lt;br /&gt;
|-&lt;br /&gt;
! 5:30 - 8:00 pm &lt;br /&gt;
| Pizza Party, Junior Commons Room and Balcony&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Thursday, June 15&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Food webs III-Neo Martinez&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Phase transitions-Cris Moore&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Climate Change III-Eshel&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 5 pm &lt;br /&gt;
| Student tutorials/problem sessions&lt;br /&gt;
|-&lt;br /&gt;
! 3:30 - 5:30 pm&lt;br /&gt;
| Physics Lab-Hubler&lt;br /&gt;
|-&lt;br /&gt;
! 6:30 - 8:30 pm&lt;br /&gt;
| Physics Lab-Hubler&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Friday, June 16&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Food webs IV- Martinez&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Climate Change IV-Eshel&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; width=&amp;quot;450&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
!  !! Week Three (June 17-23) Emphasis on social science and arts &lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Monday, June 19&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Genetic algorithms/simulation I-Melanie Mitchell &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Machine learning I-John Lafferty&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Social dynamics/communication I-Jessica Flack&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Why are epidemics so unpredictable?-Duncan Watts&lt;br /&gt;
|-&lt;br /&gt;
! 4:30 - 5:30 pm &lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Tutorial - Fractional Dynamics - Michael Raghib&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Tuesday, June 20&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Genetic algorithms/simulation II-Mitchell	 &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Machine learning II -Lafferty&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Social dynamics/communication II-Flack&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Process detection I:  Modeling processes-George Cybenko&lt;br /&gt;
|-&lt;br /&gt;
! 4:30 - 5:30 pm&lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Student tutorial: Iterated Function Systems and possible application to Complex Systems&amp;lt;font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! 7:00 - 8:00&lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Student tutorial: SQUID Sensors and what they may tell us about Protein Dynamics&amp;lt;font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;Wednesday, June 21&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Genetic algorithms/simulation III-Mitchell &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Machine learning III-Lafferty&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Stylometry-Dan Rockmore&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Process detection II:  Algorithms for detecting multiple processes-Cybenko&lt;br /&gt;
|-&lt;br /&gt;
! 4.30 - 5:15 pm &lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Student Tutorial - MindMapping and other IT Tools - Fabrice Cavarretta&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! 7:00 pm &lt;br /&gt;
| Movie night, Great Hall&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Thursday, June 22&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| TBA- Larry Polansky&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Computational modeling in the social sciences I-John Miller&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| TBA-Eric Smith&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Process detection III:  Applications-Cybenko&lt;br /&gt;
|-&lt;br /&gt;
! 4.30 - 5:30 pm &lt;br /&gt;
| &amp;lt;font color=green&amp;gt;Student Tutorial: Automated negotiation and auction protocols for resource allocation - Valentin Robu&amp;lt;/font&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
!&lt;br /&gt;
| &#039;&#039;&#039;Friday, June 23&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| TBA-Polansky&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Computational modeling in the social sciences II-John Miller&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
| 1:30 - 2:30 pm&lt;br /&gt;
|&amp;lt;font color=green&amp;gt;Student Tutorial: Quantum Mechanics - Jack Waddell &amp;lt;/font&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; width=&amp;quot;450&amp;quot;&lt;br /&gt;
|+&lt;br /&gt;
|-&lt;br /&gt;
!  !! Week Four (June 24-30) Emphasis on neuroscience and quantum computing&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Monday, June 26&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Neuroscience and complex systems I-Tony Bell&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Computational neuroscience I-Bruno Olshausen&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 pm &lt;br /&gt;
| Student project work&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Tuesday, June 27&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Neurocience and complex systems II-Bell&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Quantum information I-Carlton Caves&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Computational neuroscience II-Olshausen&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 4:15 pm &lt;br /&gt;
| Computational neuroscience III-Rob De Ruyler	&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Wednesday, June 28&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Neuroscience and complex systems III-Bell&lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Quantum information II-Caves&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 2:45 pm &lt;br /&gt;
| Computational neuroscience IV-Olshausen&lt;br /&gt;
|-&lt;br /&gt;
! 3 - 5 pm &lt;br /&gt;
| Student project work&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Thursday, June 29&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-10:15 am&lt;br /&gt;
| Computational neuroscience V-De Ruyter &lt;br /&gt;
|-&lt;br /&gt;
! 10:15 - 10:30 &lt;br /&gt;
| BREAK&lt;br /&gt;
|-&lt;br /&gt;
! 10:30 - 11:45 am &lt;br /&gt;
| Quantum information III-Cris Moore&lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 pm &lt;br /&gt;
| Student presentations&lt;br /&gt;
|-&lt;br /&gt;
! &lt;br /&gt;
| &#039;&#039;&#039;Friday, June 30&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
! 9-11:45 am&lt;br /&gt;
| Student presentations &lt;br /&gt;
|-&lt;br /&gt;
! 12- 1:30 pm &lt;br /&gt;
| Lunch&lt;br /&gt;
|-&lt;br /&gt;
! 1:30 - 5 pm &lt;br /&gt;
| Student presentations&lt;br /&gt;
|-&lt;br /&gt;
! 6:00 pm &lt;br /&gt;
| Poster session and final banquet (Santa Fe Institute)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GUIModel.java&amp;diff=3462</id>
		<title>GUIModel.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GUIModel.java&amp;diff=3462"/>
		<updated>2006-06-16T04:03:04Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GUIModel.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 30, 2005, 12:21 PM&lt;br /&gt;
 * Modified June 14, 2006&lt;br /&gt;
 * This runs the graphical interface for the CoopNetBlue model&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.Value2DDisplay;&lt;br /&gt;
import uchicago.src.sim.space.Object2DTorus;&lt;br /&gt;
import uchicago.src.sim.engine.AbstractGUIController;&lt;br /&gt;
import uchicago.src.sim.analysis.*;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class GUIModel extends CoopNetBlue{&lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance Parameters&lt;br /&gt;
&lt;br /&gt;
    // The actual display surface, where things are put on the screen&lt;br /&gt;
    private DisplaySurface              surface;&lt;br /&gt;
    &lt;br /&gt;
    // A layout, which tells the surface where to put nodes and edges&lt;br /&gt;
    private AbstractGraphLayout         layout;&lt;br /&gt;
&lt;br /&gt;
    // A graph&lt;br /&gt;
    private OpenSequenceGraph           utilityGraph;&lt;br /&gt;
&lt;br /&gt;
    // A plot&lt;br /&gt;
    private Plot                        histPlot;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    private OpenHistogram               wealthHist;&lt;br /&gt;
&lt;br /&gt;
    // A Histogram&lt;br /&gt;
    private OpenHistogram               degreeHist;&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // setup&lt;br /&gt;
    //&lt;br /&gt;
    // This runs automatically when the model starts&lt;br /&gt;
    // and when you click the reload button, to &amp;quot;tear down&amp;quot; any &lt;br /&gt;
    // existing display objects, and get ready to initialize &lt;br /&gt;
    // them at the start of the next &#039;run&#039;.&lt;br /&gt;
    //&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	// the super class does conceptual-model setup (CoopNetBlue)&lt;br /&gt;
	super.setup();  &lt;br /&gt;
	&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() begin.\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// NOTE: you may want to set these next two to &#039;true&#039;&lt;br /&gt;
	// if you are on a windows machine.  that would tell repast&lt;br /&gt;
	// to by default send System.out and .err output to&lt;br /&gt;
	// a special repast output window.&lt;br /&gt;
	AbstractGUIController.CONSOLE_ERR = false;&lt;br /&gt;
	AbstractGUIController.CONSOLE_OUT = false;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	// For restart purposes, dispose of any displays&lt;br /&gt;
	if ( surface != null ) surface.dispose();&lt;br /&gt;
	if ( utilityGraph != null ) utilityGraph.dispose();&lt;br /&gt;
	if ( wealthHist != null) wealthHist.dispose();&lt;br /&gt;
	if ( degreeHist != null) degreeHist.dispose();&lt;br /&gt;
&lt;br /&gt;
	// Create and register the abstract surface&lt;br /&gt;
	surface = null;&lt;br /&gt;
	surface = new DisplaySurface( this, &amp;quot;Network Display&amp;quot; );&lt;br /&gt;
	registerDisplaySurface( &amp;quot;Main Display&amp;quot;, surface );&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	// Add Custom Buttons&lt;br /&gt;
	modelManipulator.init();&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Circular&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutCircular();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);						   &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Layout - Kamada&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     changeLayoutKamada();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Print Nodes&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     printNodes();&lt;br /&gt;
		 }&lt;br /&gt;
	     }&lt;br /&gt;
	);&lt;br /&gt;
              &lt;br /&gt;
	modelManipulator.addButton(&amp;quot;Kill All Edges&amp;quot;,&lt;br /&gt;
	     new ActionListener(){&lt;br /&gt;
		 public void actionPerformed(ActionEvent evt){&lt;br /&gt;
		     killAllEdges();&lt;br /&gt;
		 }&lt;br /&gt;
	     }           &lt;br /&gt;
	);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== GUIModel setup() done.\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    //&lt;br /&gt;
    // This runs when you click the &amp;quot;initialize&amp;quot; button&lt;br /&gt;
    // (the button with the single arrow that goes around in a circle)&lt;br /&gt;
    // or at the first step&lt;br /&gt;
    public void begin()	{&lt;br /&gt;
	DMSG(1, &amp;quot;==&amp;gt; enter GUIModel-begin()&amp;quot; );&lt;br /&gt;
	// Set up drawables&lt;br /&gt;
	CustomNode.setUpNodeDrawing(this);&lt;br /&gt;
	CustomEdge.setUpEdgeDrawing(this);&lt;br /&gt;
	&lt;br /&gt;
	buildModel();  // Calls in the base model (CoopNetBlue)&lt;br /&gt;
	&lt;br /&gt;
	buildDisplay();  // Constructs the displays&lt;br /&gt;
	if (rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Display Built Successfully. \n&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	// Constructs the schedule; If defined in GUIModel, ignores buildSchedule in base model&lt;br /&gt;
	buildSchedule(); &lt;br /&gt;
&lt;br /&gt;
	surface.display(); // displays the surface on the display&lt;br /&gt;
&lt;br /&gt;
	writeHeaderCommentsToReportFile();&lt;br /&gt;
	&lt;br /&gt;
	DMSG(1, &amp;quot;&amp;lt;== leave GUIModel-begin() done.&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildDisplay&lt;br /&gt;
    //&lt;br /&gt;
    // builds the display and display related things&lt;br /&gt;
    //&lt;br /&gt;
    public void buildDisplay() {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;==&amp;gt; GUIModel buildDisplay...\n&amp;quot; );&lt;br /&gt;
        &lt;br /&gt;
	// Layout specifies the arrangement of nodes and edges&lt;br /&gt;
	// This specifically uses the Kamada-Kawai method&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	Network2DDisplay display = new Network2DDisplay(layout);&lt;br /&gt;
	&lt;br /&gt;
	layout.updateLayout();  // actually execute the laying out&lt;br /&gt;
&lt;br /&gt;
	// Register the layout with the display surface for drawing&lt;br /&gt;
	surface.addDisplayableProbeable(display, &amp;quot;Network Display&amp;quot;);&lt;br /&gt;
	surface.addZoomable (display);&lt;br /&gt;
	surface.setBackground (java.awt.Color.black);&lt;br /&gt;
	&lt;br /&gt;
	addSimEventListener (surface);&lt;br /&gt;
	&lt;br /&gt;
	// Makes a graph&lt;br /&gt;
	utilityGraph = new OpenSequenceGraph(&amp;quot;Utility&amp;quot;, this); // constructs graph&lt;br /&gt;
	utilityGraph.setXRange(0, 200000);                     // sets ranges&lt;br /&gt;
	utilityGraph.setYRange(-1.1, 1.1);&lt;br /&gt;
	utilityGraph.setAxisTitles(&amp;quot;time&amp;quot;, &amp;quot;utility&amp;quot;);         // sets axis lables&lt;br /&gt;
	&lt;br /&gt;
	// This generates a sequence, which is read into the graph&lt;br /&gt;
	// To generalize, change sequence class name, and what it returns&lt;br /&gt;
	class utilitySequence implements Sequence {&lt;br /&gt;
	    public double getSValue(){&lt;br /&gt;
		return calcAvgUtility();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// Add the above sequence to the graph.&lt;br /&gt;
	// You can add several sequences to plot simultaneously&lt;br /&gt;
	utilityGraph.addSequence(&amp;quot;Ave Utility&amp;quot;, new utilitySequence());&lt;br /&gt;
	// Display the graph.  It will need to be updated in Step&lt;br /&gt;
	utilityGraph.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent wealth&lt;br /&gt;
	wealthHist = new OpenHistogram(&amp;quot;Agent Wealth Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	wealthHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource histSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getUtility();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	wealthHist.createHistogramItem(&amp;quot;Wealth&amp;quot;, agentList, histSource);&lt;br /&gt;
	wealthHist.display();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	// Generate a histogram of agent degree&lt;br /&gt;
	degreeHist = new OpenHistogram(&amp;quot;Agent Degree Distribution&amp;quot;, 10, 0);&lt;br /&gt;
	degreeHist.setYRange(0, 100.0);&lt;br /&gt;
	BinDataSource degreeSource = new BinDataSource(){&lt;br /&gt;
		public double getBinValue(Object o){&lt;br /&gt;
		    CustomNode node = (CustomNode) o;&lt;br /&gt;
		    return node.getDegree();&lt;br /&gt;
		}&lt;br /&gt;
	    };&lt;br /&gt;
&lt;br /&gt;
	degreeHist.createHistogramItem(&amp;quot;Degree&amp;quot;, agentList, degreeSource);&lt;br /&gt;
	degreeHist.display();&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Adds to buildSchedule in main model&lt;br /&gt;
    // Note, model-type changes should also be included in&lt;br /&gt;
    // batchmodel&#039;s buildSchedule if one wants to ever run in batch&lt;br /&gt;
    &lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	&lt;br /&gt;
	schedule = new Schedule(1);&lt;br /&gt;
	super.buildSchedule();  // Get base model schedule&lt;br /&gt;
&lt;br /&gt;
	schedule.scheduleActionAtInterval(evolveUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    degreeHist.step();         // evolve agents    &lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    //&lt;br /&gt;
    // Ask the super-class (CoopNetBlue) to do its step() method,&lt;br /&gt;
    // and then this does display related activities.&lt;br /&gt;
    public void step() {&lt;br /&gt;
	&lt;br /&gt;
	super.step();	  // the base model does whatever it does&lt;br /&gt;
	&lt;br /&gt;
	// add things after this for all displays (graphs, etc)&lt;br /&gt;
	surface.updateDisplay();&lt;br /&gt;
	utilityGraph.step();&lt;br /&gt;
	wealthHist.step();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // called once, at end of run.&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== GUIModel processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	super.addAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	super.delAgent(agent);&lt;br /&gt;
	updateLayoutAgentList();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // updateLayoutAgentList&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Update layout&#039;s agentList.  Model&#039;s agentlist&lt;br /&gt;
    //  is updated with gm&#039;s (since they both point to &lt;br /&gt;
    //  the same object).  Layout is dumb, and evidently&lt;br /&gt;
    //  re-stores pointers to objects in list, rather than&lt;br /&gt;
    //  the list.&lt;br /&gt;
    public void updateLayoutAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	layout.setList(agentList); &lt;br /&gt;
	// update the layout, re-executing layout method (e.g. Kamada)&lt;br /&gt;
	layout.updateLayout(); &lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutCircular&lt;br /&gt;
    // Uses circular rather than Kamada layout&lt;br /&gt;
    public void changeLayoutCircular(){&lt;br /&gt;
        layout = new CircularGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // changeLayoutKamada&lt;br /&gt;
    // Uses kamada-kawai layout, rather than circular&lt;br /&gt;
    public void changeLayoutKamada(){&lt;br /&gt;
	layout = new KamadaGraphLayout(agentList, worldXSize, worldYSize);&lt;br /&gt;
	layout.updateLayout();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printNodes&lt;br /&gt;
    // print node properties to terminal window&lt;br /&gt;
    // Mainly used for debugging&lt;br /&gt;
    public void printNodes(){&lt;br /&gt;
	System.out.printf(&amp;quot;\nAt time = %f\n&amp;quot;, schedule.getCurrentTimeDouble());&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode aNode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    String s = String.format(&amp;quot;#%d has %d bucks with strategy %1.3f.\n&amp;quot;, &lt;br /&gt;
		     aNode.getID(), aNode.getUtility(), aNode.getStrategy());&lt;br /&gt;
&lt;br /&gt;
	    System.out.printf(s);&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // killAllEdges&lt;br /&gt;
    // deletes all edges&lt;br /&gt;
    // Mainly used for debugging, or being a bastard&lt;br /&gt;
    public void killAllEdges(){&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.clearInEdges();&lt;br /&gt;
	    node.clearOutEdges();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //   ****  NO NEEd TO CHANGE THE REST OF THIS  *****&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // main entry point&lt;br /&gt;
    public static void main( String[] args ) {&lt;br /&gt;
	&lt;br /&gt;
	uchicago.src.sim.engine.SimInit init =&lt;br /&gt;
	    new uchicago.src.sim.engine.SimInit();&lt;br /&gt;
	GUIModel model = new GUIModel();&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;==&amp;gt; GUIMOdel main...\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// set the type of model class, this is necessary&lt;br /&gt;
	// so the parameters object knows whether or not&lt;br /&gt;
	// to do GUI related updates of panels,etc when a&lt;br /&gt;
	// parameter is changed&lt;br /&gt;
	model.setModelType(&amp;quot;GUIModel&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
        // Do this to set the Update Probes option to true in the&lt;br /&gt;
        // Repast Actions panel&lt;br /&gt;
        Controller.UPDATE_PROBES = true;&lt;br /&gt;
	&lt;br /&gt;
	model.setCommandLineArgs( args );&lt;br /&gt;
	init.loadModel( model, null, false ); // does setup()&lt;br /&gt;
	&lt;br /&gt;
	// this new function calls ProbeUtilities.updateProbePanels() and &lt;br /&gt;
	// ProbeUtilities.updateModelProbePanel()&lt;br /&gt;
	model.updateAllProbePanels();&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /** Creates a new instance of GUIModel */&lt;br /&gt;
    public GUIModel() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=Network.java&amp;diff=3461</id>
		<title>Network.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=Network.java&amp;diff=3461"/>
		<updated>2006-06-16T04:02:36Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Network.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 18, 2005, 4:09 PM&lt;br /&gt;
 * Modified June 14, 2006&lt;br /&gt;
 * &lt;br /&gt;
 * This class generates a network, runs some&lt;br /&gt;
 * net statistics, and writes it to a pajek-formatted file&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
//import java.util.Random;&lt;br /&gt;
import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
import uchicago.src.sim.network.EdgeFactory;&lt;br /&gt;
import java.util.Formatter;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import rlriolo.ioutils.*;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import java.util.HashSet;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
import java.util.Vector;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
public class Network {&lt;br /&gt;
    &lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // static parameters&lt;br /&gt;
&lt;br /&gt;
    // the main model&lt;br /&gt;
    public static CoopNetBlue model;&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //*******************************************************&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
    public int[][]     adjacencyMatrix;  // Yes, it is Aij = 1 if j -&amp;gt; i.&lt;br /&gt;
    public int         networkSize;      // The number of agents&lt;br /&gt;
    public int         connectRadius;    // The radius for grid or SWN inits&lt;br /&gt;
    public double      reconnectProb;    // The prob or (re)wiring in (SWN) or random net&lt;br /&gt;
    // a pointer to the agent list,&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; agentList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
    &lt;br /&gt;
    // These are for writing a pajek-formatted file&lt;br /&gt;
    protected String		pajekFileName = &amp;quot;pajek&amp;quot;;&lt;br /&gt;
    protected String 		outputDirName = &amp;quot;./&amp;quot;;&lt;br /&gt;
    protected PrintWriter	pajekFile, plaintextPajekFile;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public Network(int networkSize, int connectRadius, double reconnectProb){&lt;br /&gt;
	this.networkSize = networkSize;&lt;br /&gt;
	this.connectRadius = connectRadius;&lt;br /&gt;
	this.reconnectProb = reconnectProb;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAdjacencyMatrix&lt;br /&gt;
    // Inputs: int netType, selects which specific type of matrix to form&lt;br /&gt;
    // Outputs: int[][], the adjacency matrix&lt;br /&gt;
    public int[][] buildAdjacencyMatrix(int netType){&lt;br /&gt;
	switch(netType){&lt;br /&gt;
	case 0 : return buildAdjacencyMatrix2DWS();&lt;br /&gt;
	case 1 : return buildAdjacencyMatrixWS();&lt;br /&gt;
	case 2 : return buildAdjacencyMatrixRand();&lt;br /&gt;
	default: return buildAdjacencyMatrix2DWS();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrixWS&lt;br /&gt;
    // Develops an adjacency matrix for a Watts-Strogatz Small World &lt;br /&gt;
    // network based on the given parameters.  Note that this &lt;br /&gt;
    // implementation uses a disconnecting rewire, so that it is&lt;br /&gt;
    // possible to disconnect groups in the network.  It is also &lt;br /&gt;
    // possible to have less than an average degree of 2x connectRadius, &lt;br /&gt;
    // since a connection can be &amp;quot;overwritten&amp;quot; during the rewire.&lt;br /&gt;
    //&lt;br /&gt;
    //  Inputs:  double reconnectProb:  each neighbor connection &lt;br /&gt;
    // has a probability p of being disconnected from the outgoing side (i) &lt;br /&gt;
    // and reattached to a random node (including the one from which it &lt;br /&gt;
    // was just disconnected, and any other nodes that j goes to.)]&lt;br /&gt;
    // connectRadius: the number of neighbors to either side of each node.  &lt;br /&gt;
    // Note that this often leads to cycles.&lt;br /&gt;
    &lt;br /&gt;
    public int[][] buildAdjacencyMatrixWS(){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
	&lt;br /&gt;
	// Make the regular gride&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = i; j&amp;lt; networkSize; j++){&lt;br /&gt;
                if( (j &amp;lt;= (i + connectRadius) ) &amp;amp;&amp;amp; (i!=j) ){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                else if( (j &amp;gt;= (networkSize - connectRadius + i) ) &amp;amp;&amp;amp; (i!=j)){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                else{&lt;br /&gt;
                    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
	// Do random rewiring&lt;br /&gt;
	double randomDouble;        &lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 1; j &amp;lt; networkSize; j++){&lt;br /&gt;
                randomDouble = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
                if((randomDouble &amp;lt; reconnectProb)&amp;amp;&amp;amp;&lt;br /&gt;
		                 (adjacencyMatrix[i][j]==1)){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
		    int randomi = j;&lt;br /&gt;
		    do{&lt;br /&gt;
			randomi = model.getUniformIntFromTo(0, networkSize - 1);&lt;br /&gt;
			if(model.rDebug &amp;gt; 2)&lt;br /&gt;
			    System.out.printf(&amp;quot;j = %d, randomi = %d, A[i][j] = %d\n&amp;quot;,&lt;br /&gt;
					      j,randomi, adjacencyMatrix[randomi][j]);&lt;br /&gt;
		    } while (randomi == j || adjacencyMatrix[randomi][j] ==1);&lt;br /&gt;
		    &lt;br /&gt;
		    adjacencyMatrix[randomi][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][randomi] = 1;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrix2DWS&lt;br /&gt;
    // Develops an adjacency matrix for a Toroidal - Watts-Strogatz Small &lt;br /&gt;
    // World network based on the given parameters.  Note that this &lt;br /&gt;
    // implementation uses a disconnecting rewire, so that it is&lt;br /&gt;
    // possible to disconnect groups in the network. &lt;br /&gt;
    public int[][] buildAdjacencyMatrix2DWS(){&lt;br /&gt;
        // Make regular grid&lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int ix, iy, jx, jy;&lt;br /&gt;
        int size = (int) Math.floor(Math.sqrt(networkSize));&lt;br /&gt;
        System.out.printf(&amp;quot;Size = %d \n&amp;quot;, size);&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = i; j&amp;lt; networkSize; j++){&lt;br /&gt;
                &lt;br /&gt;
                ix = i % size;&lt;br /&gt;
                iy = i / size;&lt;br /&gt;
                &lt;br /&gt;
                jx = j % size;&lt;br /&gt;
                jy = j / size;&lt;br /&gt;
                &lt;br /&gt;
                double dx = Math.min( Math.min( Math.pow(jx - ix,2), &lt;br /&gt;
						Math.pow(jx + size - ix, 2)), &lt;br /&gt;
				      Math.pow(jx - size - ix, 2) );&lt;br /&gt;
                double dy = Math.min( Math.min( Math.pow(jy - iy,2), &lt;br /&gt;
						Math.pow(jy + size - iy, 2)), &lt;br /&gt;
				      Math.pow(jy - size - iy, 2) );&lt;br /&gt;
&lt;br /&gt;
                if( (Math.sqrt(dx + dy) &amp;lt;= (connectRadius) ) &amp;amp;&amp;amp; (i!=j) ){&lt;br /&gt;
                    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
                }&lt;br /&gt;
                &lt;br /&gt;
                else{&lt;br /&gt;
                    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
                    adjacencyMatrix[j][i] = 0;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        double randomDouble;&lt;br /&gt;
        // Do random rewiring&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 1; j &amp;lt; networkSize; j++){&lt;br /&gt;
                randomDouble = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
                if((randomDouble &amp;lt; reconnectProb)&amp;amp;&amp;amp;&lt;br /&gt;
		                    (adjacencyMatrix[i][j]==1)){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 0;&lt;br /&gt;
		    int randomi = j;&lt;br /&gt;
		    do{&lt;br /&gt;
			randomi = model.getUniformIntFromTo(0, networkSize - 1);&lt;br /&gt;
			System.out.printf(&amp;quot;j = %d, randomi = %d, A[i][j] = %d\n&amp;quot;,&lt;br /&gt;
					  j,randomi, adjacencyMatrix[randomi][j]);&lt;br /&gt;
		    } while (randomi == j || adjacencyMatrix[randomi][j] ==1);&lt;br /&gt;
		    &lt;br /&gt;
		    adjacencyMatrix[randomi][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][randomi] = 1;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished 2DWS Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //&lt;br /&gt;
    // buildAdjacencyMatrixStar&lt;br /&gt;
    // Develops an adjacency matrix for a Star Network, centered on i.&lt;br /&gt;
    public int[][] buildAdjacencyMatrixStar(int i){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int ix, iy, jx, jy;&lt;br /&gt;
        for(int k = 0; k &amp;lt; networkSize; k++){&lt;br /&gt;
	    for(int j = 0; j&amp;lt; networkSize; j++){&lt;br /&gt;
		adjacencyMatrix[k][j] = 0;&lt;br /&gt;
		adjacencyMatrix[j][k] = 0;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
        &lt;br /&gt;
	for(int j = 0; j&amp;lt; networkSize; j++){&lt;br /&gt;
	    if(i!=j){&lt;br /&gt;
		adjacencyMatrix[i][j] = 1;&lt;br /&gt;
		adjacencyMatrix[j][i] = 1;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished Star Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAdjacencyMatrixRand&lt;br /&gt;
    // Develops a symmetric, random adjacency matrix, so that the&lt;br /&gt;
    //  probability of an edge existing between any pair of nodes is&lt;br /&gt;
    //  reconnectProb.&lt;br /&gt;
    public int[][] buildAdjacencyMatrixRand(){&lt;br /&gt;
        &lt;br /&gt;
        adjacencyMatrix = new int[networkSize][networkSize];&lt;br /&gt;
        int i, j;&lt;br /&gt;
	double randn;&lt;br /&gt;
        for(i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
	    for(j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
		randn = model.getUniformDoubleFromTo(0, 1);&lt;br /&gt;
		&lt;br /&gt;
		if (randn &amp;lt; reconnectProb){&lt;br /&gt;
		    adjacencyMatrix[i][j] = 1;&lt;br /&gt;
		    adjacencyMatrix[j][i] = 1;&lt;br /&gt;
		}&lt;br /&gt;
		//else&lt;br /&gt;
		//    System.out.printf(&amp;quot;Randn = %f vs %f\n&amp;quot;, randn, reconnectProb);&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
        &lt;br /&gt;
	System.out.printf(&amp;quot;----&amp;gt; Finished Random Adjacency Mat\n&amp;quot;);&lt;br /&gt;
        return adjacencyMatrix;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // buildAgentList&lt;br /&gt;
    // Develops an arrayList of CustomNodes interconnected based on the&lt;br /&gt;
    // adjacency matrix developed.&lt;br /&gt;
    public void buildAgentList(){&lt;br /&gt;
	&lt;br /&gt;
	// Create all the agents&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            OvalNetworkItem drawable = new OvalNetworkItem(0,0);&lt;br /&gt;
	    &lt;br /&gt;
	    double strategy = model.getUniformDoubleFromTo(0, 1);&lt;br /&gt;
	    &lt;br /&gt;
            CustomNode agent = new CustomNode(drawable, strategy);&lt;br /&gt;
            agentList.add(agent);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
	// Create the edges between them, governed by the adjacency&lt;br /&gt;
	//  matrix&lt;br /&gt;
        CustomEdge edge;&lt;br /&gt;
        double cc;&lt;br /&gt;
        CustomNode jnode, inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
                if(adjacencyMatrix[i][j] == 1){&lt;br /&gt;
                    jnode = (CustomNode) agentList.get(j);&lt;br /&gt;
                    inode = (CustomNode) agentList.get(i);&lt;br /&gt;
                    edge = new CustomEdge(jnode, inode);&lt;br /&gt;
                    jnode.addOutEdge(edge);&lt;br /&gt;
                    inode.addInEdge(edge);&lt;br /&gt;
&lt;br /&gt;
		    // This symmetritizes the network&lt;br /&gt;
		    // i.e. makes undirected&lt;br /&gt;
		    edge = new CustomEdge(inode, jnode);&lt;br /&gt;
		    inode.addOutEdge(edge);&lt;br /&gt;
		    jnode.addInEdge(edge);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // printAdjacencyMatrix&lt;br /&gt;
    // a debugging tool.  Prints the adjacency matrix to the terminal&lt;br /&gt;
    public void printAdjacencyMatrix(){&lt;br /&gt;
        System.out.printf(&amp;quot;--- Printing Adjacency Matrix, size %d ---\n&amp;quot;, &lt;br /&gt;
			  networkSize);&lt;br /&gt;
        for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
            for(int j = 0; j &amp;lt; networkSize; j++){&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, adjacencyMatrix[i][j]);&lt;br /&gt;
            }&lt;br /&gt;
            System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // writePajekNetwork&lt;br /&gt;
    // Writes the network to a file in pajek&lt;br /&gt;
    //  format.  Note: this version writes DOS type line feeds.&lt;br /&gt;
    public void writePajekNetwork(ArrayList&amp;lt;CustomNode&amp;gt; agentList){&lt;br /&gt;
	String verts, arcs;&lt;br /&gt;
	// These are carriage return and line feed in DOS format.&lt;br /&gt;
	char cr = (char) 13;&lt;br /&gt;
	char lf = (char) 10;&lt;br /&gt;
	&lt;br /&gt;
	// pajek requires the vertices and arcs separately.&lt;br /&gt;
	verts = String.format(&amp;quot;*Vertices %d%c%c&amp;quot;, networkSize, cr, lf);	&lt;br /&gt;
	arcs = String.format(&amp;quot;*Arcs %c%c&amp;quot;, cr, lf);&lt;br /&gt;
	&lt;br /&gt;
	// step through all nodes&lt;br /&gt;
	for(int i = 0; i &amp;lt; networkSize; i++){&lt;br /&gt;
	    CustomNode inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    verts += String.format(&amp;quot;%d \&amp;quot;N%d: %d\&amp;quot;&amp;quot;,&lt;br /&gt;
		   inode.getID() + 1, inode.getID(), inode.getUtility());&lt;br /&gt;
	   &lt;br /&gt;
	    verts += String.format(&amp;quot; ic %s%c%c&amp;quot;, inode.getMyPajekColor(),cr, lf);&lt;br /&gt;
	    &lt;br /&gt;
	    ArrayList edgesInList = inode.getInEdges();&lt;br /&gt;
	    int numEdges = edgesInList.size();&lt;br /&gt;
	    CustomNode testNode = (CustomNode) (model.agentList).get(i);&lt;br /&gt;
	    if (testNode != inode)&lt;br /&gt;
		System.out.printf(&amp;quot;Nodes(%d) not equal\n&amp;quot;, i);&lt;br /&gt;
	    if ( (testNode.getOutDegree() != inode.getOutDegree()) || (testNode.getInDegree() != inode.getInDegree()))&lt;br /&gt;
		System.out.printf(&amp;quot;Nodes(%d) have different degree\n&amp;quot;, i);&lt;br /&gt;
	    if (numEdges &amp;gt; 0)&lt;br /&gt;
		// if node has at least one neighbor, write the edges&lt;br /&gt;
		for(int j = 0;  j &amp;lt; numEdges; j++){&lt;br /&gt;
		    CustomEdge edge = (CustomEdge)edgesInList.get(j);&lt;br /&gt;
		    arcs += String.format(&amp;quot;%d %d %c%c&amp;quot;,&lt;br /&gt;
			    ((CustomNode)edge.getFrom()).getID() + 1,&lt;br /&gt;
			    ((CustomNode)edge.getTo()).getID() + 1, cr, lf);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	String s = verts + arcs;&lt;br /&gt;
	writeToPajekFile(s);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeLineToPajekFile&lt;br /&gt;
    // writes a single line to the pajek file&lt;br /&gt;
    public void writeLineToPajekFile ( String line ) {&lt;br /&gt;
	if ( pajekFile == null ) {&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    pajekFile.println( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // writeToPajekFile&lt;br /&gt;
    // Does the same.&lt;br /&gt;
    public void writeToPajekFile ( String line ) {&lt;br /&gt;
	if ( pajekFile == null ) {&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    pajekFile.print( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // startPajekFile&lt;br /&gt;
    // opens a file to write the pajek network to.&lt;br /&gt;
    public PrintWriter startPajekFile () {&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile called!&amp;quot; );&lt;br /&gt;
	pajekFile = null;&lt;br /&gt;
	String fullFileName = pajekFileName + String.format( &amp;quot;%02d.net&amp;quot;,&lt;br /&gt;
			      model.runNumber );&lt;br /&gt;
	&lt;br /&gt;
	pajekFile = IOUtils.openFileToWrite( outputDirName, fullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile completed!&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	return pajekFile;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // startPajekFile - overload&lt;br /&gt;
    // opens a file to write the pajek network to.  Calls it&lt;br /&gt;
    // by integer i&lt;br /&gt;
    public PrintWriter startPajekFile (int i) {&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile called!&amp;quot; );&lt;br /&gt;
	pajekFile = null;&lt;br /&gt;
	String fullFileName = pajekFileName + String.format(&lt;br /&gt;
			     &amp;quot;%03d.%02d.net&amp;quot;, i, model.runNumber );&lt;br /&gt;
	&lt;br /&gt;
	pajekFile = IOUtils.openFileToWrite( outputDirName, &lt;br /&gt;
					     fullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	if ( model.rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startPajekFile completed!&amp;quot; );&lt;br /&gt;
	return pajekFile;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // endPajekFile&lt;br /&gt;
    // closes the open pajekFile&lt;br /&gt;
    public void endPajekFile ( ) {&lt;br /&gt;
	IOUtils.closePWFile( pajekFile );&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getAverageCC1&lt;br /&gt;
    // Calculates the average 1-neighborhood clustering coefficient&lt;br /&gt;
    public double getAverageCC1(){&lt;br /&gt;
	CustomNode node = null;&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i ++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += getNodeCC1(node);&lt;br /&gt;
	}&lt;br /&gt;
	return sum / (double) agentList.size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getAverageCC2&lt;br /&gt;
    // Calculates the average 2-neighborhood clustering coefficient&lt;br /&gt;
    public double getAverageCC2(){&lt;br /&gt;
	CustomNode node = null;&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; agentList.size(); i ++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += getNodeCC2(node);&lt;br /&gt;
	}&lt;br /&gt;
	return sum / (double) agentList.size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // union&lt;br /&gt;
    // Support function.&lt;br /&gt;
    // Returns the union of two array lists of nodes&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; union(ArrayList&amp;lt;CustomNode&amp;gt; l1, &lt;br /&gt;
				       ArrayList&amp;lt;CustomNode&amp;gt; l2){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; unionList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	unionList.addAll(l1);&lt;br /&gt;
	for(int i = 0; i &amp;lt; l2.size(); i ++){&lt;br /&gt;
	    CustomNode node = (CustomNode) l2.get(i);&lt;br /&gt;
	    if (!unionList.contains(node))&lt;br /&gt;
		unionList.add(node);&lt;br /&gt;
	}&lt;br /&gt;
	return unionList;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // intersection&lt;br /&gt;
    // Support function&lt;br /&gt;
    // Return the intersection of two array lists of nodes&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; intersection(ArrayList&amp;lt;CustomNode&amp;gt; l1, &lt;br /&gt;
				       ArrayList&amp;lt;CustomNode&amp;gt; l2){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; interList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	for(int i = 0; i &amp;lt; l1.size(); i ++){&lt;br /&gt;
	    CustomNode node = (CustomNode) l1.get(i);&lt;br /&gt;
	    if (l2.indexOf(node) &amp;gt;-1)&lt;br /&gt;
		interList.add(node);&lt;br /&gt;
	}&lt;br /&gt;
	return interList;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // getNodeCC1&lt;br /&gt;
    // Computes the clustering coefficient CC1, as per Pajek documentation&lt;br /&gt;
    // This is the 1-neighborhood clustering coefficient&lt;br /&gt;
    public double getNodeCC1 (CustomNode node){&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighborsList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	// Get all neighbors&lt;br /&gt;
	neighborsList = union(node.getOutNodes(), node.getInNodes());&lt;br /&gt;
	int sum = 0;&lt;br /&gt;
	int k = neighborsList.size();&lt;br /&gt;
	for(int j = 0; j &amp;lt; k; j ++){&lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighborsList.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
	    &lt;br /&gt;
	    sum += (intersection(nOut, neighborsList)).size();&lt;br /&gt;
	    sum += (intersection(nIn, neighborsList)).size();&lt;br /&gt;
	   &lt;br /&gt;
	}&lt;br /&gt;
	double cc1 = 0;&lt;br /&gt;
	if (k &amp;gt; 1)&lt;br /&gt;
	    cc1 = (double)sum/( 2* (double)k * (double)(k-1));&lt;br /&gt;
	return cc1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // getNodeCC2&lt;br /&gt;
    // computes the clustering coefficient CC2, as per Pajek documentation&lt;br /&gt;
    // E(G1(v))/E(G2(v))&lt;br /&gt;
    // This is the 2-neighboorhood clustering coefficient&lt;br /&gt;
    public double getNodeCC2 (CustomNode node){&lt;br /&gt;
	&lt;br /&gt;
	// calc E(G1(v)) = sum1&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighbors1List = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighbors2List = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	neighbors1List = union(node.getOutNodes(), node.getInNodes());&lt;br /&gt;
	neighbors2List.addAll(neighbors1List);&lt;br /&gt;
&lt;br /&gt;
	int sum1 = 0;&lt;br /&gt;
	int k = neighbors1List.size();&lt;br /&gt;
	for(int j = 0; j &amp;lt; k; j ++){&lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighbors1List.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
	    &lt;br /&gt;
	    sum1 += (intersection(nOut, neighbors1List)).size();&lt;br /&gt;
	    //sum1 += (intersection(nIn, neighbors1List)).size();&lt;br /&gt;
&lt;br /&gt;
	    neighbors2List = union(neighbors2List, union(nOut, nIn));&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;For node %d sum1 = %d\n&amp;quot;, node.getID(), sum1);&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	int index = neighbors2List.indexOf(node);&lt;br /&gt;
	while (index &amp;gt; 0){&lt;br /&gt;
	    //System.out.printf(&amp;quot;node index = %d\n&amp;quot;, index);&lt;br /&gt;
	    neighbors2List.remove(index);&lt;br /&gt;
	    index = neighbors2List.indexOf(node);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// calc E(G2(v)) = sum2&lt;br /&gt;
	int sum2 = 0;&lt;br /&gt;
	int ind1, ind2;&lt;br /&gt;
	for(int j = 0; j &amp;lt; neighbors2List.size(); j++){&lt;br /&gt;
	    &lt;br /&gt;
	    CustomNode jnode = (CustomNode) neighbors2List.get(j);&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nOut = jnode.getOutNodes();&lt;br /&gt;
	    ArrayList&amp;lt;CustomNode&amp;gt; nIn = jnode.getInNodes();&lt;br /&gt;
&lt;br /&gt;
	    sum2 += (intersection(nOut, neighbors2List)).size();&lt;br /&gt;
	    //sum2 += (intersection(nIn, neighbors2List)).size();&lt;br /&gt;
&lt;br /&gt;
	    ind1 = neighbors2List.indexOf(jnode);&lt;br /&gt;
	    ind2 = neighbors2List.lastIndexOf(jnode);&lt;br /&gt;
	    if (ind1 != ind2)&lt;br /&gt;
		System.out.printf (&amp;quot;Node %d in list multiple times\n&amp;quot;, jnode.getID());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	//System.out.printf(&amp;quot;For node %d sum1 = %d\n&amp;quot;, node.getID(), sum2);&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	double cc2 = 0;&lt;br /&gt;
	if (sum2 &amp;gt; 0)&lt;br /&gt;
	    cc2 = (double)sum1/(double)sum2;&lt;br /&gt;
	return cc2;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // printList&lt;br /&gt;
    // Debug tool&lt;br /&gt;
    // Prints the contents of an ArrayList&lt;br /&gt;
    public void printList(ArrayList&amp;lt;CustomNode&amp;gt; list){&lt;br /&gt;
	for(int i = 0; i &amp;lt; list.size(); i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) list.get(i);&lt;br /&gt;
	    System.out.printf(&amp;quot;%d, &amp;quot;, node.getID());&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
	System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // PickRandomEdge&lt;br /&gt;
    // Picks a random edge with uniform probability in O(m/(n*n))&lt;br /&gt;
    //   (I think)&lt;br /&gt;
    public CustomEdge pickRandomEdge(){&lt;br /&gt;
	CustomEdge edge = null;&lt;br /&gt;
	CustomNode inode;&lt;br /&gt;
	CustomNode jnode;&lt;br /&gt;
	do{&lt;br /&gt;
	    inode = agentList.get(model.getUniformIntFromTo(0, agentList.size() -1));&lt;br /&gt;
	    do{&lt;br /&gt;
		jnode = agentList.get(model.getUniformIntFromTo(0, agentList.size() -1));&lt;br /&gt;
	    } while (inode == jnode);&lt;br /&gt;
	    &lt;br /&gt;
	    if ( (jnode.getOutNodes()).contains(inode))&lt;br /&gt;
		edge = getEdgeFromTo(jnode, inode);&lt;br /&gt;
	} while (edge == null);&lt;br /&gt;
	return edge;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // selectRandomUncoupledPair&lt;br /&gt;
    // Selectrs a random pair of nodes with uniform probability.&lt;br /&gt;
    public CustomNode[] selectRandomUncoupledPair(){&lt;br /&gt;
	boolean pass = false;&lt;br /&gt;
	CustomNode inode, jnode;&lt;br /&gt;
	int i, j;&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	do{&lt;br /&gt;
	    i = model.getUniformIntFromTo(0, agentList.size() -1);&lt;br /&gt;
	    do{&lt;br /&gt;
		j = model.getUniformIntFromTo(0, agentList.size() -1);	&lt;br /&gt;
	    } while (i == j);&lt;br /&gt;
		&lt;br /&gt;
	    inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    jnode = (CustomNode) agentList.get(j);&lt;br /&gt;
	    if ( !(jnode.getOutNodes()).contains(inode)){&lt;br /&gt;
		pass = true;&lt;br /&gt;
	    }&lt;br /&gt;
	} while (!pass);&lt;br /&gt;
	CustomNode[] nodes = {inode, jnode};&lt;br /&gt;
	return nodes;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // selectRandomUncoupledNode&lt;br /&gt;
    // &lt;br /&gt;
    public CustomNode selectRandomUncoupledNode(CustomNode jnode){&lt;br /&gt;
	boolean pass = false;&lt;br /&gt;
	CustomNode inode = null;&lt;br /&gt;
	int i, j = jnode.getID();&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	// get a list of the nodes, but make sure it isn&#039;t the main list&lt;br /&gt;
	// &#039;cause we&#039;re gonna shuffle it&lt;br /&gt;
	ArrayList &amp;lt;CustomNode&amp;gt; nodesList = new ArrayList&amp;lt;CustomNode&amp;gt;();&lt;br /&gt;
	nodesList.addAll(agentList);&lt;br /&gt;
	SimUtilities.shuffle(nodesList, Random.uniform);&lt;br /&gt;
	&lt;br /&gt;
	i = 0;&lt;br /&gt;
	int k = 0;&lt;br /&gt;
	do{&lt;br /&gt;
	    &lt;br /&gt;
	    inode = (CustomNode) nodesList.get(i);&lt;br /&gt;
	    if (inode != jnode){&lt;br /&gt;
		if ( !(jnode.getOutNodes()).contains(inode)){&lt;br /&gt;
		    pass = true;&lt;br /&gt;
		}&lt;br /&gt;
	    }&lt;br /&gt;
	    i++;&lt;br /&gt;
	    if (i == nodesList.size()){&lt;br /&gt;
		i = 0;&lt;br /&gt;
		k ++;&lt;br /&gt;
	    }&lt;br /&gt;
	} while ( !pass &amp;amp;&amp;amp; k &amp;lt; 2 );&lt;br /&gt;
&lt;br /&gt;
	if (k == 2){&lt;br /&gt;
	    do{&lt;br /&gt;
		i = model.getUniformIntFromTo(0, agentList.size() - 1);&lt;br /&gt;
		inode = (CustomNode) agentList.get(i);&lt;br /&gt;
	    } while ( i == j || (jnode.getOutNodes()).contains(inode));&lt;br /&gt;
	}&lt;br /&gt;
	return inode;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    public String getPajekFileName () { return pajekFileName; }&lt;br /&gt;
    public void setPajekFileName ( String s ) {&lt;br /&gt;
	pajekFileName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    public String getOutputDirName () { return outputDirName; }&lt;br /&gt;
    public void setOutputDirName ( String s ) {&lt;br /&gt;
	outputDirName = s;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public int getNetworkSize() {return networkSize;}&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public PrintWriter getPajekFile () { return pajekFile; }&lt;br /&gt;
    &lt;br /&gt;
    public CustomEdge getEdgeFromTo(CustomNode jnode, CustomNode inode){&lt;br /&gt;
	CustomEdge edge;&lt;br /&gt;
	HashSet edgeList = inode.getEdgesFrom(jnode);&lt;br /&gt;
	Object[] edges = edgeList.toArray();&lt;br /&gt;
	// get the edge object connected to jnode&lt;br /&gt;
	edge = ((CustomEdge)edges[0]);&lt;br /&gt;
	return edge;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //**************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
    public static void setModel(CoopNetBlue m){model = m;}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=GameMaster.java&amp;diff=3460</id>
		<title>GameMaster.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=GameMaster.java&amp;diff=3460"/>
		<updated>2006-06-16T04:02:00Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * GameMaster.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on June 13 2006&lt;br /&gt;
 * Last Modified June 14 2006&lt;br /&gt;
 * &lt;br /&gt;
 * This class oversees games played between agents&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 * &lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// GameMaster Constructor&lt;br /&gt;
public class GameMaster {&lt;br /&gt;
     &lt;br /&gt;
    // GUIModel: Stores the model class that runs the graphics&lt;br /&gt;
    public static GUIModel        guiModel = null;&lt;br /&gt;
&lt;br /&gt;
    // model: stores the base model&lt;br /&gt;
    public static CoopNetBlue     model;&lt;br /&gt;
&lt;br /&gt;
    // agentList: Stores a pointer to the agents list&lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt;  agentList;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    public GameMaster (ArrayList agentList) {&lt;br /&gt;
	// If the agent list pointer is sent from CoopNetBlue&lt;br /&gt;
	//  then changing the list here changes it there as well.&lt;br /&gt;
	this.agentList = agentList;&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // playPair&lt;br /&gt;
    // Inputs: nodei, nodej&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Plays a game between two nodes nodei, nodej (symmetric)&lt;br /&gt;
    public void playPair(CustomNode nodei, CustomNode nodej){&lt;br /&gt;
	if (nodei.getUtility() &amp;gt; 0 &amp;amp; nodej.getUtility() &amp;gt; 0 ){&lt;br /&gt;
&lt;br /&gt;
	    // Dumb game.  Flip a coin.&lt;br /&gt;
	    double randn = model.getUniformDoubleFromTo(0,1);&lt;br /&gt;
	    if (randn &amp;lt; 0.5){&lt;br /&gt;
		nodei.incUtility();&lt;br /&gt;
		nodej.decUtility();&lt;br /&gt;
	    }&lt;br /&gt;
	    else{&lt;br /&gt;
		nodej.incUtility();&lt;br /&gt;
		nodei.decUtility();&lt;br /&gt;
	    } &lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // playAll&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Traverses the agent list, playing a game once between&lt;br /&gt;
    //  all pairs of neighbors on the network.&lt;br /&gt;
    public void playAll(){&lt;br /&gt;
	 //for (CustomNode nodej : agentList){&lt;br /&gt;
	 CustomNode nodei, nodej;&lt;br /&gt;
	 &lt;br /&gt;
	 // Traverse the agent list&lt;br /&gt;
	 for (int i = 0; i &amp;lt; agentList.size(); i++){&lt;br /&gt;
	     nodei = agentList.get(i);&lt;br /&gt;
&lt;br /&gt;
	     // Get current node&#039;s neighbors: symmetric network&lt;br /&gt;
	     //  means that out neighbors are just neighbors.&lt;br /&gt;
	     ArrayList&amp;lt;CustomNode&amp;gt; neighbors = nodei.getOutNodes();&lt;br /&gt;
	     for (int j = 0; j &amp;lt; neighbors.size(); j++){&lt;br /&gt;
		 nodej = neighbors.get(j);&lt;br /&gt;
		 &lt;br /&gt;
		 // To ensure game played once between each pair&lt;br /&gt;
		 //  only play in one direction.&lt;br /&gt;
		 if (nodej.getID() &amp;lt; nodei.getID())&lt;br /&gt;
		     playPair(nodej, nodei);&lt;br /&gt;
	     }&lt;br /&gt;
	 }&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // evolveAgents&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    public void evolveAgents(){&lt;br /&gt;
	// Need this to draw the node in the graphics mode.&lt;br /&gt;
	OvalNetworkItem drawable = new OvalNetworkItem(0,0);&lt;br /&gt;
	&lt;br /&gt;
	int i=0,j=1;  // These will be two random values, unequal&lt;br /&gt;
	CustomNode nodei, nodej;&lt;br /&gt;
	int numAgents = agentList.size();&lt;br /&gt;
	do{&lt;br /&gt;
	    i = model.getUniformIntFromTo(0, numAgents-1);&lt;br /&gt;
	    j = model.getUniformIntFromTo(0, numAgents-1);&lt;br /&gt;
	    &lt;br /&gt;
	    nodei = agentList.get(i);&lt;br /&gt;
	    nodej = agentList.get(j);&lt;br /&gt;
	    &lt;br /&gt;
	} while (nodei.getUtility() == nodej.getUtility());&lt;br /&gt;
	// This makes sure that there are no ties, and also that&lt;br /&gt;
	//  i and j are different.&lt;br /&gt;
	&lt;br /&gt;
	CustomNode winner, loser;&lt;br /&gt;
	&lt;br /&gt;
	// Find which wins&lt;br /&gt;
	if (nodei.getUtility() &amp;gt; nodej.getUtility()){&lt;br /&gt;
	    winner = nodei;&lt;br /&gt;
	    loser = nodej;&lt;br /&gt;
	}&lt;br /&gt;
	else{&lt;br /&gt;
	    loser = nodei;&lt;br /&gt;
	    winner = nodej;&lt;br /&gt;
	}&lt;br /&gt;
	winner.bearChild();&lt;br /&gt;
	loser.die();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(CoopNetBlue m) {model = m;}&lt;br /&gt;
    public static void setGUIModel(GUIModel m) {guiModel = m;}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomEdge.java&amp;diff=3459</id>
		<title>CustomEdge.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomEdge.java&amp;diff=3459"/>
		<updated>2006-06-16T04:01:18Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * CustomEdge.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 5:55 PM&lt;br /&gt;
 * Modified on June 13 2006&lt;br /&gt;
 * &lt;br /&gt;
 * This class is for the edges in a netwok&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.gui.DrawableEdge;&lt;br /&gt;
import uchicago.src.sim.gui.SimGraphics;&lt;br /&gt;
import uchicago.src.sim.network.DefaultEdge;&lt;br /&gt;
import uchicago.src.sim.network.Node;&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultEdge gives us the standard edge methods&lt;br /&gt;
// DrawableEdge lets us draw it in the GUI&lt;br /&gt;
public class CustomEdge extends DefaultEdge implements DrawableEdge {&lt;br /&gt;
    //*************************************************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // These are for drawing the edge in GUI&lt;br /&gt;
    public static GUIModel          guiModel = null;&lt;br /&gt;
    public static ColorMap          redColorMap, blueColorMap;&lt;br /&gt;
    public static final int         colorMapSize = 64;&lt;br /&gt;
    public static final int         colorMapMax = colorMapSize - 1;&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    //Instance parameters&lt;br /&gt;
    &lt;br /&gt;
    private Color color = Color.red;  // Edge color&lt;br /&gt;
&lt;br /&gt;
    //***********************************************************&lt;br /&gt;
    // Methods&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor&lt;br /&gt;
    public CustomEdge() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // Constructor (overloaded)&lt;br /&gt;
    // Inputs: Node from, the (generic class) Node from which the edge emerges&lt;br /&gt;
    //         Node to, the (generic) Node to which the edge points&lt;br /&gt;
    public CustomEdge(Node from, Node to) {&lt;br /&gt;
        super(from, to, &amp;quot;&amp;quot;);   // Calls DefaultEdge constructor&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////&lt;br /&gt;
    // setColor&lt;br /&gt;
    // Inputs: Color c&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Sets edge&#039;s color to c, a Java color&lt;br /&gt;
    public void setColor(Color c) {&lt;br /&gt;
        color = c;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////&lt;br /&gt;
    // draw&lt;br /&gt;
    // Inputs: SimGraphics g&lt;br /&gt;
    //         int fromX, toX, fromY, toY&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Required to implement DrawableEdge.&lt;br /&gt;
    public void draw(SimGraphics g, int fromX, int toX, int fromY, int toY) {&lt;br /&gt;
        g.drawDirectedLink(color, fromX, toX, fromY, toY);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //******************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////&lt;br /&gt;
    // setUpEdgeDrawing&lt;br /&gt;
    // Inputs: GUIModel m, a pointer to the GUIModel instance&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Prepares the edge to be drawn in the GUI&lt;br /&gt;
    public static void setUpEdgeDrawing (GUIModel m) {&lt;br /&gt;
	//System.out.printf(&amp;quot;Setting up Edge Color Map\n&amp;quot;);&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	redColorMap = new ColorMap();&lt;br /&gt;
	double minRed = 0.5;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracR = minRed + ( (1.0-minRed)*i/colorMapMax );&lt;br /&gt;
	    fracR = 1.0 + minRed - fracR;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    redColorMap.mapColor(i, fracR, 0, 0);		   &lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	blueColorMap = new ColorMap();&lt;br /&gt;
	double minBlue = 0.5;&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracB = minBlue + ( (1.0-minBlue)*i/colorMapMax );&lt;br /&gt;
	    fracB = 1.0 + minBlue - fracB;&lt;br /&gt;
	    //System.out.printf(&amp;quot;Edge Color Map: i = %d, fR = %f\n&amp;quot;, i, fracR);&lt;br /&gt;
	    blueColorMap.mapColor(i, 0, 0, fracB);		   &lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CustomNode.java&amp;diff=3457</id>
		<title>CustomNode.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CustomNode.java&amp;diff=3457"/>
		<updated>2006-06-16T04:00:54Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * CustomNode.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 2:41 PM&lt;br /&gt;
 * Modified on June 14, 2006&lt;br /&gt;
 *&lt;br /&gt;
 * This class contains the parameters and methods&lt;br /&gt;
 *  for an agent acting on the network&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import uchicago.src.sim.gui.NetworkDrawable;&lt;br /&gt;
import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
import uchicago.src.sim.gui.DrawableNonGridNode;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import uchicago.src.sim.gui.ColorMap;&lt;br /&gt;
import uchicago.src.sim.engine.CustomProbeable;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
// DefaultDrawableNode lets us draw it in the GUI&lt;br /&gt;
// CustomProbeable lets us define which attributes appear when&lt;br /&gt;
//  probed in the GUI&lt;br /&gt;
public class CustomNode extends DefaultDrawableNode implements CustomProbeable {&lt;br /&gt;
    //***********************************&lt;br /&gt;
    // Static Parameters&lt;br /&gt;
&lt;br /&gt;
    // tracks next unique id&lt;br /&gt;
    public static int                   nextID = 0;      &lt;br /&gt;
    &lt;br /&gt;
    public static GUIModel              guiModel = null;&lt;br /&gt;
    public static CoopNetBlue           model;&lt;br /&gt;
&lt;br /&gt;
    //********************************8**&lt;br /&gt;
    // Instance parameters&lt;br /&gt;
&lt;br /&gt;
    // Two colormaps are generated for color-coding the nodes in GUI&lt;br /&gt;
    public static ColorMap              centerColorMap;    &lt;br /&gt;
    public static ColorMap              edgeColorMap;&lt;br /&gt;
    public static final int             colorMapSize = 16;&lt;br /&gt;
    public static final int             colorMapMax = colorMapSize - 1;&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    private int   id;                   // uniquely ids node&lt;br /&gt;
    public Color  myColor;              // used to draw color in GUI&lt;br /&gt;
    public String myPajekColor = &amp;quot;Red&amp;quot;; // color to appear in Pajek output&lt;br /&gt;
    public int    utility;              // current wealth or stored utility&lt;br /&gt;
    public double    strategy;          // strategy parameter&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////&lt;br /&gt;
    // constructor&lt;br /&gt;
    // Inputs: NetworkDrawable drawable, to draw in GUI&lt;br /&gt;
    //         double strategy, the strategy parameter&lt;br /&gt;
    public CustomNode (NetworkDrawable drawable, double strategy) {&lt;br /&gt;
	super(drawable);&lt;br /&gt;
	id = nextID++;              // set id and iterate to next&lt;br /&gt;
	this.strategy = strategy;&lt;br /&gt;
	utility = 50;	            // Generalize.  Currently hard-coded&lt;br /&gt;
	if (guiModel != null)&lt;br /&gt;
	    setNodeEdgeColorFromStrategy();&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // getProbedProperties&lt;br /&gt;
    // Required to implement CustomProbeable&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: array of strings holding parameter names&lt;br /&gt;
    public String[] getProbedProperties(){&lt;br /&gt;
	return new String[] {&amp;quot;id&amp;quot;, &amp;quot;utility&amp;quot;, &amp;quot;strategy&amp;quot;};&lt;br /&gt;
    }&lt;br /&gt;
     &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // (Can be) Called by main model to have nodes execute a single step&lt;br /&gt;
    public void step(){&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeColorFromUtility&lt;br /&gt;
    // Input:  maxUtility, the highest utility from all agents&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node color to the colormap leval depending on utility&lt;br /&gt;
    public void setNodeColorFromUtility(int maxUtility){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*((double)utility)/ ((double) maxUtility));&lt;br /&gt;
	this.setColor(centerColorMap.getColor(i));&lt;br /&gt;
	/*if (rDebug &amp;gt; 1){&lt;br /&gt;
	    double rat = ((double) getUtility())/((double) maxUtility);&lt;br /&gt;
	    int ival = (int) Math.round(rat*colorMapSize);&lt;br /&gt;
	    System.out.printf(&amp;quot;%d/%d = %f -&amp;gt; %d\n&amp;quot;, getUtility(), maxUtility, rat, ival);&lt;br /&gt;
	    }*/&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setNodeEdgeColorFromStrategy&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Sets the node edge color to the colormap level depending on strategy&lt;br /&gt;
    public void setNodeEdgeColorFromStrategy(){&lt;br /&gt;
	int i = (int) Math.round(colorMapMax*strategy);&lt;br /&gt;
	this.setBorderColor(edgeColorMap.getColor(i));&lt;br /&gt;
	this.setBorderWidth(3);&lt;br /&gt;
	/*if (rDebug &amp;gt; 1){&lt;br /&gt;
	    double rat = ((double) getUtility())/((double) maxUtility);&lt;br /&gt;
	    int ival = (int) Math.round(rat*colorMapSize);&lt;br /&gt;
	    System.out.printf(&amp;quot;%d/%d = %f -&amp;gt; %d\n&amp;quot;, getUtility(), maxUtility, rat, ival);&lt;br /&gt;
	    }*/&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ////////////////////////////////////////////////////////////&lt;br /&gt;
    // bearChild&lt;br /&gt;
    // Input:  none&lt;br /&gt;
    // Output: node&lt;br /&gt;
    // Creates a child node&lt;br /&gt;
    public void bearChild(){&lt;br /&gt;
	double deviation = model.getNormalDouble(0, 0.1);  // mutate child&lt;br /&gt;
	double childStrategy = strategy + deviation;&lt;br /&gt;
	childStrategy = Math.min(1, Math.max(0, childStrategy));&lt;br /&gt;
&lt;br /&gt;
	OvalNetworkItem drawable = new OvalNetworkItem(0,0);&lt;br /&gt;
&lt;br /&gt;
	CustomNode child = new CustomNode(drawable, childStrategy);&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; parentNeighbors = this.getOutNodes();&lt;br /&gt;
	for (CustomNode neighbor : parentNeighbors){&lt;br /&gt;
	    CustomEdge edge1 = new CustomEdge(child, neighbor);&lt;br /&gt;
	    CustomEdge edge2 = new CustomEdge(neighbor, child);&lt;br /&gt;
	    &lt;br /&gt;
	    &lt;br /&gt;
	    // I think you have to add edges in and out to make it&lt;br /&gt;
	    //  undirected.&lt;br /&gt;
	    child.addOutEdge(edge1);&lt;br /&gt;
	    neighbor.addInEdge(edge1);&lt;br /&gt;
	    child.addInEdge(edge2);&lt;br /&gt;
	    neighbor.addOutEdge(edge2);&lt;br /&gt;
	}&lt;br /&gt;
	CustomEdge edge1 = new CustomEdge(this, child);&lt;br /&gt;
	CustomEdge edge2 = new CustomEdge(child, this);&lt;br /&gt;
	 &lt;br /&gt;
	child.addOutEdge(edge2);&lt;br /&gt;
	this.addInEdge(edge2);&lt;br /&gt;
	child.addInEdge(edge1);&lt;br /&gt;
	this.addOutEdge(edge1);&lt;br /&gt;
&lt;br /&gt;
	if (guiModel!=null)&lt;br /&gt;
	    guiModel.addAgent(child);&lt;br /&gt;
	else&lt;br /&gt;
	    model.addAgent(child);&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // die&lt;br /&gt;
    // Inputs: none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Kills an agent&lt;br /&gt;
    public void die(){&lt;br /&gt;
	// Go through neighbors, removing links to or from node&lt;br /&gt;
	// Make sure you get them all!&lt;br /&gt;
	ArrayList&amp;lt;CustomNode&amp;gt; neighbors = this.getOutNodes();&lt;br /&gt;
	for (CustomNode neigh : neighbors){&lt;br /&gt;
	    neigh.removeEdgesFrom(this);&lt;br /&gt;
	    neigh.removeEdgesTo(this);&lt;br /&gt;
	}&lt;br /&gt;
	if (guiModel != null)&lt;br /&gt;
	    guiModel.delAgent(this);&lt;br /&gt;
	else&lt;br /&gt;
	    model.delAgent(this);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // getDegree&lt;br /&gt;
    // Input: none&lt;br /&gt;
    // Output: int degree&lt;br /&gt;
    // Calculates the degree of the node (assuming symmetric)&lt;br /&gt;
    public int getDegree(){	&lt;br /&gt;
	return (this.getOutNodes()).size();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Getters and Setters&lt;br /&gt;
    public int      getID() {return id;}&lt;br /&gt;
&lt;br /&gt;
    public void     setMyPajekColor(String i) {myPajekColor = i;}&lt;br /&gt;
    public String   getMyPajekColor() {return myPajekColor;}&lt;br /&gt;
    &lt;br /&gt;
    public int      getUtility() {return utility;}&lt;br /&gt;
    public void     setUtility(int i) {utility = i;}&lt;br /&gt;
&lt;br /&gt;
    public int      incUtility() {return ++utility;}&lt;br /&gt;
    public int      decUtility() {return --utility;}&lt;br /&gt;
&lt;br /&gt;
    public double   getStrategy() {return strategy;}&lt;br /&gt;
    public void     setStrategy(double i) {strategy = i;}&lt;br /&gt;
    &lt;br /&gt;
    //***************************************************************&lt;br /&gt;
    // Static Methods&lt;br /&gt;
&lt;br /&gt;
    public static void setModel(CoopNetBlue m) {model = m;}&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // setUpNodeDrawing&lt;br /&gt;
    // Input: GUIModel m, a pointer to the GUIModel&lt;br /&gt;
    // Output: none&lt;br /&gt;
    public static void setUpNodeDrawing (GUIModel m) {&lt;br /&gt;
	guiModel = m;&lt;br /&gt;
	centerColorMap = new ColorMap();&lt;br /&gt;
	edgeColorMap   = new ColorMap();&lt;br /&gt;
	double minColor = 0.1;&lt;br /&gt;
	&lt;br /&gt;
	for (int i = 0; i &amp;lt; colorMapSize; i++){&lt;br /&gt;
	    double fracColor = minColor + ( (1.0-minColor)*i/colorMapMax );&lt;br /&gt;
&lt;br /&gt;
	    centerColorMap.mapColor(i, 0, 0, fracColor);&lt;br /&gt;
	    edgeColorMap.mapColor(i, 0, fracColor, 0);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////&lt;br /&gt;
    // resetNextID&lt;br /&gt;
    // Inputs:  none&lt;br /&gt;
    // Outputs: none&lt;br /&gt;
    // Resets nextID.  Called when the model is reset, and a &lt;br /&gt;
    //  new set of nodes is generated&lt;br /&gt;
    public static void resetNextID(){&lt;br /&gt;
	nextID = 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=ModelParameters.java&amp;diff=3456</id>
		<title>ModelParameters.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=ModelParameters.java&amp;diff=3456"/>
		<updated>2006-06-16T04:00:28Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.util.Formatter;  // import this class lib&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import java.util.regex.*;  // for MatchResult&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.awt.FileDialog;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
&lt;br /&gt;
import java.text.NumberFormat;&lt;br /&gt;
import java.text.DecimalFormat;&lt;br /&gt;
import java.text.DateFormat;&lt;br /&gt;
import java.sql.Time;&lt;br /&gt;
&lt;br /&gt;
import java.lang.reflect.*;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.*;&lt;br /&gt;
import uchicago.src.sim.gui.*;&lt;br /&gt;
import uchicago.src.sim.space.*;&lt;br /&gt;
import uchicago.src.sim.network.*;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
import uchicago.src.reflector.ListPropertyDescriptor;&lt;br /&gt;
import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.analysis.*;&lt;br /&gt;
import uchicago.src.collection.RangeMap;&lt;br /&gt;
import uchicago.src.sim.event.SliderListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
&lt;br /&gt;
//for the xml parsing of input files&lt;br /&gt;
import javax.xml.parsers.DocumentBuilderFactory;&lt;br /&gt;
import javax.xml.parsers.DocumentBuilder;&lt;br /&gt;
import org.w3c.dom.Document;&lt;br /&gt;
import org.w3c.dom.Node;&lt;br /&gt;
import org.w3c.dom.NodeList;&lt;br /&gt;
import org.w3c.dom.Attr;&lt;br /&gt;
import org.w3c.dom.Element;&lt;br /&gt;
&lt;br /&gt;
import java.util.TreeMap;&lt;br /&gt;
&lt;br /&gt;
import rlriolo.ioutils.*;&lt;br /&gt;
&lt;br /&gt;
public class ModelParameters extends SimModelImpl {&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
    long startTime = System.currentTimeMillis();&lt;br /&gt;
    &lt;br /&gt;
    // setup&lt;br /&gt;
    // this should be called *last* in the Model setup() that&lt;br /&gt;
    // extends this class.&lt;br /&gt;
    public void setup() {&lt;br /&gt;
	changesVector = new Vector();&lt;br /&gt;
	setupParametersMap();&lt;br /&gt;
	// this might be kind of kludgy?&lt;br /&gt;
	// only process command line arguments if it is the first run&lt;br /&gt;
	// if it is the first run then schedule is null,&lt;br /&gt;
	// if not then schedule is initialized (and is set to null&lt;br /&gt;
	// on the next line)&lt;br /&gt;
	if( schedule == null ) &lt;br /&gt;
	    processCommandLinePars( commandLineArgs );&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;--- ModelParameters setup() done.\n&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void begin() {&lt;br /&gt;
	// this must be declared in the class that &#039;extends&#039; this one&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // buildModelStart&lt;br /&gt;
    // this should be called first by the buildModel in the extending class.&lt;br /&gt;
    public void buildModelStart() {&lt;br /&gt;
	if ( getSeed() == 1234567 || getSeed() == 0) {&lt;br /&gt;
	    long s = System.currentTimeMillis();&lt;br /&gt;
	    setSeed( s );&lt;br /&gt;
	    if ( rDebug &amp;gt; 1 )&lt;br /&gt;
		System.out.printf( &amp;quot;\nseed was 1234567 or 0, now ==&amp;gt; s=%d\n&amp;quot;, s );&lt;br /&gt;
	}&lt;br /&gt;
	if( rDebug &amp;gt; 1 )&lt;br /&gt;
	    System.out.printf( &amp;quot;\nabout to setSeed(%d)\n&amp;quot;, getSeed() );&lt;br /&gt;
	resetRNGenerators();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // the extending classes must fill this in&lt;br /&gt;
    public void buildSchedule() {&lt;br /&gt;
	//if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	//	System.err.printf( &amp;quot;-&amp;gt; ModelParameters buildSchedule...\n&amp;quot; );&lt;br /&gt;
	schedule = new Schedule();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    public String[] getInitParam() {&lt;br /&gt;
	// this must be declared in the class that &#039;extends&#039; this one&lt;br /&gt;
	return null;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // Generic parameters&lt;br /&gt;
    protected String		initialParametersFileName = &amp;quot;&amp;quot;;&lt;br /&gt;
    protected String		initialAgentsFileName = &amp;quot;&amp;quot;;&lt;br /&gt;
    protected String		reportFileName = &amp;quot;report&amp;quot;;&lt;br /&gt;
    protected String		outputDirName =  &amp;quot;./&amp;quot;;&lt;br /&gt;
    protected int	       	reportFrequency = 1;&lt;br /&gt;
    protected int	       	runNumber = 0;&lt;br /&gt;
    protected int	       	stopT = 100000; //100&lt;br /&gt;
    protected int	       	rDebug = 0;&lt;br /&gt;
    protected int	       	saveRunEndState = 0;&lt;br /&gt;
    protected long    		seed = 1234567;&lt;br /&gt;
    protected PrintWriter      	reportFile, plaintextReportFile;&lt;br /&gt;
    protected PrintWriter      	changesFile;&lt;br /&gt;
    &lt;br /&gt;
    // other utilities&lt;br /&gt;
    protected String[] commandLineArgs;&lt;br /&gt;
    protected String modelType = &amp;quot;Model&amp;quot;;&lt;br /&gt;
    &lt;br /&gt;
    //for input file &lt;br /&gt;
    protected boolean 	STRICT_FILE_FORMAT = true;&lt;br /&gt;
    protected Vector 		changesVector;&lt;br /&gt;
    &lt;br /&gt;
    // variables for processing run-time changes that are&lt;br /&gt;
    // read in from the input file&lt;br /&gt;
    protected int 	numberOfChanges = 0;&lt;br /&gt;
    protected int 	nextChangeToDo  = 0;&lt;br /&gt;
    protected int[] 	changeSteps     = new int[64];&lt;br /&gt;
    protected int[] 	changeIDs       = new int[64];&lt;br /&gt;
    protected ArrayList changeSpecs     = new ArrayList(16);&lt;br /&gt;
    &lt;br /&gt;
    // required by SimModelImpl&lt;br /&gt;
    protected BasicAction	stepMethods;&lt;br /&gt;
    protected Schedule	schedule = null;&lt;br /&gt;
    &lt;br /&gt;
    // setupParametersMap&lt;br /&gt;
    // this implements the mapping from aliases to long names,&lt;br /&gt;
    // for the &#039;base&#039; parameters common to all models.&lt;br /&gt;
    // For parameters for a particular model, add lines&lt;br /&gt;
    // to addToParametersMap().&lt;br /&gt;
    protected   TreeMap parametersMap;&lt;br /&gt;
    public void setupParametersMap () {&lt;br /&gt;
	DMSG( 1, &amp;quot;setupParametersMap()&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	parametersMap = null;&lt;br /&gt;
	parametersMap = new TreeMap();&lt;br /&gt;
	// generic model parameters&lt;br /&gt;
	parametersMap.put( &amp;quot;D&amp;quot;, &amp;quot;rDebug&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;S&amp;quot;, &amp;quot;seed&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;iPFN&amp;quot;, &amp;quot;initialParametersFileName&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;iAFN&amp;quot;, &amp;quot;initialAgentsFileName&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;rFN&amp;quot;, &amp;quot;reportFileName&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;T&amp;quot;, &amp;quot;stopT&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;sRES&amp;quot;, &amp;quot;saveRunEndState&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;oDN&amp;quot;, &amp;quot;outputDirName&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;rF&amp;quot;, &amp;quot;reportFrequency&amp;quot; );&lt;br /&gt;
	parametersMap.put( &amp;quot;rN&amp;quot;, &amp;quot;runNumber&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	addModelSpecificParameters();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // a subclass should override this. &lt;br /&gt;
    public void addModelSpecificParameters() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printParametersMap () {&lt;br /&gt;
	&lt;br /&gt;
	ArrayList parameterNames = new ArrayList( parametersMap.values() );&lt;br /&gt;
	ArrayList parameterAliases = new ArrayList( parametersMap.keySet() );&lt;br /&gt;
	&lt;br /&gt;
	for( int i = 0; i &amp;lt; parameterAliases.size(); i++ ) {&lt;br /&gt;
	    Method getmethod = null;&lt;br /&gt;
	    String parAlias = (String)  parameterAliases.get(i);&lt;br /&gt;
	    String parName = (String) parametersMap.get( parAlias );&lt;br /&gt;
	    &lt;br /&gt;
	    getmethod = findGetMethodFor( parName );&lt;br /&gt;
	    &lt;br /&gt;
	    if( getmethod != null ) {&lt;br /&gt;
		try {&lt;br /&gt;
		    Object returnVal = getmethod.invoke( this, new Object[] {} );&lt;br /&gt;
		    String s =  parName + &amp;quot; (&amp;quot; + parAlias + &amp;quot;) = &amp;quot; + returnVal;&lt;br /&gt;
		    System.out.printf( &amp;quot;%s\n&amp;quot;, s );&lt;br /&gt;
		} catch( Exception e ) { e.printStackTrace(); }&lt;br /&gt;
	    }&lt;br /&gt;
	    else {&lt;br /&gt;
		System.err.printf ( &amp;quot;COULD NOT FIND SET METHOD FOR:  %s\n&amp;quot;, &lt;br /&gt;
				    parameterNames.get( i ) );&lt;br /&gt;
		System.err.printf ( &amp;quot;Is the entry in the parametersMap for this correct?&amp;quot; );&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    //////////////////////////////////////////////////////////////////&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // generic setters/getters&lt;br /&gt;
    &lt;br /&gt;
    public String[] getCommandLineArgs () { return commandLineArgs; }&lt;br /&gt;
    public void setCommandLineArgs ( String[] arguments ) {&lt;br /&gt;
	// for( int i = 0; i &amp;lt; arguments.length; i++ ) {&lt;br /&gt;
	//	System.out.println( &amp;quot;setCommandLineArgs: &amp;quot; + arguments[i] );&lt;br /&gt;
	// }&lt;br /&gt;
	commandLineArgs = arguments;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getModelType() { return modelType; }&lt;br /&gt;
    public void setModelType( String s ) {&lt;br /&gt;
	modelType = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getInitialParametersFileName () { &lt;br /&gt;
	return initialParametersFileName; }&lt;br /&gt;
    public void setInitialParametersFileName ( String s ) {&lt;br /&gt;
	initialParametersFileName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getInitialAgentsFileName () { &lt;br /&gt;
	return initialAgentsFileName; }&lt;br /&gt;
    public void setInitialAgentsFileName ( String s ) {&lt;br /&gt;
	initialAgentsFileName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getReportFileName () { return reportFileName; }&lt;br /&gt;
    public void setReportFileName ( String s ) {&lt;br /&gt;
	reportFileName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getOutputDirName () { return outputDirName; }&lt;br /&gt;
    public void setOutputDirName ( String s ) {&lt;br /&gt;
	outputDirName = s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int getReportFrequency () { return reportFrequency; }&lt;br /&gt;
    public void setReportFrequency ( int i ) {&lt;br /&gt;
	reportFrequency = i;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int getRunNumber () { return runNumber; }&lt;br /&gt;
    public void setRunNumber ( int i ) {&lt;br /&gt;
	runNumber = i;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int getStopT () { return stopT; }&lt;br /&gt;
    public void setStopT ( int i ) {&lt;br /&gt;
	stopT = i;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int getSaveRunEndState () { return saveRunEndState; }&lt;br /&gt;
    public void setSaveRunEndState ( int i ) {&lt;br /&gt;
	saveRunEndState = i;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public int getRDebug () { return rDebug; }&lt;br /&gt;
    public void setRDebug ( int i ) {&lt;br /&gt;
	if( rDebug == i ) {&lt;br /&gt;
	    // System.out.printf( &amp;quot;setRDebug called, but value unchanged, returning&amp;quot; );&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	// System.out.println( &amp;quot;setRDebug ( &amp;quot; + i + &amp;quot; ) called&amp;quot; );&lt;br /&gt;
	rDebug = i;&lt;br /&gt;
	if( modelType.equals( &amp;quot;GUIModel&amp;quot; ) ) {&lt;br /&gt;
	    updateAllProbePanels();&lt;br /&gt;
	}&lt;br /&gt;
	if( modelType.equals( &amp;quot;GUIModel&amp;quot; ) &amp;amp;&amp;amp; schedule != null )&lt;br /&gt;
	    writeChangeToReportFile ( &amp;quot;rDebug&amp;quot;, String.valueOf( i ) );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public long getSeed () { return seed; }&lt;br /&gt;
    public void setSeed ( long i ) {&lt;br /&gt;
	if( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;setSeed ( &amp;quot; + i + &amp;quot; ) called&amp;quot; );&lt;br /&gt;
	seed = i;&lt;br /&gt;
	&lt;br /&gt;
	resetRNGenerators();&lt;br /&gt;
	&lt;br /&gt;
	if( modelType.equals( &amp;quot;GUIModel&amp;quot; ) ) {&lt;br /&gt;
	    updateAllProbePanels();&lt;br /&gt;
	}&lt;br /&gt;
	if( modelType.equals( &amp;quot;GUIModel&amp;quot; ) &amp;amp;&amp;amp; schedule != null)&lt;br /&gt;
	    writeChangeToReportFile ( &amp;quot;seed&amp;quot;, String.valueOf( i ) );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void resetRNGenerators ( ) {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;\nresetRNGenerators with %d\n&amp;quot;, getSeed() );&lt;br /&gt;
	&lt;br /&gt;
	// this is required because once you change the seed you invalidate&lt;br /&gt;
	// any previously created distributions&lt;br /&gt;
	uchicago.src.sim.util.Random.setSeed( seed );&lt;br /&gt;
	uchicago.src.sim.util.Random.createUniform();&lt;br /&gt;
	uchicago.src.sim.util.Random.createNormal( 0.0, 1.0 );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // NOTE: these are class methods!&lt;br /&gt;
    static public int getUniformIntFromTo ( int low, int high ) {&lt;br /&gt;
	int randNum = Random.uniform.nextIntFromTo( low, high );&lt;br /&gt;
	// System.out.println( &amp;quot;getUniformIntFromTo:  &amp;quot; + randNum );&lt;br /&gt;
	return randNum;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    static public double getNormalDouble ( double mean, double var ) {&lt;br /&gt;
	double randNum =  Random.normal.nextDouble ( mean, var );&lt;br /&gt;
	// System.out.println( &amp;quot;getNormalDouble:  &amp;quot; + randNum );&lt;br /&gt;
	return randNum;&lt;br /&gt;
    }&lt;br /&gt;
    static public double getUniformDoubleFromTo( double low, double high ) {&lt;br /&gt;
	double randNum = Random.uniform.nextDoubleFromTo( low, high );&lt;br /&gt;
	// System.out.println( &amp;quot;getUniformDoubleFromTo:  &amp;quot; + randNum );&lt;br /&gt;
	return randNum;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // loop until a number between 0 and 1 is generated,&lt;br /&gt;
    // if mean and var are set correctly the loop will rarely happen&lt;br /&gt;
    static public double getNormalDoubleProb ( double mean, double var ) {&lt;br /&gt;
	if ( mean &amp;lt; 0 || mean &amp;gt; 1 ) {&lt;br /&gt;
	    System.out.println ( &amp;quot;Invalid value set for normal distribution mean&amp;quot; );&lt;br /&gt;
	    return -1;&lt;br /&gt;
	}&lt;br /&gt;
	double d = Random.normal.nextDouble ( mean, var );&lt;br /&gt;
	while ( d &amp;lt; 0 || d &amp;gt; 1 )&lt;br /&gt;
	    d = Random.normal.nextDouble ( mean, var );&lt;br /&gt;
	&lt;br /&gt;
	// System.out.println( &amp;quot;getNormalDoubleProb:  &amp;quot; + d );&lt;br /&gt;
	&lt;br /&gt;
	return d;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void setRngSeed ( long i ) {&lt;br /&gt;
	System.out.println( &amp;quot;setRngSeed ( &amp;quot; + i + &amp;quot; ) called&amp;quot; );&lt;br /&gt;
	setSeed( i );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public PrintWriter getReportFile () { return reportFile; }&lt;br /&gt;
    public PrintWriter getPlaintextReportFile () { return plaintextReportFile; }&lt;br /&gt;
    public Schedule getSchedule() { return schedule; }&lt;br /&gt;
    &lt;br /&gt;
    // rePast needs this (i guess...)&lt;br /&gt;
    public String getName() { return &amp;quot;ModelParameters&amp;quot;; }&lt;br /&gt;
    &lt;br /&gt;
    // some generic utilities&lt;br /&gt;
    public void updateAllProbePanels() {&lt;br /&gt;
	DMSG ( 2, &amp;quot;updateAllProbePanels()&amp;quot; );&lt;br /&gt;
	ProbeUtilities.updateProbePanels();&lt;br /&gt;
	&lt;br /&gt;
	// kludge...&lt;br /&gt;
	// need this in case updateAllProbePanels gets called&lt;br /&gt;
	// before the probe panel is created (if it is called&lt;br /&gt;
	// before, then a RuntimeException occurs)&lt;br /&gt;
	// did have if(schedule != null), but that means panels&lt;br /&gt;
	// do not update at all during time=0, so people get confused.&lt;br /&gt;
	try {&lt;br /&gt;
	    ProbeUtilities.updateModelProbePanel();&lt;br /&gt;
	}&lt;br /&gt;
	catch (RuntimeException e) {&lt;br /&gt;
	    // ignore exception&lt;br /&gt;
	    DMSG( 3, &amp;quot;RuntimeException when updating model probe panel, ignoring ...&amp;quot; );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // captialize first character of s&lt;br /&gt;
    protected String capitalize( String s ) {&lt;br /&gt;
	char c = s.charAt( 0 );&lt;br /&gt;
	char upper = Character.toUpperCase( c );&lt;br /&gt;
	return upper + s.substring( 1, s.length() );&lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // REPORT FILE PROCESSING ------------------------------&lt;br /&gt;
    //&lt;br /&gt;
    // startReportFile&lt;br /&gt;
    // opens two report files&lt;br /&gt;
    // one XML report file and one plaintext report file&lt;br /&gt;
    // call writeLineToReportFile to write to XML report file&lt;br /&gt;
    // and writeLineToPlaintextReportFile to write to plaintext file&lt;br /&gt;
    &lt;br /&gt;
    public PrintWriter startReportFile ( ) {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.println( &amp;quot;startReportFile called!&amp;quot; );&lt;br /&gt;
	reportFile = null;&lt;br /&gt;
	plaintextReportFile = null;&lt;br /&gt;
	String fullFileName = reportFileName + String.format( &amp;quot;.%02d&amp;quot;, runNumber );&lt;br /&gt;
	String xmlFullFileName = reportFileName + &amp;quot;.xml&amp;quot; &lt;br /&gt;
	    + String.format( &amp;quot;.%02d&amp;quot;, runNumber );&lt;br /&gt;
	&lt;br /&gt;
	// BufferedReader inFile = IOUtils.openFileToRead(initialParametersFileName);&lt;br /&gt;
	&lt;br /&gt;
	//reportFile = IOUtils.openFileToWrite( outputDirName, xmlFullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	plaintextReportFile = IOUtils.openFileToWrite( outputDirName, fullFileName, &amp;quot;r&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// the first line you have to write is the XML version line&lt;br /&gt;
	// DO NOT WRITE THIS LINE USING writeLineToReportFile()!&lt;br /&gt;
	//reportFile.println( &amp;quot;&amp;lt;?xml version=\&amp;quot;1.0\&amp;quot; encoding=\&amp;quot;UTF-8\&amp;quot;?&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;reportfile&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot;# begin reportfile&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	//  write the initial parameters to the report file&lt;br /&gt;
	writeParametersToReportFile();&lt;br /&gt;
	&lt;br /&gt;
	writeHeaderCommentsToReportFile();  // the user must define this!&lt;br /&gt;
	&lt;br /&gt;
	return reportFile;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void writeLineToReportFile ( String line ) {&lt;br /&gt;
	if ( reportFile == null ) {&lt;br /&gt;
	    DMSG( 3, &amp;quot;report file not opened yet&amp;quot; );&lt;br /&gt;
	    // click the initialize button to open it! &lt;br /&gt;
	    // returning w/o writing to report file ...&amp;quot;);&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    reportFile.println( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void writeLineToPlaintextReportFile ( String line ) {&lt;br /&gt;
	if ( plaintextReportFile == null ) {&lt;br /&gt;
	    DMSG( 3, &amp;quot;report file not opened yet&amp;quot; );&lt;br /&gt;
	    // click the initialize button to open it! &lt;br /&gt;
	    // returning w/o writing to report file ...&amp;quot;);&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    plaintextReportFile.println( line );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void writeChangeToReportFile( String varname, String value ) {&lt;br /&gt;
	DMSG( 1, &amp;quot;writeChangeToReportFile(): write change to report file: &amp;quot; &lt;br /&gt;
	      + varname + &amp;quot; changed to &amp;quot; + value );&lt;br /&gt;
	&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;change&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;\t&amp;lt;&amp;quot; + varname + &amp;quot;&amp;gt;&amp;quot; + value &lt;br /&gt;
			       + &amp;quot;&amp;lt;/&amp;quot; + varname + &amp;quot;&amp;gt;&amp;quot; );&lt;br /&gt;
	String s = String.format(  &amp;quot;\t&amp;lt;time&amp;gt;%.0f&amp;lt;/time&amp;gt;&amp;quot;, getTickCount() );&lt;br /&gt;
	//writeLineToReportFile( s );&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;/change&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot;# change:  &amp;quot; + varname + &amp;quot;=&amp;quot; + value );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /*public void endReportFile ( ) {&lt;br /&gt;
      writeLineToReportFile( &amp;quot;&amp;lt;/reportfile&amp;gt;&amp;quot; );&lt;br /&gt;
      String s = String.format(&amp;quot;# end report file&amp;quot;);//: ran %f steps in %f seconds.&amp;quot;, schedule.getCurrentTime(), ((double)(System.currentTimeMillis() - startTime))/1000.0 );&lt;br /&gt;
      writeLineToPlaintextReportFile( s );&lt;br /&gt;
      IOUtils.closePWFile( reportFile );&lt;br /&gt;
      IOUtils.closePWFile( plaintextReportFile );&lt;br /&gt;
      }*/&lt;br /&gt;
    &lt;br /&gt;
    public void endReportFile (long steps ) {&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;/reportfile&amp;gt;&amp;quot; );&lt;br /&gt;
	String s = String.format(&amp;quot;# end report file: ran %d steps in %f seconds.&amp;quot;, steps,  ((double)(System.currentTimeMillis() - startTime))/1000.0 );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	//IOUtils.closePWFile( reportFile );&lt;br /&gt;
	IOUtils.closePWFile( plaintextReportFile );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // this iterates through the values stored in the parametersMap, &lt;br /&gt;
    // calls the getter on each parameter, and outputs the &lt;br /&gt;
    // parameter and its value to the report file.&lt;br /&gt;
    // this is called right before the model run starts (after all &lt;br /&gt;
    // initial parameters are changed!) so &lt;br /&gt;
    // the initial parameters are in the report file.&lt;br /&gt;
    public void writeParametersToReportFile() {&lt;br /&gt;
	DMSG( 1, &amp;quot;writeParametersToReportFile()&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf(&amp;quot;Begin Writing Parameters.\n&amp;quot;);&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;parameters&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot;# begin parameters&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	ArrayList parameterNames = new ArrayList( parametersMap.values() );&lt;br /&gt;
	System.out.printf(&amp;quot;parametersMap size = %d\n&amp;quot;, parameterNames.size());&lt;br /&gt;
	for( int i = 0; i &amp;lt; parameterNames.size(); i++ ) {&lt;br /&gt;
	    System.out.printf(&amp;quot;Printing %s\n&amp;quot;, (String) parameterNames.get(i));&lt;br /&gt;
	    Method getmethod = null;&lt;br /&gt;
	    getmethod = findGetMethodFor( (String) parameterNames.get( i ) );&lt;br /&gt;
	    &lt;br /&gt;
	    if( getmethod != null ) {&lt;br /&gt;
		try {&lt;br /&gt;
		    Object returnVal = getmethod.invoke( this, new Object[] {} );&lt;br /&gt;
		    &lt;br /&gt;
		    /*writeLineToReportFile( &amp;quot;\t&amp;lt;&amp;quot; + parameterNames.get(i) + &amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
		      + returnVal &lt;br /&gt;
		      + &amp;quot;&amp;lt;/&amp;quot; + parameterNames.get(i) + &amp;quot;&amp;gt;&amp;quot; );*/&lt;br /&gt;
		    &lt;br /&gt;
		    writeLineToPlaintextReportFile( parameterNames.get(i)&lt;br /&gt;
						    + &amp;quot;=&amp;quot;&lt;br /&gt;
						    + returnVal );&lt;br /&gt;
		    &lt;br /&gt;
		} catch( Exception e ) { e.printStackTrace(); }&lt;br /&gt;
	    }&lt;br /&gt;
	    else {&lt;br /&gt;
		System.err.printf ( &amp;quot;COULD NOT FIND SET METHOD FOR:  %s\n&amp;quot;, &lt;br /&gt;
				    parameterNames.get( i ) );&lt;br /&gt;
		System.err.printf ( &amp;quot;Is the entry in the parametersMap for this correct?&amp;quot; );&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	//writeLineToReportFile( &amp;quot;&amp;lt;/parameters&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot;# end parameters&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // parseParametersFile&lt;br /&gt;
    //&lt;br /&gt;
    public void parseParametersFile() {&lt;br /&gt;
	// a klunky way to see if the parameters file exists&lt;br /&gt;
	try {&lt;br /&gt;
	    BufferedReader inFile = &lt;br /&gt;
		IOUtils.openFileToRead(initialParametersFileName );&lt;br /&gt;
	    IOUtils.closeBRFile( inFile );&lt;br /&gt;
	}&lt;br /&gt;
	catch(Exception e) { // not an error, just not there!&lt;br /&gt;
	    if ( rDebug &amp;gt; 0 )&lt;br /&gt;
		System.err.printf( &amp;quot;  -- no initialParametersFileName &#039;%s&#039; to parse.\n&amp;quot;, &lt;br /&gt;
				   initialParametersFileName );&lt;br /&gt;
	    return;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	try {&lt;br /&gt;
	    //setup the input file&lt;br /&gt;
	    DocumentBuilderFactory myDBF = DocumentBuilderFactory.newInstance();&lt;br /&gt;
	    DocumentBuilder myDB = myDBF.newDocumentBuilder();&lt;br /&gt;
	    Document myDocument = myDB.parse(initialParametersFileName);&lt;br /&gt;
	    &lt;br /&gt;
	    if ( rDebug &amp;gt; 0 )&lt;br /&gt;
		System.out.println(&amp;quot;Parsing parameter file: &amp;quot;+initialParametersFileName);&lt;br /&gt;
	    &lt;br /&gt;
	    NodeList tmpList = myDocument.getElementsByTagName(&amp;quot;parameters&amp;quot;);&lt;br /&gt;
	    Element tmpElement = (Element)tmpList.item(0);&lt;br /&gt;
	    NodeList parameterList = tmpElement.getElementsByTagName(&amp;quot;*&amp;quot;);&lt;br /&gt;
	    &lt;br /&gt;
	    for(int i = 0; i &amp;lt; parameterList.getLength(); i++) {&lt;br /&gt;
		if ( parameterList.item(i).getChildNodes().item(0) == null)&lt;br /&gt;
		    continue;&lt;br /&gt;
		DMSG( 1, &amp;quot;name:  &amp;quot; + parameterList.item(i).getNodeName()&lt;br /&gt;
		      + &amp;quot;  value:  &amp;quot;&lt;br /&gt;
		      + parameterList.item(i).getChildNodes().item(0).getNodeValue() );&lt;br /&gt;
		set( parameterList.item(i).getNodeName(), &lt;br /&gt;
		     parameterList.item(i).getChildNodes().item(0).getNodeValue() );&lt;br /&gt;
	    }&lt;br /&gt;
	    &lt;br /&gt;
	    // process changes&lt;br /&gt;
	    NodeList parameterChangeList = myDocument.getElementsByTagName( &amp;quot;change&amp;quot; );&lt;br /&gt;
	    processChangeList( parameterChangeList );&lt;br /&gt;
	    &lt;br /&gt;
	    DMSG( 1, &amp;quot;Done parsing file:  &amp;quot; + initialParametersFileName );&lt;br /&gt;
	}&lt;br /&gt;
	catch(Exception e) {&lt;br /&gt;
	    System.out.println(&amp;quot;Exception when parsing parameters file:  &amp;quot;&lt;br /&gt;
			       + initialParametersFileName);&lt;br /&gt;
	    System.out.println(&amp;quot;Is the file in the correct format?&amp;quot;);&lt;br /&gt;
	    e.printStackTrace();&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processCommandLinePars&lt;br /&gt;
    // storeParameter&lt;br /&gt;
    //&lt;br /&gt;
    //&lt;br /&gt;
    public void processCommandLinePars ( String[] args ) {&lt;br /&gt;
	int r;&lt;br /&gt;
	if( args.length &amp;gt; 0 &lt;br /&gt;
	    &amp;amp;&amp;amp; ( args[0].equals( &amp;quot;--help&amp;quot; ) || args[0].equals( &amp;quot;-h&amp;quot; ) ) ) {&lt;br /&gt;
	    printProjectHelp();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	for ( int i = 0; i &amp;lt; args.length; ++i ) {&lt;br /&gt;
	    r = storeParameter( args[i] );&lt;br /&gt;
	    if( r != 0 )  {&lt;br /&gt;
		System.out.println( &amp;quot;Error processing cmdLine par:  &amp;quot; + args[i] );&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // storeParameter&lt;br /&gt;
    // format:  parname=value&lt;br /&gt;
    // parse out parname, and find method for setParname&lt;br /&gt;
    // if not found, return -1&lt;br /&gt;
    // otherwise set the value and return 0.&lt;br /&gt;
    // to set the value, we have to get the setMethod, and its par type.&lt;br /&gt;
    // then convert the string value to the appropriate object, and&lt;br /&gt;
    // use invoke to do the setting!&lt;br /&gt;
    &lt;br /&gt;
    public int storeParameter ( String line ) {&lt;br /&gt;
	int r = 0;&lt;br /&gt;
	String pname, pvalue;&lt;br /&gt;
	StringTokenizer st = new StringTokenizer( line, &amp;quot;=;,&amp;quot; );&lt;br /&gt;
	Method setm = null;&lt;br /&gt;
	&lt;br /&gt;
	if ( ( pname = st.nextToken() ) == null ) {&lt;br /&gt;
	    System.err.printf(&amp;quot;\n** storeParameter -- couldn&#039;t find pname on &#039;%s&#039;.\n&amp;quot;,&lt;br /&gt;
			      line );&lt;br /&gt;
	    return -1;&lt;br /&gt;
	}&lt;br /&gt;
	if ( ( pvalue = st.nextToken() ) == null ) {&lt;br /&gt;
	    System.err.printf(&amp;quot;\n** storeParameter -- couldn&#039;t find value on &#039;%s&#039;.\n&amp;quot;,&lt;br /&gt;
			      line );&lt;br /&gt;
	    return -1;&lt;br /&gt;
	}&lt;br /&gt;
	pname = pname.trim();&lt;br /&gt;
	pvalue = pvalue.trim();&lt;br /&gt;
	&lt;br /&gt;
	pname = aliasToParameterName ( pname );&lt;br /&gt;
	&lt;br /&gt;
	// if this is a scheduledChange, create the change&lt;br /&gt;
	// and insert it into the changesVector&lt;br /&gt;
	if( pname.equals ( &amp;quot;sC&amp;quot; ) ) {&lt;br /&gt;
	    String changetime = pvalue;&lt;br /&gt;
	    String changepname, changepvalue;&lt;br /&gt;
	    &lt;br /&gt;
	    if ( ( changepname = st.nextToken() ) == null ) {&lt;br /&gt;
		System.out.println( &amp;quot;\n** storeParameter -- couldn&#039;t find &amp;quot;&lt;br /&gt;
				    + &amp;quot;scheduleChange pname on:  &amp;quot; + line );&lt;br /&gt;
		return -1;&lt;br /&gt;
	    }&lt;br /&gt;
	    &lt;br /&gt;
	    if ( ( changepvalue = st.nextToken() ) == null ) {&lt;br /&gt;
		System.out.println( &amp;quot;\n** storeParameter -- couldn&#039;t find &amp;quot;&lt;br /&gt;
				    + &amp;quot;scheduleChange pvalue on:  &amp;quot; + line );&lt;br /&gt;
		return -1;&lt;br /&gt;
	    }&lt;br /&gt;
	    &lt;br /&gt;
	    changepname = changepname.trim();&lt;br /&gt;
	    changepvalue = changepvalue.trim();&lt;br /&gt;
	    &lt;br /&gt;
	    changepname = aliasToParameterName ( changepname );&lt;br /&gt;
	    &lt;br /&gt;
	    ChangeObj newChange = new ChangeObj( Integer.parseInt( changetime ),&lt;br /&gt;
						 changepname, changepvalue );&lt;br /&gt;
	    &lt;br /&gt;
	    DMSG ( 1, &amp;quot;scheduledChange from command line created:  &amp;quot;&lt;br /&gt;
		   + &amp;quot;  Time:  &amp;quot; + changetime + &amp;quot;  pname:  &amp;quot;&lt;br /&gt;
		   + changepname + &amp;quot;  pvalue:  &amp;quot; + changepvalue );&lt;br /&gt;
	    changesVector.add ( newChange );&lt;br /&gt;
	    &lt;br /&gt;
	    return 0;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	setm = findSetMethodFor( pname );&lt;br /&gt;
	String ptype = getParTypeOfSetMethod( setm );&lt;br /&gt;
	&lt;br /&gt;
	try {&lt;br /&gt;
	    setm.invoke( this, new Object[] { valToObject( ptype, pvalue ) } );&lt;br /&gt;
	} catch ( Exception  e ) {&lt;br /&gt;
	    System.err.printf( &amp;quot;\n storeParameter: &#039;%s&#039;=&#039;%s&#039; invoke exception!\n&amp;quot;, &lt;br /&gt;
			       pname, pvalue );&lt;br /&gt;
	    &lt;br /&gt;
	    System.err.printf( &amp;quot;  --&amp;gt; %s\n&amp;quot;, e.toString() );&lt;br /&gt;
	    e.printStackTrace();&lt;br /&gt;
	    return -1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if( pname.equals ( &amp;quot;initialParametersFileName&amp;quot; ) ) {&lt;br /&gt;
	    DMSG( 1, &amp;quot;Processing initial parameters file:  &amp;quot; + pvalue );&lt;br /&gt;
	    parseParametersFile();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return r;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // returns the long parameter name if the parameter passed in is&lt;br /&gt;
    // an alias.  if it is not an alias, the name sent to it is returned.&lt;br /&gt;
    public String aliasToParameterName ( String alias ) {&lt;br /&gt;
	// check to see if &amp;quot;alias&amp;quot; is an alias in the parametersMap&lt;br /&gt;
	// if it is then &amp;quot;alias&amp;quot; is a valid alias, so set &amp;quot;alias&amp;quot; to the &lt;br /&gt;
	// actual parameter name that is in the map&lt;br /&gt;
	if( parametersMap.containsKey( alias ) ) {&lt;br /&gt;
	    DMSG( 1, &amp;quot;Converting alias &amp;quot; + alias + &amp;quot; to &amp;quot; + parametersMap.get( alias ) );&lt;br /&gt;
	    alias = (String) parametersMap.get( alias );&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return alias;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // getParTypeOfSetMethod&lt;br /&gt;
    // get type of setPar method parameter&lt;br /&gt;
    public String getParTypeOfSetMethod ( Method m ) {&lt;br /&gt;
	Class[] parTypes = m.getParameterTypes();&lt;br /&gt;
	String s = parTypes[0].getName();&lt;br /&gt;
	return s;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // findGetMethodFor&lt;br /&gt;
    // find get&amp;lt;ParName&amp;gt; method for specified parameter name &lt;br /&gt;
    protected Method findGetMethodFor( String varname ) {&lt;br /&gt;
	String methodname = new String( &amp;quot;get&amp;quot; + capitalize( varname ) );&lt;br /&gt;
	Class c = getClass();&lt;br /&gt;
	Method[] methods = c.getMethods();&lt;br /&gt;
	Method getmethod = null;&lt;br /&gt;
	&lt;br /&gt;
	for ( int j = 0; j &amp;lt; methods.length; j++ ) {&lt;br /&gt;
	    if ( methods[j].getName().equals( methodname ) ) {&lt;br /&gt;
		getmethod = methods[j];&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	if ( getmethod == null ) {&lt;br /&gt;
	    System.err.printf( &amp;quot;\n** findGetMethodFor -- couldn&#039;t find &#039;%s&#039;\n&amp;quot;,&lt;br /&gt;
			       methodname );&lt;br /&gt;
	    return getmethod;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return getmethod;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // findSetMethodFor&lt;br /&gt;
    // find set&amp;lt;ParName&amp;gt; method for specified parameter name &lt;br /&gt;
    public Method findSetMethodFor ( String pname ) {&lt;br /&gt;
	Class c = this.getClass();&lt;br /&gt;
	Method[] methods = c.getMethods();&lt;br /&gt;
	int nf = methods.length;&lt;br /&gt;
	String setmethodname = &amp;quot;set&amp;quot; + capitalize( pname );&lt;br /&gt;
	String mname;&lt;br /&gt;
	Method method = null;&lt;br /&gt;
	for ( int i = 0; i &amp;lt; nf; ++i ) {&lt;br /&gt;
	    mname = methods[i].getName();&lt;br /&gt;
	    if ( mname.equals( setmethodname ) ) {&lt;br /&gt;
		method = methods[i];&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	if ( method == null ) {&lt;br /&gt;
	    System.err.printf( &amp;quot;\n** findSetMethodFor -- couldn&#039;t fine &#039;%s&#039;\n&amp;quot;,&lt;br /&gt;
			       setmethodname );&lt;br /&gt;
	    return method;&lt;br /&gt;
	}&lt;br /&gt;
	return method;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // valToObject&lt;br /&gt;
    // return value stored in object of appropriate type&lt;br /&gt;
    private Object valToObject( String type, String val ) {&lt;br /&gt;
	if ( type.equals( &amp;quot;int&amp;quot; ) ) {&lt;br /&gt;
	    return Integer.valueOf( val );&lt;br /&gt;
	} else if ( type.equals( &amp;quot;double&amp;quot; ) ) {&lt;br /&gt;
	    return Double.valueOf( val );&lt;br /&gt;
	} else if ( type.equals( &amp;quot;float&amp;quot; ) ) {&lt;br /&gt;
	    return Float.valueOf( val );&lt;br /&gt;
	} else if ( type.equals( &amp;quot;long&amp;quot; ) ) {&lt;br /&gt;
	    return Long.valueOf(val);&lt;br /&gt;
	} else if ( type.equals( &amp;quot;boolean&amp;quot; ) ) {&lt;br /&gt;
	    return Boolean.valueOf(val);&lt;br /&gt;
	} else if ( type.equals( &amp;quot;java.lang.String&amp;quot; ) ) {&lt;br /&gt;
	    return val;&lt;br /&gt;
	} else {&lt;br /&gt;
	    throw new IllegalArgumentException( &amp;quot;illegal type&amp;quot; );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String skipCommentLines ( BufferedReader inFile ) {&lt;br /&gt;
	String line;&lt;br /&gt;
	while ( ( line = IOUtils.readBRLine ( inFile ) ) != null ) {&lt;br /&gt;
	    if ( line.charAt(0) != &#039;#&#039; )&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
	return line;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // applyAnyStoredChanges&lt;br /&gt;
    // look through all of the changes, if any have time of this time &lt;br /&gt;
    // step execute the change&lt;br /&gt;
    public void applyAnyStoredChanges () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 ) {&lt;br /&gt;
	    System.out.println( &amp;quot;applyAnyStoredChanges called at time step: &amp;quot; &lt;br /&gt;
				+ getTickCount() );&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	for( int i = 0; i &amp;lt; changesVector.size(); i++ ) {&lt;br /&gt;
	    ChangeObj tmpObj = (ChangeObj) changesVector.get( i );&lt;br /&gt;
	    if( tmpObj.time == getTickCount() ) {&lt;br /&gt;
		if ( rDebug &amp;gt; 0 ) {&lt;br /&gt;
		    System.out.println( &amp;quot;applyAnyStoredChanges():  Changing &amp;quot; &lt;br /&gt;
					+ tmpObj.varname + &amp;quot; to &amp;quot; +tmpObj.value );&lt;br /&gt;
		}&lt;br /&gt;
		set( tmpObj.varname, tmpObj.value );&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // utility methods for accessing parts of model&lt;br /&gt;
    &lt;br /&gt;
    private void setObjectParameter( Object inObject, String varname, String value ) {&lt;br /&gt;
	String methodname = new String( &amp;quot;set&amp;quot; + capitalize( varname ) );&lt;br /&gt;
	Class c = inObject.getClass();&lt;br /&gt;
	Method[] methods = c.getMethods();&lt;br /&gt;
	Method setmethod = null;&lt;br /&gt;
	&lt;br /&gt;
	for ( int j = 0; j &amp;lt; methods.length; j++ ) {&lt;br /&gt;
	    if ( methods[j].getName().equals( methodname ) ) {&lt;br /&gt;
		setmethod = methods[j];&lt;br /&gt;
		break;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	if(setmethod != null) {&lt;br /&gt;
	    try {&lt;br /&gt;
		Class[] parameterTypes = setmethod.getParameterTypes();&lt;br /&gt;
		if( parameterTypes[0].getName().equals( &amp;quot;int&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;int parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( inObject, new Object[] { Integer.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if( parameterTypes[0].getName().equals( &amp;quot;long&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;long parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( inObject, new Object[] { Long.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if( parameterTypes[0].getName().equals( &amp;quot;double&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;double parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( inObject, new Object[] { Double.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if( parameterTypes[0].getName().equals( &amp;quot;float&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;float parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( inObject, new Object[] { Float.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if( parameterTypes[0].getName().equals( &amp;quot;java.lang.String&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;String parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( inObject, new Object[] { value } );&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
		    System.out.println( &amp;quot;COULD NOT DETERMINE PARAMETER TYPE&amp;quot; );&lt;br /&gt;
		}&lt;br /&gt;
		DMSG( 1, &amp;quot;setObjectParameter():  &amp;quot; + varname + &amp;quot; changed to &amp;quot; + value );&lt;br /&gt;
	    } catch( Exception e ) { e.printStackTrace(); }&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    System.out.println( &amp;quot;COULD NOT FIND SET METHOD FOR:  &amp;quot; + varname );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private void processChange(Element c) {&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	DMSG(3, &amp;quot;Processing A Change&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	NodeList tmpList = c.getElementsByTagName(&amp;quot;*&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	ChangeObj newChange = new ChangeObj(0,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	for(int i = 0; i &amp;lt; tmpList.getLength(); i++)  {&lt;br /&gt;
	    Element tmpElement = (Element)tmpList.item(i);&lt;br /&gt;
	    // System.out.println(&amp;quot;tmpElement.getTagName(): &amp;quot; + tmpElement.getTagName());&lt;br /&gt;
	    if(tmpElement.getTagName().equals(&amp;quot;time&amp;quot;)) {&lt;br /&gt;
		newChange.time = Integer.parseInt(tmpElement.getChildNodes().item(0).getNodeValue());&lt;br /&gt;
	    }&lt;br /&gt;
	    else {&lt;br /&gt;
		newChange.varname = tmpElement.getTagName();&lt;br /&gt;
		newChange.value = tmpElement.getChildNodes().item(0).getNodeValue();&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	changesVector.add(newChange);&lt;br /&gt;
&lt;br /&gt;
	DMSG(3,&amp;quot;Done processing a Change&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private void processChangeList( NodeList c ) {&lt;br /&gt;
	&lt;br /&gt;
	DMSG(3, &amp;quot;Processing &amp;quot; + c.getLength() + &amp;quot; changes ...&amp;quot; );&lt;br /&gt;
	for( int i = 0; i &amp;lt; c.getLength(); i++ )&lt;br /&gt;
	    processChange( (Element) c.item( i ) );&lt;br /&gt;
	&lt;br /&gt;
	for( int i = 0; i &amp;lt; changesVector.size(); i++ ) {&lt;br /&gt;
	    ChangeObj tmpObj = (ChangeObj) changesVector.get( i );&lt;br /&gt;
	    DMSG( 3, &amp;quot;Time:  &amp;quot; + tmpObj.time + &amp;quot;  VarName:  &amp;quot; &lt;br /&gt;
		  + tmpObj.varname + &amp;quot;  Value:  &amp;quot; + tmpObj.value );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private void set( String varname, String value ) {&lt;br /&gt;
	&lt;br /&gt;
	// first convert varname to the alias, if it is an alias&lt;br /&gt;
	varname = aliasToParameterName ( varname );&lt;br /&gt;
	&lt;br /&gt;
	Method setmethod = findSetMethodFor ( varname );&lt;br /&gt;
	&lt;br /&gt;
	if( setmethod != null ) {&lt;br /&gt;
	    try {&lt;br /&gt;
		Class[] parameterTypes = setmethod.getParameterTypes();&lt;br /&gt;
		if ( parameterTypes[0].getName().equals( &amp;quot;int&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;int parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( this, new Object[] { Integer.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if ( parameterTypes[0].getName().equals( &amp;quot;long&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;long parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( this, new Object[] { Long.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if( parameterTypes[0].getName().equals( &amp;quot;float&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;float parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( this, new Object[] { Float.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if ( parameterTypes[0].getName().equals( &amp;quot;double&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;double parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( this, new Object[] { Double.valueOf( value ) } );&lt;br /&gt;
		}&lt;br /&gt;
		else if ( parameterTypes[0].getName().equals( &amp;quot;java.lang.String&amp;quot; ) ) {&lt;br /&gt;
		    DMSG( 3, &amp;quot;String parameter type&amp;quot; );&lt;br /&gt;
		    setmethod.invoke( this, new Object[] { value } );&lt;br /&gt;
		}&lt;br /&gt;
		else {&lt;br /&gt;
		    System.out.println( &amp;quot;COULD NOT DETERMINE PARAMETER TYPE&amp;quot; );&lt;br /&gt;
		}&lt;br /&gt;
		DMSG( 1, &amp;quot;set():  &amp;quot; + varname + &amp;quot; changed to &amp;quot; + value );&lt;br /&gt;
	    } catch( Exception e ) { e.printStackTrace(); }&lt;br /&gt;
	}&lt;br /&gt;
	else {&lt;br /&gt;
	    System.out.println( &amp;quot;COULD NOT FIND SET METHOD FOR:  &amp;quot; + varname );&lt;br /&gt;
	    System.out.println( &amp;quot;Is the parameter name correct?&amp;quot; );&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    // loadChangeParameters&lt;br /&gt;
    // we expect to see&lt;br /&gt;
    //   @changeParameters&lt;br /&gt;
    //   step=&amp;lt;timeStep&amp;gt;&lt;br /&gt;
    //   parName=parValue&lt;br /&gt;
    //   ...&lt;br /&gt;
    //   @endChangeParameters&lt;br /&gt;
    //   &amp;lt;timeStep&amp;gt; is time step changes are to occur.&lt;br /&gt;
    //   store in changeSteps[numberOfChanges]&lt;br /&gt;
    //   store number of parameters to change in changeIDs[numberOfChanges]&lt;br /&gt;
    //   increment 	 numberOfChanges&lt;br /&gt;
    // Return 0 if ok, 1 if not.  next line will be after @endChangeParameters&lt;br /&gt;
    public int loadChangeParameters( BufferedReader inFile ) {&lt;br /&gt;
	ArrayList lines = new ArrayList(16);&lt;br /&gt;
	String line, ends = &amp;quot;@endChangeParameters&amp;quot;;&lt;br /&gt;
	int r,  step = 0, numPars = 0, done = 0;&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;\n\n*** loadChangeParameters \n\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	// first get the step= line, and the time and ID values&lt;br /&gt;
	line = skipCommentLines( inFile );&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf(&amp;quot;0: %s\n&amp;quot;, line );&lt;br /&gt;
	&lt;br /&gt;
	/* was&lt;br /&gt;
	   r = Format.sscanf( line, &amp;quot;step=%i&amp;quot;, p.add(iV) );&lt;br /&gt;
	   step = iV.intValue();&lt;br /&gt;
	*/&lt;br /&gt;
	Scanner scanner = new Scanner( line );&lt;br /&gt;
	scanner.findInLine( &amp;quot;step=(\\d+)&amp;quot;);&lt;br /&gt;
	MatchResult result = scanner.match();&lt;br /&gt;
	try { step = Integer.parseInt( result.group() ); }&lt;br /&gt;
	catch(NumberFormatException e) { }&lt;br /&gt;
	&lt;br /&gt;
	// get lines into a bunch of strings, add to list of these sets of lines.&lt;br /&gt;
	while ( done == 0 ) {&lt;br /&gt;
	    line = skipCommentLines( inFile );&lt;br /&gt;
	    if ( line.equals( ends ) )&lt;br /&gt;
		done = 1;&lt;br /&gt;
	    else {&lt;br /&gt;
		// *** It would be nice to check these here...&lt;br /&gt;
		lines.add( line );&lt;br /&gt;
		++numPars;&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	changeSpecs.add( lines );&lt;br /&gt;
	&lt;br /&gt;
	if ( numPars == 0 ) {  // oops!&lt;br /&gt;
	    System.err.printf( &amp;quot;\n*** loadChangeParameters found 0 changes! Last line=&#039;%s&#039;\n&amp;quot;,&lt;br /&gt;
			       line );&lt;br /&gt;
	    return -1;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	// store time and id in next place in arrays.&lt;br /&gt;
	changeSteps[numberOfChanges] = step;&lt;br /&gt;
	changeIDs[numberOfChanges] = 0 - numPars;&lt;br /&gt;
	++numberOfChanges;&lt;br /&gt;
	&lt;br /&gt;
	for ( int c = 0; c &amp;lt; numberOfChanges; ++c ) {&lt;br /&gt;
	    if ( changeIDs[c] &amp;gt;= 0 )&lt;br /&gt;
		continue;&lt;br /&gt;
	    lines = (ArrayList) changeSpecs.get(c);&lt;br /&gt;
	    System.out.printf( &amp;quot;Change %d at t=%d, ID=%d:\n&amp;quot;, &lt;br /&gt;
			       c, changeSteps[c], changeIDs[c] );&lt;br /&gt;
	    for ( int i = 0; i &amp;lt; numPars; ++i ) {&lt;br /&gt;
		System.out.printf(&amp;quot;%d: %s\n&amp;quot;, i+1, (String)lines.get(i) );&lt;br /&gt;
	    }&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	return 0;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void DMSG(int debugLevel, String debugStr) {&lt;br /&gt;
	if(rDebug &amp;gt;= debugLevel) {&lt;br /&gt;
	    System.out.println(&amp;quot;debug:\t&amp;quot; + debugStr);&lt;br /&gt;
	}&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with -help parameter&lt;br /&gt;
    //&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// this is declared in the class that &#039;extends&#039; this one&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // include comments to be written just after the list of parameter &lt;br /&gt;
    // values and just before the step-by-step data lines.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	// this is declared in the class that &#039;extends&#039; this one&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
///////////////////////////////////////////////////////////////////////////&lt;br /&gt;
// auxilliary classes for processing changes&lt;br /&gt;
//&lt;br /&gt;
//&lt;br /&gt;
&lt;br /&gt;
class ChangeObj {&lt;br /&gt;
    public ChangeObj() {}&lt;br /&gt;
    public ChangeObj(int in_time, String in_varname, String in_value) {&lt;br /&gt;
	time = in_time;&lt;br /&gt;
	varname = in_varname;&lt;br /&gt;
	value = in_value;&lt;br /&gt;
    }&lt;br /&gt;
    public int time;&lt;br /&gt;
    public String varname;&lt;br /&gt;
    public String value;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class ACChangeObj {&lt;br /&gt;
    public ACChangeObj() {}&lt;br /&gt;
    public ACChangeObj(int in_time, int in_id, String in_varname, String in_value) {&lt;br /&gt;
	time = in_time;&lt;br /&gt;
	id = in_id;&lt;br /&gt;
	varname = in_varname;&lt;br /&gt;
	value = in_value;&lt;br /&gt;
    }&lt;br /&gt;
    public int time;&lt;br /&gt;
    public int id;&lt;br /&gt;
    public String varname;&lt;br /&gt;
    public String value;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CoopNetBlue.java&amp;diff=3455</id>
		<title>CoopNetBlue.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CoopNetBlue.java&amp;diff=3455"/>
		<updated>2006-06-16T04:00:04Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * CoopNetBlue.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 14, 2006 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class CoopNetBlue extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList agentList = new ArrayList (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public GameMaster gm;       // Runs the games&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
    public int evolveUpdateInterval;    // The evolution of the net&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of CoopNetBlue */&lt;br /&gt;
    public CoopNetBlue() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nUI&amp;quot;, &amp;quot;evolveUpdateInterval&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;,  &lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {&lt;br /&gt;
	numAgents = i; &lt;br /&gt;
    }&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
&lt;br /&gt;
    public int getEvolveUpdateInterval() {return evolveUpdateInterval;}&lt;br /&gt;
    public void setEvolveUpdateInterval(int i) {evolveUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	gm = new GameMaster(agentList);&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	schedule.scheduleActionAtInterval(evolveUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    gm.evolveAgents();         // evolve agents    &lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    // Current has nodes re-draw themselves based on Utility&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
	int maxUtility = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    if (node.getUtility() &amp;gt; maxUtility)&lt;br /&gt;
		maxUtility = node.getUtility();&lt;br /&gt;
        }&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.setNodeColorFromUtility(maxUtility);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1000;&lt;br /&gt;
	pajekUpdateInterval    = 5000;&lt;br /&gt;
	evolveUpdateInterval   = 10;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	gm.playAll();&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgUtility()&lt;br /&gt;
    public double calcAvgUtility(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getUtility();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        CoopNetBlue model = new CoopNetBlue ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=CoopNetBlue.java&amp;diff=3453</id>
		<title>CoopNetBlue.java</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=CoopNetBlue.java&amp;diff=3453"/>
		<updated>2006-06-16T03:59:35Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Base Model]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * CoopNetBlue.java&lt;br /&gt;
 *&lt;br /&gt;
 * Created on January 22, 2005, 6:11 PM&lt;br /&gt;
 * Modified June 14, 2006 by Jack&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
package CoopNetBlue;&lt;br /&gt;
import java.awt.Color;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.List;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.engine.BasicAction;&lt;br /&gt;
import uchicago.src.sim.engine.Schedule;&lt;br /&gt;
//import uchicago.src.sim.engine.SimModelImpl;&lt;br /&gt;
//import uchicago.src.sim.gui.DisplaySurface;&lt;br /&gt;
//import uchicago.src.sim.gui.Network2DDisplay;&lt;br /&gt;
import uchicago.src.sim.gui.OvalNetworkItem;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkFactory;&lt;br /&gt;
//import uchicago.src.sim.network.NetworkRecorder;&lt;br /&gt;
//import uchicago.src.sim.network.Node;&lt;br /&gt;
//import uchicago.src.sim.util.Random;&lt;br /&gt;
import uchicago.src.sim.util.SimUtilities;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableNode;&lt;br /&gt;
//import uchicago.src.sim.network.DefaultDrawableEdge;&lt;br /&gt;
//import uchicago.src.sim.gui.CircularGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.KamadaGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.gui.AbstractGraphLayout;&lt;br /&gt;
//import uchicago.src.sim.space.Object2DGrid;&lt;br /&gt;
//import uchicago.src.sim.gui.Object2DDisplay;&lt;br /&gt;
import uchicago.src.sim.util.*;&lt;br /&gt;
&lt;br /&gt;
import uchicago.src.sim.network.NetUtilities;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 *&lt;br /&gt;
 * @author Jack Waddell&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
public class CoopNetBlue extends ModelParameters{&lt;br /&gt;
    &lt;br /&gt;
    // model variables&lt;br /&gt;
    public int numAgents = 16;&lt;br /&gt;
    public ArrayList agentList = new ArrayList (numAgents);&lt;br /&gt;
    public int worldXSize = 400;&lt;br /&gt;
    public int worldYSize = 400;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    public Schedule schedule;   // Schedules Events&lt;br /&gt;
    public GameMaster gm;       // Runs the games&lt;br /&gt;
    &lt;br /&gt;
    // The P parameter for regular lattice -&amp;gt; small world rewiring   &lt;br /&gt;
    // Also used as the probability in the random network&lt;br /&gt;
    public double reconnectProb;&lt;br /&gt;
&lt;br /&gt;
    // the connection radius of the regular lattice&lt;br /&gt;
    public int    connectRadius;&lt;br /&gt;
&lt;br /&gt;
    // selects which network type to use in Network.java&lt;br /&gt;
    public int    netType;&lt;br /&gt;
&lt;br /&gt;
    // Stores how frequently, in units of time steps, to update...&lt;br /&gt;
    public int updateInterval;          // The report file&lt;br /&gt;
    public int pajekUpdateInterval;     // The pajek files&lt;br /&gt;
    public int evolveUpdateInterval;    // The evolution of the net&lt;br /&gt;
&lt;br /&gt;
    Network net;   // The network class&lt;br /&gt;
    &lt;br /&gt;
    // The following class performs calculations on the network&lt;br /&gt;
    NetUtilities netCalculator = new NetUtilities();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /** Creates a new instance of CoopNetBlue */&lt;br /&gt;
    public CoopNetBlue() {&lt;br /&gt;
    }&lt;br /&gt;
	&lt;br /&gt;
    /////////////////////////////////////////////////&lt;br /&gt;
    // begin&lt;br /&gt;
    // builds model-required elements&lt;br /&gt;
    public void begin () {&lt;br /&gt;
        buildModel ();&lt;br /&gt;
        buildSchedule ();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    ///////////////////////////////////////////////////////&lt;br /&gt;
    // addModelSpecificParameters&lt;br /&gt;
    // Maps the input parameters.&lt;br /&gt;
    public void addModelSpecificParameters () {&lt;br /&gt;
	parametersMap.put( &amp;quot;size&amp;quot;, &amp;quot;numAgents&amp;quot;);	&lt;br /&gt;
	parametersMap.put( &amp;quot;ui&amp;quot;, &amp;quot;updateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;rP&amp;quot;, &amp;quot;reconnectProb&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;cR&amp;quot;, &amp;quot;connectRadius&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nT&amp;quot;, &amp;quot;netType&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;pUI&amp;quot;, &amp;quot;pajekUpdateInterval&amp;quot;);&lt;br /&gt;
	parametersMap.put( &amp;quot;nUI&amp;quot;, &amp;quot;evolveUpdateInterval&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////&lt;br /&gt;
    // getInitParam&lt;br /&gt;
    // Controls what appears the the GUI parameter panel&lt;br /&gt;
    public String[] getInitParam () {&lt;br /&gt;
	String[] params = { &amp;quot;numAgents&amp;quot;, &amp;quot;connectRadius&amp;quot;, &lt;br /&gt;
			    &amp;quot;reconnectProb&amp;quot;, &amp;quot;netType&amp;quot;,  &lt;br /&gt;
			    // these are from the super class:&lt;br /&gt;
			    &amp;quot;rDebug&amp;quot;, &amp;quot;seed&amp;quot;};&lt;br /&gt;
	return params;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // getters and setters&lt;br /&gt;
    // ********************   Note   *************************&lt;br /&gt;
    // Specific format required if using inputted parameters&lt;br /&gt;
    //  (either through batch or gui)&lt;br /&gt;
    public int  getWorldXSize () {return worldXSize;}&lt;br /&gt;
    public void setWorldXSize (int size) {worldXSize = size;}&lt;br /&gt;
    public int  getWorldYSize () {return worldYSize;}&lt;br /&gt;
    public void setWorldYSize (int size) {worldYSize = size;}&lt;br /&gt;
   &lt;br /&gt;
    public int  getNumAgents() {return numAgents;}&lt;br /&gt;
    public void setNumAgents(int i) {&lt;br /&gt;
	numAgents = i; &lt;br /&gt;
    }&lt;br /&gt;
    public double getReconnectProb() {return reconnectProb;}&lt;br /&gt;
    public void   setReconnectProb(double i) {reconnectProb = i;}&lt;br /&gt;
    public int  getConnectRadius() {return connectRadius;}&lt;br /&gt;
    public void setConnectRadius(int i) {connectRadius = i;}&lt;br /&gt;
&lt;br /&gt;
    public void setNetType(int i) {netType = i;}&lt;br /&gt;
    public int  getNetType() {return netType;}&lt;br /&gt;
&lt;br /&gt;
    public int    getUpdateInterval() {return updateInterval;}&lt;br /&gt;
    public void  setUpdateInterval(int i) {updateInterval = i;}&lt;br /&gt;
    public int    getPajekUpdateInterval() {return pajekUpdateInterval;}&lt;br /&gt;
    public void  setPajekUpdateInterval(int i) {pajekUpdateInterval = i;}&lt;br /&gt;
&lt;br /&gt;
    public int getEvolveUpdateInterval() {return evolveUpdateInterval;}&lt;br /&gt;
    public void setEvolveUpdateInterval(int i) {evolveUpdateInterval = i;}&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildModel&lt;br /&gt;
    // Does what it says&lt;br /&gt;
    public void buildModel(){&lt;br /&gt;
	if(rDebug &amp;gt; 0)&lt;br /&gt;
	    System.out.printf(&amp;quot;Build Model Begin\n&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
	// CALL FIRST -- defined in super class -- it starts RNG, etc&lt;br /&gt;
	buildModelStart();&lt;br /&gt;
	&lt;br /&gt;
	// setup the network class&lt;br /&gt;
        net = new Network(numAgents, connectRadius, reconnectProb);&lt;br /&gt;
        net.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	CustomNode.setModel(this);&lt;br /&gt;
&lt;br /&gt;
	// have the network class build the network&lt;br /&gt;
        net.buildAdjacencyMatrix(netType);  // first build the adjacency matrix&lt;br /&gt;
&lt;br /&gt;
	net.buildAgentList();		    // then the agent list&lt;br /&gt;
        agentList = net.getAgentList();&lt;br /&gt;
	&lt;br /&gt;
	// setup the gamemaster&lt;br /&gt;
	gm = new GameMaster(agentList);&lt;br /&gt;
&lt;br /&gt;
	// prepare pajek file&lt;br /&gt;
       	net.startPajekFile(0);&lt;br /&gt;
	&lt;br /&gt;
        System.out.printf(&amp;quot;Build Model End\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////&lt;br /&gt;
    // buildSchedule&lt;br /&gt;
    // Sets what is to happen, when.&lt;br /&gt;
    public void buildSchedule () {&lt;br /&gt;
&lt;br /&gt;
	// schedule the current BatchModel&#039;s step() function&lt;br /&gt;
	// to execute every time step starting with time  step 0&lt;br /&gt;
	schedule.scheduleActionBeginning( 0, this, &amp;quot;step&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
	// Schedule to stop at a particular time, StopT.  Rem out&lt;br /&gt;
	// to run indefinitely&lt;br /&gt;
	schedule.scheduleActionAt(getStopT(), this, &amp;quot;processEndOfRun&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Only run every updateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(updateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    System.gc();         // garbage collect&lt;br /&gt;
		    stepReport();        // write step report&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	schedule.scheduleActionAtInterval(evolveUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    gm.evolveAgents();         // evolve agents    &lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
&lt;br /&gt;
	// Only run every pajekUpdateInterval steps&lt;br /&gt;
	schedule.scheduleActionAtInterval(pajekUpdateInterval, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    nextPajekNetwork();  // write pajek file and open new one&lt;br /&gt;
		}&lt;br /&gt;
      }, Schedule.LAST);&lt;br /&gt;
					  &lt;br /&gt;
	// Execute at step 1 only&lt;br /&gt;
	schedule.scheduleActionAt(1, new BasicAction() {&lt;br /&gt;
		public void execute() {&lt;br /&gt;
		    stepReport();&lt;br /&gt;
		    nextPajekNetwork();&lt;br /&gt;
		}&lt;br /&gt;
	    }, Schedule.LAST);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // printProjectHelp&lt;br /&gt;
    // this could be filled in with some help to get from running with &lt;br /&gt;
    // -help parameter&lt;br /&gt;
    public void printProjectHelp() {&lt;br /&gt;
	// print project help&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n%s -- \n&amp;quot;, getName() );&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n **** Add more info here!! **** \n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	System.out.printf( &amp;quot;\n&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	printParametersMap();&lt;br /&gt;
	&lt;br /&gt;
	System.exit( 0 );&lt;br /&gt;
	&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    ////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepNodes&lt;br /&gt;
    // Steps each node.&lt;br /&gt;
    // Current has nodes re-draw themselves based on Utility&lt;br /&gt;
    public void stepNodes(){&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
	int maxUtility = 0;&lt;br /&gt;
        for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    if (node.getUtility() &amp;gt; maxUtility)&lt;br /&gt;
		maxUtility = node.getUtility();&lt;br /&gt;
        }&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
            node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    node.setNodeColorFromUtility(maxUtility);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    //////////////////////////////////////////////////////////////&lt;br /&gt;
    // Setup&lt;br /&gt;
    // Prepares the model, or resets it after the reset button is pressed&lt;br /&gt;
    // in GUI model&lt;br /&gt;
    public void setup () {&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )&lt;br /&gt;
	    System.out.printf( &amp;quot;&amp;lt;== Model setup() done.\n&amp;quot; );&lt;br /&gt;
	// Clean up previous instances&lt;br /&gt;
	schedule = null;&lt;br /&gt;
	System.gc ();&lt;br /&gt;
	&lt;br /&gt;
	// Set default values&lt;br /&gt;
	// These are overwritten by inputted values, if any&lt;br /&gt;
	numAgents              = 64;&lt;br /&gt;
	updateInterval         = 1000;&lt;br /&gt;
	pajekUpdateInterval    = 5000;&lt;br /&gt;
	evolveUpdateInterval   = 10;&lt;br /&gt;
        worldXSize             = 400;&lt;br /&gt;
        worldYSize             = 400;&lt;br /&gt;
&lt;br /&gt;
	netType = 0;&lt;br /&gt;
	connectRadius = 2;&lt;br /&gt;
	reconnectProb = 0.1;&lt;br /&gt;
	&lt;br /&gt;
        CustomNode.resetNextID();&lt;br /&gt;
        agentList = new ArrayList (numAgents);&lt;br /&gt;
&lt;br /&gt;
        super.setup();	// Reads in input values&lt;br /&gt;
	schedule = new Schedule (1);&lt;br /&gt;
	&lt;br /&gt;
	// some post-load finishing touches&lt;br /&gt;
        startReportFile();&lt;br /&gt;
	&lt;br /&gt;
	// you probably don&#039;t want to remove any of the following&lt;br /&gt;
	// calls to process parameter changes and write the&lt;br /&gt;
	// initial state to the report file.&lt;br /&gt;
	// NB -&amp;gt; you might remove/add more agentChange processing&lt;br /&gt;
        applyAnyStoredChanges();&lt;br /&gt;
        //stepReport();&lt;br /&gt;
        //getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // step&lt;br /&gt;
    // governs what happens at each step&lt;br /&gt;
    public void step(){&lt;br /&gt;
	gm.playAll();&lt;br /&gt;
	stepNodes();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // addAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Adds a new agent to the agent list&lt;br /&gt;
    public void addAgent(CustomNode agent){&lt;br /&gt;
	agentList.add(agent);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////&lt;br /&gt;
    // delAgent&lt;br /&gt;
    // Input: CustomNode agent&lt;br /&gt;
    // Output: none&lt;br /&gt;
    // Deletes an agent from the agent list&lt;br /&gt;
    public void delAgent(CustomNode agent){&lt;br /&gt;
	agentList.remove(agentList.indexOf(agent));&lt;br /&gt;
	System.gc();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // calcAvgUtility()&lt;br /&gt;
    public double calcAvgUtility(){&lt;br /&gt;
	double sum = 0;&lt;br /&gt;
	for(int i = 0; i &amp;lt; numAgents; i++){&lt;br /&gt;
	    CustomNode node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    sum += (double) node.getUtility();&lt;br /&gt;
	}&lt;br /&gt;
	return sum/(double) numAgents;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    ///////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // stepReport&lt;br /&gt;
    // each step write out:&lt;br /&gt;
    //   time  expectivity&lt;br /&gt;
    //&lt;br /&gt;
    // Note: update the writeHeaderCommentsToReportFile() to print&lt;br /&gt;
    //       lines of text describing the data written to the report file.&lt;br /&gt;
    &lt;br /&gt;
    public void stepReport () {&lt;br /&gt;
	String s;&lt;br /&gt;
	s = String.format(&amp;quot;%f&amp;quot;,&lt;br /&gt;
			  schedule.getCurrentTimeDouble());&lt;br /&gt;
&lt;br /&gt;
	//writeLineToReportFile ( &amp;quot;&amp;lt;stepreport&amp;gt;&amp;quot; + s + &amp;quot;&amp;lt;/stepreport&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToPlaintextReportFile( s );&lt;br /&gt;
	// flush the buffers so the data is not lost in a &amp;quot;crash&amp;quot;&lt;br /&gt;
	//getReportFile().flush();&lt;br /&gt;
	getPlaintextReportFile().flush();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // writeHeaderCommentsToReportFile&lt;br /&gt;
    // customize to match what you are writing to the report files in &lt;br /&gt;
    // stepReport.&lt;br /&gt;
    &lt;br /&gt;
    public void writeHeaderCommentsToReportFile () {&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;comment&amp;gt;&amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;                        &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;  time    expectivity   &amp;quot; );&lt;br /&gt;
	writeLineToReportFile( &amp;quot;&amp;lt;/comment&amp;gt;&amp;quot; );&lt;br /&gt;
	&lt;br /&gt;
	writeLineToPlaintextReportFile( &amp;quot; #time&amp;quot; );&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public Schedule getSchedule () {&lt;br /&gt;
        return schedule;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public String getName () {&lt;br /&gt;
        return &amp;quot;Network&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public ArrayList&amp;lt;CustomNode&amp;gt; getAgentList() {return agentList;}&lt;br /&gt;
    &lt;br /&gt;
    public static void main (String[] args) {&lt;br /&gt;
        uchicago.src.sim.engine.SimInit init = new uchicago.src.sim.engine.SimInit ();&lt;br /&gt;
        CoopNetBlue model = new CoopNetBlue ();&lt;br /&gt;
        init.loadModel (model, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // The following are some debugging methods&lt;br /&gt;
    public static void printVector(double[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%f &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static void printVector(int[] vector){&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        for(int i = 0; i &amp;lt; vector.length; i++){&lt;br /&gt;
            System.out.printf(&amp;quot;%d &amp;quot;, vector[i]);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public void printAgentList(){&lt;br /&gt;
        System.out.printf(&amp;quot;Printing agentList, size = %d\n&amp;quot;, agentList.size());&lt;br /&gt;
        CustomNode node;&lt;br /&gt;
        CustomNode inode;&lt;br /&gt;
        for(int i = 0; i &amp;lt; (agentList.size()); i++){&lt;br /&gt;
	    node = (CustomNode) agentList.get(i);&lt;br /&gt;
	    ArrayList &amp;lt;CustomNode&amp;gt; outNodes = node.getToNodes();&lt;br /&gt;
	    System.out.printf(&amp;quot;Node %d points to (%d objects): &amp;quot;, node.getID(),&lt;br /&gt;
			      outNodes.size());&lt;br /&gt;
	    for(int j = 0; j &amp;lt; (outNodes.size()); j++){&lt;br /&gt;
		inode = (CustomNode) outNodes.get(j);&lt;br /&gt;
		System.out.printf(&amp;quot; %d &amp;quot;, inode.getID());&lt;br /&gt;
	    }&lt;br /&gt;
	    System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        System.out.printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /////////////////////////////////////////////////////////&lt;br /&gt;
    // nextPajekNetwork&lt;br /&gt;
    // closes the current pajek file and opens the new one.&lt;br /&gt;
    public void nextPajekNetwork(){&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	net.startPajekFile((int) schedule.getCurrentTime()/pajekUpdateInterval + 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    /////////////////////////////////////////////////////////////////////&lt;br /&gt;
    // processEndOfRun&lt;br /&gt;
    // ends process&lt;br /&gt;
    public void processEndOfRun ( ) {&lt;br /&gt;
	long finalStep = (long) schedule.getCurrentTime();&lt;br /&gt;
	if ( rDebug &amp;gt; 0 )  &lt;br /&gt;
	    System.out.printf(&amp;quot;\n\n===== Model processEndOfRun =====\n\n&amp;quot; );&lt;br /&gt;
	applyAnyStoredChanges();&lt;br /&gt;
	stepReport();&lt;br /&gt;
	endReportFile(finalStep);&lt;br /&gt;
	net.writePajekNetwork(agentList);&lt;br /&gt;
	net.endPajekFile();&lt;br /&gt;
	this.fireStopSim();&lt;br /&gt;
    }   &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
	<entry>
		<id>https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3433</id>
		<title>WikiPeerCode</title>
		<link rel="alternate" type="text/html" href="https://wiki.santafe.edu/index.php?title=WikiPeerCode&amp;diff=3433"/>
		<updated>2006-06-15T22:45:32Z</updated>

		<summary type="html">&lt;p&gt;Seoc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Back to [[WikiPeer Group]]&lt;br /&gt;
&lt;br /&gt;
* [[RepMod.java.wp]]     : The main model&lt;br /&gt;
* [[CustomNode.java.wp]] : The agent class.&lt;br /&gt;
* [[CustomEdge.java.wp]] : The edge class.&lt;br /&gt;
* [[GameMaster.java.wp]] : The class that organizes the votes, polls, and challenges&lt;br /&gt;
* [[Network.java.wp]]    : The class that initializes the network.&lt;br /&gt;
* [[GUIModel.java.wp]]   : The GUI for the model&lt;br /&gt;
* [[BatchModel.java.wp]] : The batch organizer for the model (not yet implemented)&lt;br /&gt;
* [[ModelParameters.java.wp]] :The base for the model (slightly modified from Rick&#039;s)&lt;/div&gt;</summary>
		<author><name>Seoc</name></author>
	</entry>
</feed>