swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EZDistribution


From: Marcus G. Daniels
Subject: Re: EZDistribution
Date: 08 Jan 2002 01:26:36 -0700
User-agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.7

>>>>> "BI" == Benjamin Inden <address@hidden> writes:

BI> 1) The GUI shows percentage values for all Bins
BI> correctly. However, the log file that is created at the same time
BI> has just "1" if the value ist 1.0 and "0" if the value ist below
BI> 1.0. I have tried to adjust this with ezBin.setPrecision(4), but
BI> this has not changed anything. How can I get correct numbers in
BI> the log file?

This is fixed in today's binaries:

  ftp://ftp.swarm.org/pub/swarm/binaries/w32/latest/javaswarm.dll.gz
                                                    libkaffeswarm.dll.gz
                                                    swarm.jar.gz

Source at:
  ftp://ftp.swarm.org/pub/swarm/src/testing/swarm-2002-01-07.tar.gz

BI> 2) I have a lot of Bins. Is there a way to change the initial size
BI> of the EZDistribution window?

Use setSaveSizeFlag as below.  Then, size the window as you prefer and
click `Save'.

import swarm.Globals;
import swarm.simtoolsgui.GUISwarmImpl;
import swarm.defobj.Zone;
import swarm.activity.Activity;
import swarm.objectbase.Swarm;
import swarm.activity.Schedule;
import swarm.activity.ScheduleImpl;
import swarm.analysis.EZDistributionImpl;
import swarm.analysis.EZDistributionCImpl;
import swarm.analysis.EZDistribution;
import swarm.analysis.EZDistributionC;
import swarm.Selector;
import java.util.LinkedList;
import java.util.List;

public class TestEZDistribution extends GUISwarmImpl {
  class Agent {
    double value;

    Agent (double value) {
      this.value = value;
    }

    void newValue () {
      value = Globals.env.uniformDblRand.getDoubleWithMin$withMax (.1, 1);
    }

   public double getAgentValue () {
     return value;
    }
  }
 
  List list;
  Schedule schedule;
  EZDistribution ezdist;

  TestEZDistribution (Zone aZone) {
    super (aZone);
  }
  
  void addValueToList () {
    double v = Globals.env.uniformDblRand.getDoubleWithMin$withMax (.1, 1);

    list.add (new Agent (v));
  }

  public void step () {
    addValueToList ();

    ezdist.update ();
    ezdist.output ();
    getActionCache ().doTkEvents ();
  }

  public Object buildObjects () {
    super.buildObjects ();

    list = new LinkedList ();
    addValueToList ();

    EZDistributionC distC = new EZDistributionCImpl (new EZDistributionImpl ());
    distC.createBegin (getZone ());
    distC.setTitle ("test");
    distC.setLowerBound (0.0);
    distC.setUpperBound (1.0);
    distC.setBinCount (10);
    distC.setAxisLabelsX$Y ("x", "y");
    distC.setFileOutput (true);
    distC.setFileName ("dist.txt");
    distC.setWindowGeometryRecordName ("ezdist");
    distC.setSaveSizeFlag (true);
    try { 
      Selector sel = new Selector (Agent.class,
                                   "getAgentValue",
                                   false);
      
      distC.setProbedSelector (sel);
      distC.setCollection (list);
    } catch (Exception e) {
      e.printStackTrace (System.err);
      System.exit (1);
    }
    ezdist = (EZDistribution) distC.createEnd ();
    return this;
  }

  public Object buildActions () {
    super.buildActions ();
   
    schedule = new ScheduleImpl (getZone (), 1);

    try {
      Selector sel = new Selector (getClass (), "step", false);

      schedule.at$createActionTo$message (0, this, sel);
    } catch (Exception e) {
      e.printStackTrace (System.err);
      System.exit (1);
    }
    return this;
  }
  
  public Activity activateIn (Swarm swarmContext) {
    super.activateIn (swarmContext);

    schedule.activateIn (this);
    return getActivity ();
  }
  

 public static void main (String []args) {
    Globals.env.initSwarm ("TestEZDist", "0.0", "address@hidden", args);

    TestEZDistribution ezdistTest =
        new TestEZDistribution (Globals.env.globalZone);

    ezdistTest.buildObjects ();
    ezdistTest.buildActions ();
    ezdistTest.activateIn (null);

    ezdistTest.go ();
  }
}

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]