Mercurial > hg > jslab
comparison src/samer/tools/RateSchedule.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package samer.tools; | |
2 | |
3 import samer.core.types.*; | |
4 import samer.core.*; | |
5 | |
6 public class RateSchedule extends AnonymousTask { | |
7 VDouble rate,dec; | |
8 | |
9 public void setRatio(double r) { dec.set(1-r); } | |
10 public void setCount(double n) { dec.set(1/(n+1)); } | |
11 | |
12 public RateSchedule(VDouble rate) { | |
13 this.rate=rate; | |
14 Shell.push(rate.getNode()); | |
15 this.dec=new VDouble("relative dec",0.01); | |
16 Shell.pop(); | |
17 // setCount(n); | |
18 } | |
19 | |
20 public void dispose() { dec.dispose(); super.dispose(); } | |
21 public void run() { | |
22 // rate.value*=n/(1+n); n+=1; | |
23 double d=dec.value; | |
24 if (d>=1) d=1; else if (d<0) d=0; | |
25 rate.value -= rate.value*d; // /(++n); | |
26 dec.value/=1+d; | |
27 dec.set(d/(1+d)); | |
28 rate.changed(); | |
29 } | |
30 } | |
31 | |
32 // note to self: add agent to rate viewable. | |
33 // need linked list of Agents -- DoubleAgent?! |