// // Discrete Time CA using rates and parameterised time // import java.util.*; import java.io.*; import java.awt.*; public class CARM extends CA { double tau; // the unit or measure of time public CARM(int n,int m,double tau,boolean draw){ super(n,m,draw); this.tau = tau; } public void setDeathRate(int species,double rate){ deathRate[species] = rate; pDeath[species] = 1.0 - Math.pow(Math.E,-rate*tau); } int numberOfBirths(double lambda){ double L = 0.0; double U = gen.nextDouble(); double factB = 1.0; for (int b=0;b<8;b++){ if (b > 0) factB = factB * b; L = L + Math.pow(lambda*tau,(double)b) * Math.pow(Math.E,-lambda*tau)/factB; if (L >= U) return b; } return 8; // size of Moore neighbourhood } void doBirths(int[][]X,int[][]Y){ int species = -1; for (int i=0;i 0){ CARM carm = new CARM(n,m,tau,draw); for (int i=1;i<=m;i++){ int species = i-1; int pop = Integer.parseInt(args[3*i]); carm.setBirthRate(species,Double.parseDouble(args[3*i+1])); carm.setDeathRate(species,Double.parseDouble(args[3*i+2])); for (int j=0;j