Return-Path: <ssiegel@MIT.EDU>
Received: from grand-central-station.mit.edu by po11.mit.edu (8.9.2/4.7) id QAA09907; Fri, 16 Aug 2002 16:03:00 -0400 (EDT)
Received: from melbourne-city-street.mit.edu (MELBOURNE-CITY-STREET.MIT.EDU [18.7.21.86])
	by grand-central-station.mit.edu (8.9.2/8.9.2) with ESMTP id QAA09674;
	Fri, 16 Aug 2002 16:02:06 -0400 (EDT)
Received: from balder.mit.edu (BALDER.MIT.EDU [18.170.0.150])
	by melbourne-city-street.mit.edu (8.9.2/8.9.2) with ESMTP id QAA28981;
	Fri, 16 Aug 2002 16:02:06 -0400 (EDT)
Received: from localhost (ssiegel@localhost) by balder.mit.edu (8.9.3) with ESMTP
	id QAA06491; Fri, 16 Aug 2002 16:02:05 -0400 (EDT)
Date: Fri, 16 Aug 2002 16:02:05 -0400 (EDT)
From: Sarah Y Siegel <ssiegel@MIT.EDU>
To: Derek Atkins <warlord@mit.edu>
cc: <sipb@mit.edu>
Subject: Re: java question
In-Reply-To: <sjm4rdufutv.fsf@kikki.mit.edu>
Message-ID: <Pine.GSO.4.30L.0208161559500.6245-100000@balder.mit.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

yeah, I tried it and that's what happened. With
init.loadModel(model, null, true);
it compiles but gives me this runtime error:

java.io.FileNotFoundException:  (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:64)
	at java.io.FileReader.<init>(FileReader.java:38)
	at
uchicago.src.sim.engine.ParameterReader.isXMLFormat(ParameterReader.java:257)
	at
uchicago.src.sim.engine.ParameterReader.<init>(ParameterReader.java:245)
	at uchicago.src.sim.engine.SimInit.load(SimInit.java:185)
	at uchicago.src.sim.engine.SimInit.loadModel(SimInit.java:216)
	at
edu.santafe.csss.fixedschelling.FixedSchellingModel.main(FixedSchellingModel.java:93)


On 16 Aug 2002, Derek Atkins wrote:

> Does it?  Did you try it?
>
> Also, what about the other way around (leave the second parameter null
> but switch the first to true)?
>
> -derek
>
> Sarah Y Siegel <ssiegel@MIT.EDU> writes:
>
> > it runs, but not as a batch file. I guess it just ignores the parameter
> > file.
> >
> > On 16 Aug 2002, Derek Atkins wrote:
> >
> > > Hi,
> > >
> > > There are a number of java hackers in SIPB, so hopefully someone can
> > > help you.
> > >
> > > Trying to limit the factors, what happens if you try:
> > >
> > >         init.loadModel(model, "./Params.txt", false)
> > >
> > > -derek
> > >
> > > Sarah Y Siegel <ssiegel@MIT.EDU> writes:
> > >
> > > > The answer to this email suggested that I contact you guys. Can you help
> > > > me?
> > > >
> > > > Thanks.
> > > >
> > > > -----Original Message-----
> > > > Date: Fri, 16 Aug 2002 13:14:35 -0400
> > > > To: computing-help@MIT.EDU
> > > > From: Sarah Y Siegel <ssiegel@MIT.EDU>
> > > > Cc:
> > > > Subject: java
> > > >
> > > >
> > > > Can you guys help me with a java programming question, or is that more
> > > > specific than you guys get into? I'm guessing it's too specific. If you
> > > > can't, do you have a suggestion as where I could get help? I'm a grad
> > > > student using java for a research project, and I so far haven't found
> > > > anyone in the department who can help me out. And although over the
> > > > summer I've had a couple friends I've asked for help, it would be great
> > > > to have a consultant I could ask. This is my current question, which is
> > > > on a program I've written using the java libraries RePast
> > > > (repast.sourceforge.net):
> > > >
> > > > > So I'm trying to set my simulation to run in batch mode so I
> > > >  > can collect some
> > > >  > data. So I set it up with a data recorder, everything works
> > > >  > fine. Then I changed
> > > >  > one line, from
> > > >  >
> > > >  > init.loadModel(model, null, false);  to
> > > >  > init.loadModel(model, "./Params.txt", true);
> > > >  >
> > > >  > so I changed the parameters file from nothing to one that I
> > > >  > wrote, and then
> > > >  > changed the batch file parameter from false to true.
> > > >  >
> > > >  > It now compiles fine, but when I try to run it it gives me
> > > >  > null pointer
> > > >  > exceptions at these lines:
> > > >  >         x = Random.uniform.nextIntFromTo(0,width-1);
> > > >  >         y = Random.uniform.nextIntFromTo(0,height-1);
> > > >  >
> > > >  > I put in some print commands to see what was going on, and it
> > > >  > does have the
> > > >  > right, nonzero, integer values for width and height. Any ideas? I
> > > > just
> > > >  > can't figure out
> > > >  > what in the world those lines could possibly have to do with
> > > >  > running it as a
> > > >  > batch file.
> > > >
> > > >  > Thanks!
> > > >  >
> > > >  > Sarah
> > > >  >
> > > >  > p.s. Here's more of my code, iwth all the stuff I put in to
> > > >  > try to figure out
> > > >  > what was going on and the error I get in case that
> > > >  > helps--log() is a method that
> > > >  > prints out what's in the parentheses.
> > > >  >
> > > >  >     public static void main(String[] args) {
> > > >  >         uchicago.src.sim.engine.SimInit init =
> > > >  >             new uchicago.src.sim.engine.SimInit();
> > > >  >         FixedSchellingModel model = new FixedSchellingModel();
> > > >  >         init.loadModel(model, "./Params.txt", true);
> > > >  >         //init.loadModel(model, null, false);
> > > >  >     }
> > > >  >
> > > >  >     public void setup() {
> > > >  >         super.setup();
> > > >  >         if (dsurf != null) dsurf.dispose();
> > > >  >
> > > >  >                System.gc();
> > > >  >         log("setting up");
> > > >  >         dsurf = new DisplaySurface(this, "FixedSchelling Display");
> > > >  >         registerDisplaySurface("Main", dsurf);
> > > >  >         generateNewSeed();
> > > >  >         Random.createUniform();
> > > >  >
> > > >  >         BaseController c = getController();
> > > >  >         c.setCellHeight(cellSize);
> > > >  >         c.setCellWidth(cellSize);
> > > >  >         c.setCellDepth(cellSize);
> > > >  >         setStoppingTime(5);
> > > >  >     }
> > > >  >     public void buildModel() {
> > > >  >
> > > >  >         // the "true" or "false" parameter refers to whether
> > > >  > the space should be a
> > > >  > torus
> > > >  >         space = new FixedSchellingSpace(width, height, false, this);
> > > >  >         setupSpace();
> > > >  >         display = space.getDisplay();
> > > >  >         dsurf.addDisplayableProbeable(display, "FixedSchelling
> > > >  > Display");
> > > >  >         ((Object2DDisplay)display).setObjectList(agentList);
> > > >  >         dsurf.display();
> > > >  >         buildCharts();
> > > >  >         recorder = new DataRecorder("./data815.txt", this);
> > > >  >         recorder.addNumericDataSource("avgUtility", new
> > > >  > NumDataSource());
> > > >  >     }
> > > >  >
> > > >  >
> > > >  >     public void setupSpace() {
> > > >  >         //log("random placement");
> > > >  >         double n = ((double)(width * height)*(1-(vacancies/100)));
> > > >  >         int n1 = (int)Math.round(n*type1percent/100);
> > > >  >         int n2 = (int)Math.round(n-n1);
> > > >  >         //log("n1 = " + n1 + " and n2 = " + n2 + " and width =
> > > >  > " + width + " and height
> > > >  > = " + height);
> > > >  >         for (int i= 0; i < n1; i++){
> > > >  >             int x = 10;
> > > >  >             try{
> > > >  >                 x = Random.uniform.nextIntFromTo(0,width-1);
> > > >  >             }
> > > >  >             catch (NullPointerException e){
> > > >  >                 log("something weird here");
> > > >  >
> > > >  >             }
> > > >  >
> > > >  >             int y = Random.uniform.nextIntFromTo(0,height-1);
> > > >  >             //   System.out.println("checking if empty at " + x
> > > >  > + ", " + y);
> > > >  >             while (!space.isEmptyAt(x,y)){
> > > >  >                 x = Random.uniform.nextIntFromTo(0,width-1);
> > > >  >                     y = Random.uniform.nextIntFromTo(0,height-1);
> > > >  >             }
> > > >  >             FixedSchellingAgent agent = new
> > > >  > FixedSchellingAgent(x, y, 1, 11, space);
> > > >  >             space.addAgent(agent);
> > > >  >             agentList.add(agent);
> > > >  >         }
> > > >  >
> > > >  >         for (int i= 0; i < n2; i++){
> > > >  >             int x = Random.uniform.nextIntFromTo(0,width-1);
> > > >  >             int y = Random.uniform.nextIntFromTo(0,height-1);
> > > >  >             while (!space.isEmptyAt(x,y)){
> > > >  >                 x = Random.uniform.nextIntFromTo(0,width-1);
> > > >  >                     y = Random.uniform.nextIntFromTo(0,height-1);
> > > >  >             }
> > > >  >             FixedSchellingAgent agent = new
> > > >  > FixedSchellingAgent(x, y, 2, 21, space);
> > > >  >             space.addAgent(agent);
> > > >  >             agentList.add(agent);
> > > >  >         }
> > > >  >
> > > >  >     }
> > > >  >
> > > >  >     public void step() {
> > > >  >
> > > >  >         //log("stepping!");
> > > >  >         SimUtilities.shuffle(agentList);
> > > >  >         int size = agentList.size();
> > > >  >         for (int i = 0; i < size; i++) {
> > > >  >             FixedSchellingAgent agent =
> > > >  > (FixedSchellingAgent)agentList.get(i);
> > > >  >             agent.step();
> > > >  >         }
> > > >  >         graph.step();
> > > >  >         dsurf.updateDisplay();
> > > >  >         recorder.record();
> > > >  >     }
> > > >  >
> > > >  > and what prints out is:
> > > >  >
> > > >  > setting up
> > > >  > Run: 1
> > > >  > something weird here
> > > >  > java.lang.NullPointerException
> > > >  >         at
> > > >  > edu.santafe.csss.fixedschelling.FixedSchellingModel.setupSpace
> > > >  > (FixedSchellingModel.java:146)
> > > >  >         at
> > > >  > edu.santafe.csss.fixedschelling.FixedSchellingModel.buildModel
> > > >  > (FixedSchellingModel.java:119)
> > > >  >         at
> > > >  > uchicago.src.sim.engine.SimpleModel.begin(SimpleModel.java:104)
> > > >  >         at
> > > >  > uchicago.src.sim.engine.BaseController.startSim(BaseController
> > > >  > .java:345)
> > > >  >         at
> > > >  > uchicago.src.sim.engine.BatchController.start(BatchController.
> > > >  > java:412)
> > > >  >         at
> > > >  > uchicago.src.sim.engine.BatchController$1.run(BatchController.
> > > >  > java:383)
> > > >  >         at java.lang.Thread.run(Thread.java:484)
> > > >  > Batch Done
> > > >  >
> > > >  >
> > > >  >
> > > >
> > >
> > > --
> > >        Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
> > >        Member, MIT Student Information Processing Board  (SIPB)
> > >        URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
> > >        warlord@MIT.EDU                        PGP key available
> > >
> >
>
> --
>        Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
>        Member, MIT Student Information Processing Board  (SIPB)
>        URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
>        warlord@MIT.EDU                        PGP key available
>

