Changeset 474 for experiments


Ignore:
Timestamp:
03/12/16 00:13:49 (9 years ago)
Author:
oriona
Message:

Parameters for time scaling added.

Location:
experiments/frams/foraminifera/data/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experiments/frams/foraminifera/data/scripts/foraminifera.expdef

    r470 r474  
    3131global max_chamber_energ;
    3232global dir_change;
     33global movePerStep;
    3334
    3435@include "foraminifera.inc"
     
    8182        ExpParams.autorestart = 0;
    8283
     84        //time
     85        ExpParams.secPerStep = 60;
     86        ExpParams.foramSpeedMmPerMin = 0.1;
     87        movePerStep = getMovePerStep();
     88
    8389        //ExpParams.visualize = 1; //uncomment to visualize reticulopodia and indicate nutrients positions
    8490
     
    8793        //reproduction
    8894        ExpParams.foramPop = 10;       
    89         ExpParams.crossprob = 0.4;
    90         ExpParams.mutationprob = 0.2;
     95        ExpParams.crossprob = 0;
     96        ExpParams.mutationprob = 0;
    9197        ExpParams.repro_time = 20;
    9298        reprocounter = 0;
    9399
    94100        //morphology
    95         dir_change = 500;
     101        dir_change = 30000;
    96102        ExpParams.zone1_range = micronsToFrams(3000);
    97103        ExpParams.zone2_range = micronsToFrams(6000);
     
    114120        ExpParams.min_repro_energ_diplo = 6;
    115121
    116         ExpParams.e_meta = 0.0002;
    117         ExpParams.energy_hib = 0.0001;
    118         ExpParams.energy_move = 0.00025;
     122        ExpParams.e_meta = 0.00005;
     123        ExpParams.energy_hib = 0.000025;
     124        ExpParams.energy_move = 0.00005;
    119125
    120126        ExpParams.energies0_haplo = max_chamber_energ[0][0] - 0.001*max_chamber_energ[0][0];
    121127        ExpParams.energies0_diplo = max_chamber_energ[1][0] - 0.001*max_chamber_energ[1][0];
    122         ExpParams.feedtrans = 0.5;
     128        ExpParams.feedtrans = 0.125;
    123129        ExpParams.e_repro_cost_haplo = 0.7;
    124130        ExpParams.e_repro_cost_diplo = 0.3;
     
    128134        ExpParams.energy_nut = 100 * Math.pow(ExpParams.nutrientsize, 3);
    129135        ExpParams.nutrientPop = 1;
    130         ExpParams.feedrate = 0.1;
    131         nutrientenergywaiting = ExpParams.energy_nut;
     136        ExpParams.feedrate = 100;
     137        nutrientenergywaiting = 0;
    132138        ExpState.totaltestedcr = 0;
    133139        ExpState.nutrient = "";
     
    135141
    136142@include "standard_placement.inc"
     143
     144function getMovePerStep()
     145{
     146        return micronsToFrams((ExpParams.foramSpeedMmPerMin/60)*1000)*ExpParams.secPerStep;
     147}
    137148
    138149function micronsToFrams(micrometers)
     
    247258function setForamMeta(cr, gen)
    248259{
    249         cr.idleen = ExpParams.e_meta * max_chamber_energ[gen][Math.min(lastChamberNum(cr), max_chamber_energ[gen].size-1)];
     260        cr.idleen = (ExpParams.e_meta * max_chamber_energ[gen][Math.min(lastChamberNum(cr), max_chamber_energ[gen].size-1)])*ExpParams.secPerStep;
    250261}
    251262
     
    295306function foramGrow(cr, chamber_num)
    296307{
    297         var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
    298         var cr2 = Populations[0].add(geno);
    299 
    300         cr2.energy0 = cr.energy;
    301         cr2.energy = cr2.energy0;
    302 
    303         setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "opt" : 2});
    304         cr2.moveAbs(cr.center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2, cr.pos_z);
    305         setForamMeta(cr2, cr2.user2["gen"]);
    306 
    307         if (visualization(cr))
    308         {
    309                 Populations[2].delete(cr.user3);
    310         }
    311         Populations[0].delete(cr);
     308        if ((chamber_num+1) < chambers[cr.user2["species"]].size)
     309        {
     310                var geno = createForamGenotype(cr.user2["gen"], cr.user2["species"], chamber_num+1);
     311                var cr2 = Populations[0].add(geno);
     312
     313                cr2.energy0 = cr.energy;
     314                cr2.energy = cr2.energy0;
     315
     316                setGenotype({"cr" : cr2, "parent_user1" : cr.user1, "parent_user2" : cr.user2, "opt" : 2});
     317                cr2.moveAbs(cr.center_x - cr2.size_x / 2, cr.center_y - cr2.size_y / 2, cr.pos_z);
     318                setForamMeta(cr2, cr2.user2["gen"]);
     319
     320                if (visualization(cr))
     321                {
     322                        Populations[2].delete(cr.user3);
     323                }
     324                Populations[0].delete(cr);
     325        }
    312326}
    313327
     
    352366                {
    353367                        mindistvec.normalize();
    354                         mindistvec.scale(-0.08);
     368                        mindistvec.scale(-1*movePerStep);
    355369                        cr.localDrive = mindistvec;
    356370                        moveEnergyDec(cr);
     
    361375       
    362376        else
     377        {
    363378                return 0;
     379        }
    364380}
    365381
     
    368384        if (cr.user2["hibernated"] == 0)
    369385        {
    370                 cr.energy_m += ExpParams.energy_move * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)];
     386                cr.energy_m += (ExpParams.energy_move * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)])*ExpParams.secPerStep;
    371387        }
    372388}
     
    399415        }
    400416        //random move
    401         else if (cr.lifespan%dir_change == 0)
    402         {
    403                 var dir = (Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), 0); 
    404                 dir.normalize();
    405                 dir.scale(-0.08);
    406                 cr.localDrive = dir;
     417        else if (cr.lifespan%(dir_change/ExpParams.secPerStep) == 0)
     418        {
     419                cr.user2["dir"] = randomDir();
     420                cr.localDrive = cr.user2["dir"];
    407421                moveEnergyDec(cr);
    408422        }
     423        else
     424        {
     425                cr.localDrive = cr.user2["dir"];
     426        }
     427}
     428
     429function randomDir()
     430{
     431        var dir = (Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), Math.rndUni(-ExpParams.zone2_range, ExpParams.zone2_range), 0); 
     432        dir.normalize();
     433        dir.scale(-1*movePerStep);
     434        return dir;
    409435}
    410436
     
    412438{
    413439        cr1.localDrive = XYZ.new(0,0,0);
    414         var e = cr2.getPart(0).ing * ExpParams.feedtrans; //TODO efficiency dependent on age
     440        var e = ExpParams.feedtrans*ExpParams.secPerStep; //TODO efficiency dependent on age
    415441        e = Math.min(cr2.energy, e) + 0.0000001;
    416442        //Simulator.print("transferring "+e+" to "+cr1.name+" from "+cr2.name+" ("+cr2.energy+")");
     
    431457        else
    432458        {
    433                 cr.idleen = ExpParams.energy_hib * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)]; //hibernate
     459                cr.idleen = (ExpParams.energy_hib * max_chamber_energ[cr.user2["gen"]][Math.min(lastChamberNum(cr), (max_chamber_energ[cr.user2["gen"]].size)-1)])*ExpParams.secPerStep; //hibernate
    434460        }
    435461        cr.user2["hibernated"] = 1 - cr.user2["hibernated"];
     
    536562function nutrientGrowth()
    537563{
    538         nutrientenergywaiting = nutrientenergywaiting + ExpParams.feedrate;
    539         if (nutrientenergywaiting > ExpParams.energy_nut)
     564        nutrientenergywaiting = nutrientenergywaiting + 1;
     565        if (nutrientenergywaiting > ExpParams.feedrate/ExpParams.secPerStep)
    540566        {
    541567                for (var i = 0; i < ExpParams.nutrientPop; i++)
     
    564590        //reproduction --------------------------------------------
    565591        reprocounter += 1;
    566         if (reprocounter > ExpParams.repro_time)
     592        if (reprocounter*ExpParams.secPerStep > ExpParams.repro_time)
    567593        {
    568594                reprocounter = 0;
     
    618644
    619645        log(log_numbers, "forams_log.txt");
    620         log(log_energies,  "energies_log.txt");
     646    log(log_energies,  "energies_log.txt");
    621647}
    622648
     
    649675name:Stop after the given number of simulation steps
    650676type:d 0 1000000 0
     677
     678prop:
     679id:foramSpeedMmPerMin
     680name:Speed of foraminfera in mm/min
     681type:f 0.1
     682flags: 16
     683group:Foraminifera
     684
     685prop:
     686id:secPerStep
     687name:Seconds per simulation step
     688type:f 60.0
     689flags: 16
     690group:Foraminifera
    651691
    652692prop:
     
    798838id:feedrate
    799839name:Feeding rate
    800 type:f 0 100
     840type:f 0 1000000
    801841group:Energy
    802842help:How fast energy is created in the world
     
    841881id:repro_time
    842882name:Time before reproduction
    843 type:d 0 1000
     883type:d 0 10000
    844884
    845885prop:
  • experiments/frams/foraminifera/data/scripts/foraminifera.inc

    r432 r474  
    5656        {
    5757                mode["cr"].user1 = {"min_repro_energies" : [max_chamber_energ[0][getProperty(0, "min_repro_energ")], max_chamber_energ[1][getProperty(1, "min_repro_energ")]], "hibernation" : mode["species"]};
    58                 mode["cr"].user2 = {"max_energy_level" : getProperty(0,"energies0"), "gen" : 0,  "hibernated" : 0, "species" : mode["species"], "reproduce" : 0};
     58                mode["cr"].user2 = {"max_energy_level" : getProperty(0,"energies0"), "gen" : 0,  "hibernated" : 0, "species" : mode["species"], "reproduce" : 0, "dir" : randomDir()};
    5959        }
    6060        else if (mode["opt"]  == 1) //child
    6161        {
    62                 mode["cr"].user2 = {"max_energy_level" : getProperty(1 - mode["parent_user2"]["gen"],"energies0"), "gen" : 1 - mode["parent_user2"]["gen"],  "hibernated" : 0, "species" : mode["parent_user2"]["species"], "reproduce" : 0};
     62                mode["cr"].user2 = {"max_energy_level" : getProperty(1 - mode["parent_user2"]["gen"],"energies0"), "gen" : 1 - mode["parent_user2"]["gen"],  "hibernated" : 0, "species" : mode["parent_user2"]["species"], "reproduce" : 0, "dir" : randomDir()};
    6363                mode["cr"].user1 = mode["parent_user1"];
    6464        }
  • experiments/frams/foraminifera/data/scripts/foraminifera.show

    r454 r474  
    2323        GLDisplay.minfps = 10;
    2424        TrackingCam.cam_h = 15; //more side view
    25         Params = { "feedrate" : [0.05,0.1,0.2], "feedtrans" : [0.01,0.05,0.1],"energy_nut" :[0.5,1.5,3.0], "stress" : [0,1], "visualize" : [0,1]};
     25        Params = { "feedrate" : [200,100,50], "feedtrans" : [0.05,0.125,0.25],"energy_nut" :[0.5,1.5,3.0], "stress" : [0,1], "visualize" : [0,1]};
    2626        ShowParams.visualize=1;
    2727}
     
    3030{
    3131        //just a draft, this function and all constants in expdef need serious review
    32         var foramSpeedMmPerMin=0.1; //0.1 mm/minute based on http://drs.nio.org/drs/bitstream/handle/2264/418/ONGC_Bull_37%281%29_53.pdf
    33         var localDriveMicronsPerStep=framsToMicrons(0.08); //0.08 is used in expdef as distance (in frams units) per simulation step. TODO Use a variable/constant/function from expdef instead of copying this value here
    34         var foramSpeedMmPerSec=foramSpeedMmPerMin/60;
     32        var localDriveMicronsPerStep=framsToMicrons(getMovePerStep());
     33        var foramSpeedMmPerSec=ExpParams.foramSpeedMmPerMin/60;
    3534        var localDriveMmPerStep=localDriveMicronsPerStep/1000;
    3635        var localDriveMmPerSec=localDriveMmPerStep*Simulator.simspeed;
     
    9392id:feedtrans
    9493name:Energy transfer
    95 type:d 0 2 1 ~0.01~0.05~0.1
     94type:d 0 2 1 ~0.05~0.125~0.25
    9695
    9796prop:
Note: See TracChangeset for help on using the changeset viewer.