LISTSERV mailing list manager LISTSERV 16.0

Help for MASON-INTEREST-L Archives


MASON-INTEREST-L Archives

MASON-INTEREST-L Archives


MASON-INTEREST-L@LISTSERV.GMU.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

MASON-INTEREST-L Home

MASON-INTEREST-L Home

MASON-INTEREST-L  December 2011

MASON-INTEREST-L December 2011

Subject:

Patch for minor issues

From:

"Richard O. Legendi" <[log in to unmask]>

Reply-To:

MASON Multiagent Simulation Toolkit <[log in to unmask]>

Date:

Mon, 5 Dec 2011 15:26:21 +0100

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (18 lines) , mason_minor_fixes_rlegendi.patch (1 lines)

Dear List Members,

I downloaded the latest source of MASON and made some minor 
modifications on the code (some errors caused by typos, created but not 
thrown exceptions, some NPEs, corrected error messages and alike).

Hope you may find them useful.

Best regards,
Richard
-- 
Richard O. Legendi
Software developer
Intelligent Applications and Web Services
AITIA International, Inc.
http://people.inf.elte.hu/legendi/



Index: sim/field/network/Edge.java =================================================================== --- sim/field/network/Edge.java (revision 584) +++ sim/field/network/Edge.java (working copy) @@ -100,7 +100,9 @@ this.to = to; this.info = info; this.indexFrom = indexFrom; - this.indexFrom = indexTo; + //this.indexFrom = indexTo; + // I guess this should be an indexTo assignment: + this.indexTo = indexTo; } /** @@ -147,6 +149,13 @@ } + // Note: if compareTo() returns 0 then equals() should return true as well + // However, the equals() method is not overridden. See the Javadoc of + // Comparable: + // "It is strongly recommended, but not strictly required that + // (x.compareTo(y)==0) == (x.equals(y))." + // This may result in weird stuff when using Edges with something like + // PriorityQueues public int compareTo(Object obj) { if (info == null || obj == null || !(obj instanceof Edge)) Index: sim/engine/Schedule.java =================================================================== --- sim/engine/Schedule.java (revision 584) +++ sim/engine/Schedule.java (working copy) @@ -673,8 +673,13 @@ public boolean equals(Object obj) { - Key o = (Key)obj; - return (o.time == time && o.ordering == ordering); + // ERROR Preparing for null and non-Key parameters + if (obj instanceof Key) + { + Key o = (Key)obj; + return (o.time == time && o.ordering == ordering); + } + return false; } public int hashCode() Index: sim/util/gui/MiniHistogram.java =================================================================== --- sim/util/gui/MiniHistogram.java (revision 584) +++ sim/util/gui/MiniHistogram.java (working copy) @@ -186,7 +186,11 @@ String[] s = new String[numBuckets]; if (min>max) {double tmp = min; min = max; max = tmp;} // duh, stupid user - else if (min==max) { s[0] = "["+min+"..."+max+"]"; for(int x=1;x<s.length;x++) s[x] = ""; return s;} // duh, stupider user + + // I'm not sure about this, but I guess the following has nothing to do with the previous if-else + // E.g., if min > max, then an array of nulls returned + + if (min==max) { s[0] = "["+min+"..."+max+"]"; for(int x=1;x<s.length;x++) s[x] = ""; return s;} // duh, stupider user else if (logScale) { min = Math.log(min); Index: sim/util/media/MovieEncoder.java =================================================================== --- sim/util/media/MovieEncoder.java (revision 584) +++ sim/util/media/MovieEncoder.java (working copy) @@ -464,7 +464,8 @@ boolean endAcknowledged = false; float frameRate; - MovieEncoderDataStream(Format format, float frameRate) { frameRate = this.frameRate ;this.format = format; } + // ERROR wrong assignment + MovieEncoderDataStream(Format format, float frameRate) { this.frameRate = frameRate ;this.format = format; } void finish() { Index: sim/util/media/chart/MinGapDataCuller.java =================================================================== --- sim/util/media/chart/MinGapDataCuller.java (revision 584) +++ sim/util/media/chart/MinGapDataCuller.java (working copy) @@ -181,7 +181,7 @@ } //I prefer to drop the point the leaves behind the smallest gap (key=leftGap+rightGap) //In case of a tie, I prefer to dop the first point (so I keep more of the fresh data on) - public int compareTo(Object o) + public int compareTo(Object o) // See comment for sim.field.network.Edge, same stands here { Record r = (Record)o; double keydiff = key-r.key; Index: sim/util/media/chart/ScatterPlotSeriesAttributes.java =================================================================== --- sim/util/media/chart/ScatterPlotSeriesAttributes.java (revision 584) +++ sim/util/media/chart/ScatterPlotSeriesAttributes.java (working copy) @@ -6,23 +6,24 @@ package sim.util.media.chart; -import java.awt.*; -import javax.swing.*; -import javax.swing.border.*; -import java.awt.geom.*; -import java.awt.event.*; -import java.util.*; -import sim.util.gui.*; +import java.awt.Color; +import java.awt.Shape; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.geom.AffineTransform; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.util.Arrays; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; -// From JFreeChart (jfreechart.org) -import org.jfree.data.xy.*; -import org.jfree.chart.*; -import org.jfree.chart.event.*; -import org.jfree.chart.plot.*; -import org.jfree.data.general.*; -import org.jfree.chart.renderer.xy.*; -import org.jfree.data.general.*; -import org.jfree.data.xy.*; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.data.general.SeriesChangeListener; + +import sim.util.gui.ColorWell; +import sim.util.gui.NumberTextField; public class ScatterPlotSeriesAttributes extends SeriesAttributes { @@ -130,7 +131,8 @@ public void setName(String val) { - setName(val); + //setName(val); // ERROR Isn't this an infinite recursion? + super.setName(val); // I guess this was intended, right? ((ScatterPlotGenerator)generator).update(); } Index: sim/util/CausedRuntimeException.java =================================================================== --- sim/util/CausedRuntimeException.java (revision 584) +++ sim/util/CausedRuntimeException.java (working copy) @@ -45,9 +45,11 @@ if (target == null) // duh, need to print our own stack trace super.printStackTrace(); else - stream.println("CausedRuntimeException: " + message); - stream.println("Caused By:"); - target.printStackTrace(stream); + { + stream.println("CausedRuntimeException: " + message); + stream.println("Caused By:"); + target.printStackTrace(stream); // Here it may be null otherwise + } } public void printStackTrace(PrintWriter stream) @@ -55,9 +57,11 @@ if (target == null) // duh, need to print our own stack trace super.printStackTrace(); else + { stream.println("CausedRuntimeException: " + message); - stream.println("Caused By:"); - target.printStackTrace(stream); + stream.println("Caused By:"); + target.printStackTrace(stream); // Here it may be null otherwise + } } public void printStackTrace() { printStackTrace(System.err); } Index: sim/util/distribution/Gamma.java =================================================================== --- sim/util/distribution/Gamma.java (revision 584) +++ sim/util/distribution/Gamma.java (working copy) @@ -118,7 +118,7 @@ // Check for invalid input values if (a <= 0.0) throw new IllegalArgumentException(); - if (lambda <= 0.0) new IllegalArgumentException(); + if (lambda <= 0.0) throw new IllegalArgumentException(); // ERROR Forgot to throw the created exception if (a < 1.0) { // CASE A: Acceptance rejection algorithm gs b = 1.0 + 0.36788794412 * a; // Step 1 Index: sim/app/balls3d/Balls3D.java =================================================================== --- sim/app/balls3d/Balls3D.java (revision 584) +++ sim/app/balls3d/Balls3D.java (working copy) @@ -13,8 +13,6 @@ public class Balls3D extends SimState { - private static final long serialVersionUID = 1; - public Continuous3D balls; public Network bands; Index: sim/app/particles3d/Particles3D.java =================================================================== --- sim/app/particles3d/Particles3D.java (revision 584) +++ sim/app/particles3d/Particles3D.java (working copy) @@ -63,5 +63,4 @@ System.exit(0); } - static final long serialVersionUID = 9115981605874680023L; } Index: sim/app/cto/KMeansEngine.java =================================================================== --- sim/app/cto/KMeansEngine.java (revision 584) +++ sim/app/cto/KMeansEngine.java (working copy) @@ -10,7 +10,7 @@ public /*strictfp*/ class KMeansEngine { - private static final long serialVersionUID = 1; + // private static final long serialVersionUID = 1; // Unused final static double ALFA = 0.25; @@ -52,6 +52,12 @@ public Double2D getGoalPosition( int id ) { + // ERROR There may be some serious synchronization issues here. + // Since basically there are only two Boolean instances (Boolean.TRUE + // and Boolean.FALSE), they are synchronizing on the same object + // instances everywhere in the code. + // + // By default, all of the usable[] elements refer to Boolean.FALSE. synchronized( usable[id] ) { if( usable[id].booleanValue() ) @@ -111,6 +117,7 @@ } for( int i = 0 ; i < CooperativeObservation.NUM_AGENTS ; i++ ) { + // ERROR Same comment as above with Synchronizing on Booleans synchronized( usable[i] ) { if( n[i] != 0 ) Index: sim/portrayal/network/SimpleEdgePortrayal2D.java =================================================================== --- sim/portrayal/network/SimpleEdgePortrayal2D.java (revision 584) +++ sim/portrayal/network/SimpleEdgePortrayal2D.java (working copy) @@ -247,7 +247,7 @@ labelFont.getSize2D(); if (scaledFont == null || scaledFont.getSize2D() != size || - scaledFont.getFamily() != labelFont.getFamily() || + ! scaledFont.getFamily().equals( labelFont.getFamily() ) || // ERROR These are strings scaledFont.getStyle() != labelFont.getStyle()) scaledFont = this.scaledFont = labelFont.deriveFont(size);

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

May 2021
April 2021
March 2021
February 2021
August 2020
July 2020
June 2020
February 2020
August 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
October 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
September 2017
June 2017
May 2017
March 2017
February 2017
January 2017
December 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
February 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
July 2004
May 2004
April 2004
March 2004

ATOM RSS1 RSS2



LISTSERV.GMU.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager