Deterministic Results 

Hello,

I am using frams to run a number of experiments. Unfortunately, the results are deterministic (i.e., I get the same results every time). I am using the following to run the experiment:

frams "lo baseline_params.expt" "st 100000000" "sa baseline3.expt" "qu"

It would appear I need some way to seed a random number generator. How do I do this? Much thanks!

Cheers,
Donovan

Forums: 
Maciej Komosinski's picture

Include this before "st": "Math.seed=(Math.time%10000)*100;" This is a time-based seed, different seed value every 0.01s. Instead of command-line parameters, you can use a file as well, like "commands.in" sample below:
Simulator.load("vertpos.sim");

//genetic format: 0,1,2,3,4,7
ExpProperties.initialgen = GenMan.getSimplest(7).genotype;

//Simulator.creatwarnfail=1; //don't simulate genotypes with warnings
//mutations and xovers
//ExpProperties.p_mut = 9;
//ExpProperties.p_xov = 1;
//ExpProperties.stagnation=5000;


//popsize
ExpProperties.capacity=10;

//selection and deletion
//case 1:
//ExpProperties.delrule=0; //random
//ExpProperties.selrule=2; //2-tournament
//case 2:
//ExpProperties.delrule=0; //random
//ExpProperties.selrule=5; //5-tournament
//case 3:
ExpProperties.delrule=2; //worst
ExpProperties.selrule=2; //2-tournament


Math.seed=(Math.time%10000)*100;
Simulator.init();

while(!Simulator.shouldStop) Simulator.step();

Hello Maciej,

I'm not sure exactly what you mean here. When I try:

frams "lo baseline_params.expt" "Math.seed=(Math.time%10000)*100" "st 10000" "sa baseline2.expt" "qu"

I get the following error:

[ERROR] FramScriptCompiler::compile - compile error in command line input near line 1: parse error

I'd really like to be able to run it from the command line. Any suggestions?

Thanks,
Donovan

Maciej Komosinski's picture

Missing semicolon at the end of Math.seed=(Math.time%10000)*100 ?

Hi, adding "Math.seed=Math.time*100;" doesn't fix the seed issue. I get exactly the same results. This is my command line:

./frams.linux "lo basicquad.gen" "im evol.smooth.sim" "Math.seed=Math.time*100;" "st 100000000" "sa baseline2.end.expt" "im eval.smooth.sim" "Math.seed=Math.time*100;" "st 10000000" "sa baseline2.eval.smooth.expt" "qu"

Maciej Komosinski's picture

Yes... I have updated previous posts in this thread.

Since Math.seed is a 32-bit integer, you should first cut off the "big number" part from Math.time, otherwise it will overflow the int32 range.

So better use Math.seed=(Math.time%100000)*1000; or similar.

Note that the rnd macro from cliutils.ini does what you need, as shown in the example below.

frams -icliutils.ini "rnd" "Simulator.print(Math.rnd01);" -q