Changeset 418 for experiments/frams/foraminifera
- Timestamp:
- 08/01/15 16:32:10 (9 years ago)
- Location:
- experiments/frams/foraminifera/data/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
experiments/frams/foraminifera/data/scripts/foraminifera.expdef
r416 r418 24 24 - added "S" receptor to visualize the difference between diplo and haplo generations 25 25 - signal.value is a MechPart (a reference) so it does not have to be updated after changing the object location 26 */27 28 /* TODO fix29 [ERROR] Population.kill: Invalid index 35 (allowed range is 0..34)30 [ERROR] Population.kill: ... called from reproduce_haploid() <foraminifera.inc:54>31 [ERROR] Population.kill: ... called from onStep() <foraminifera.inc:228>32 26 */ 33 27 … … 69 63 pop.othermask = 0x10000; 70 64 65 //TODO remove unused params 66 71 67 //radius of the chamber 72 68 ExpParams.rads = [1.2, 0.6]; 69 //ExpParams.rads = [2, 2]; 73 70 //inital genotypes 74 71 ExpParams.genh = "//0\np:sh=1,sx=" + ExpParams.rads[0] + ",sy=" + ExpParams.rads[0] + ",sz=" + ExpParams.rads[0] + ", rz=3.14159265358979"; … … 80 77 ExpParams.feedtrans = 3; 81 78 ExpParams.creath = -0.99; //just above the bottom 82 ExpParams.foodgen = "//0\np:sh=2,sx=0.1,sy=0.1,sz=0.1\nn:d=T,p=0"; 79 ExpParams.foodgen = "//0\np:sh=2,sx=0.1,sy=0.1,sz=0.1\nn:d=T,p=0"; //TODO food size as param 83 80 ExpParams.autorestart = 0; 84 81 ExpParams.psize = 10; … … 102 99 103 100 //grwoth speed in time steps 104 ExpParams.growth_step = 50; 101 ExpParams.growth_step = 50; //50 105 102 106 103 ExpState.totaltestedcr = 0; … … 308 305 else 309 306 { 310 properSize = cr.user2["Va"] >= cr.user1[0]["vamin"]; 307 properSize = cr.user2["Va"] >= cr.user1[0]["vamin"]; //TODO gene selection 311 308 } 312 309 … … 333 330 geno.user1 = cr.user1; 334 331 geno.user2 = cr.user2; 335 Simulator.print("\"" + cr.name + "\" died...");332 if (ExpParams.logging == 1) Simulator.print("\"" + cr.name + "\" died..."); 336 333 ExpState.totaltestedcr++; 337 334 } … … 422 419 id:growth_step 423 420 name:Growth step 424 type:d 1010000 1000421 type:d -1 10000 1000 425 422 426 423 prop: -
experiments/frams/foraminifera/data/scripts/foraminifera.inc
r416 r418 4 4 // -------------------------------- step begin -------------------------------- 5 5 6 function reproduce_haploid( repro_list)6 function reproduce_haploid(parent, parent2) 7 7 { 8 var len = repro_list.size; 9 if (len % 2 != 0) len = repro_list.size - 1; 8 var number = parent.user2["Va"] / ExpParams.ofnumd + parent2.user2["Va"] / ExpParams.ofnumd; 10 9 11 for (var i = 0; i < len - 2 ; i = i + 2)10 for (var j = 0; j < number; j++) 12 11 { 13 var parent = Populations[0].get(repro_list[i]); 14 var parent2 = Populations[0].get(repro_list[i + 1]); 15 16 var number = parent.user2["Va"] / ExpParams.ofnumd + parent2.user2["Va"] / ExpParams.ofnumd; 17 18 for (var j = 0; j < number; j++) 19 { 20 createOffspring(ExpParams.gend, ExpParams.ofnumd, [parent.user1, parent2.user1], {"Va" : ExpParams.ofnumd, "gen" : 1 , "growth_step" : ExpParams.growth_step, "rsize": ExpParams.rads[1], "vinit": ExpParams.ofnumd}); //TODO genes from both generations in user1 21 } 12 createOffspring(ExpParams.gend, ExpParams.ofnumd, [parent.user1, parent2.user1], {"Va" : ExpParams.ofnumd, "gen" : 1 , "growth_step" : ExpParams.growth_step, "rsize": ExpParams.rads[1], "vinit": ExpParams.ofnumd}); //TODO genes from both generations in user1 22 13 } 23 killParents(repro_list);24 14 } 25 15 26 function reproduce_diploid( repro_list)16 function reproduce_diploid(parent) 27 17 { 28 for (var i = 0; i < repro_list.size; i++) 18 var number = parent.user2["Va"] / ExpParams.ofnumh; 19 for (var j = 0; j < number / 2; j++) 29 20 { 30 var parent = Populations[0].get(repro_list[i]);31 32 if ( parent.user2["gen"] != 1)21 var crossed = 0; 22 //crossover 23 if (Math.rnd01 < ExpParams.crossprob) 33 24 { 34 Simulator.print("gen: " + parent.user2["gen"]); 25 crossover(parent, "vamin"); 26 crossed = 1; 35 27 } 36 28 37 if (parent.user2["gen"] == 1)29 for (var k = 0; k < 2; k++) 38 30 { 39 var number = parent.user2["Va"] / ExpParams.ofnumh; 40 for (var j = 0; j < number / 2; j++) 41 { 42 var crossed = 0; 43 //crossover 44 if (Math.rnd01 < ExpParams.crossprob) 45 { 46 crossover(parent, "vamin"); 47 crossed = 1; 48 } 31 createOffspring(ExpParams.genh, ExpParams.ofnumh, {"vamin" : ExpParams.v_min_h, "amin": ExpParams.age_min_h}, {"Va" : ExpParams.ofnumh, "gen" : 0 , "growth_step" : ExpParams.growth_step, "rsize" : ExpParams.rads[0], "vinit": ExpParams.ofnumh}); 32 } 49 33 50 for (var k = 0; k < 2; k++) 51 { 52 createOffspring(ExpParams.genh, ExpParams.ofnumh, {"vamin" : ExpParams.v_min_h, "amin": ExpParams.age_min_h}, {"Va" : ExpParams.ofnumh, "gen" : 0 , "growth_step" : ExpParams.growth_step, "rsize" : ExpParams.rads[0], "vinit": ExpParams.ofnumh}); 53 } 54 55 //reverse of crossover for fossilization 56 if (crossed == 1) 57 { 58 crossover(parent, "vamin"); 59 crossed = 0; 60 } 61 } 34 //reverse of crossover for fossilization 35 if (crossed == 1) 36 { 37 crossover(parent, "vamin"); 38 crossed = 0; 62 39 } 40 63 41 } 64 killParents(repro_list);65 42 } 66 43 … … 72 49 } 73 50 74 function killParents(repro_list)75 {76 for (var j = 0; j < repro_list.size; j++)77 {78 Populations[0].kill(repro_list[j]);79 }80 }81 51 82 52 function createOffspring(geno, energy, new_user1, new_user2) … … 164 134 { 165 135 reprocounter = 0; 166 var to_repro_h = []; 167 var to_repro_d = []; 168 for (var i = 0; i < Populations[0].size; i++) 136 var parent1 = null; 137 var parent2 = null; 138 var pop = Populations[0]; 139 for (var i = pop.size-1; i >= 0; i--) 169 140 { 170 var cr = Populations[0].get(i); 171 if (cr.signals.size > 0) 172 { 173 if (cr.user2["gen"] == 0) 141 if (pop[i].signals.size > 0) 142 { 143 if (pop[i].user2["gen"]==1) 174 144 { 175 to_repro_h.add(i); 145 reproduce_diploid(pop[i]); 146 pop.kill(i); 176 147 } 177 if (cr.user2["gen"] == 1)148 else if (parent1 == null) 178 149 { 179 to_repro_d.add(i);150 parent1 = pop[i]; 180 151 } 181 } 182 } 183 if (to_repro_h.size > 1) 184 { 185 reproduce_haploid(to_repro_h); 186 } 187 if (to_repro_d.size > 0) 188 { 189 reproduce_diploid(to_repro_d); 152 else if (parent2 == null) 153 { 154 parent2 = pop[i]; 155 } 156 else 157 { 158 reproduce_haploid(parent1, parent2); 159 pop.kill(parent1); 160 pop.kill(parent2); 161 parent1 = null; 162 parent2 = null; 163 } 164 165 } 190 166 } 191 167 }
Note: See TracChangeset
for help on using the changeset viewer.