Skip to content
Snippets Groups Projects
Commit ceb0d833 authored by fjn1g13's avatar fjn1g13
Browse files

Getting ready...

parent e8a12f7f
No related branches found
No related tags found
No related merge requests found
...@@ -14,12 +14,12 @@ namespace IVMCTrim ...@@ -14,12 +14,12 @@ namespace IVMCTrim
class Program class Program
{ {
// This is the entry point. // This is the entry point.
// Consult readme.md for information about how to run this program. // Consult readme.md for additional information about how to run this program.
// Consult fjn1g13@soton.ac.uk if you don't understand something. // Consult fjn1g13@soton.ac.uk if you don't understand something.
// This code is not exemplar C#; rather, the idea is that it should be fairly easy for anyone to reimplement the model from looking at it without taking too long to run. // This code is not exemplar C#; rather, the idea is that it should be fairly easy for anyone to reimplement the model, but it should also reproduce the experiments from the paper.
static void Main() static void Main()
{ {
// none of our matrices are big enough to warrent multi-threading // none of our matrices are big enough to warrant multi-threading
MathNet.Numerics.Control.UseSingleThread(); MathNet.Numerics.Control.UseSingleThread();
// runs a bunch of experiments with the 'standard' configuration, only varying Z // runs a bunch of experiments with the 'standard' configuration, only varying Z
...@@ -279,6 +279,36 @@ namespace IVMCTrim ...@@ -279,6 +279,36 @@ namespace IVMCTrim
return (double)wins.Last() / runonEpisodeCount; return (double)wins.Last() / runonEpisodeCount;
} }
/// <summary>
/// Runs a few episodes, recording the fitness per evolutionary step with the given sample period.
/// </summary>
/// <returns>
/// A list of <see cref="DataPoint"/> comprising the evolutionary step and fitness.
/// </returns>
public static List<DataPoint> RunTracee(Parameters parameters, Individual individual, int traceeEpisodeCount = 4, int samplePeriod = 100)
{
individual = individual.Clone();
// run tracee
var ctx = new ExecutionContext(new MersenneTwister(3)); // common seed (chosen so that it has a mix of cL and c0)
var env = new IvmcEnvironment(parameters.ModuleSize, parameters.ModuleCount);
var fitnessSamples = new List<DataPoint>();
void sample(IvmcEnvironment _env, IndividualEvaluation stepIndividualEvaluation, int _episode, int evolutionaryStep)
{
if (evolutionaryStep % samplePeriod == 0)
fitnessSamples.Add(new DataPoint(_episode * parameters.EvolutionaryStepsPerEpisode + evolutionaryStep, stepIndividualEvaluation.Evaluation.Fitness));
}
for (int traceeEpisodes = 0; traceeEpisodes < traceeEpisodeCount; traceeEpisodes++)
{
Model.RunEpisode(traceeEpisodes, ctx, parameters, env, ref individual, sample);
}
return fitnessSamples;
}
} }
public static class Configurations public static class Configurations
...@@ -930,7 +960,10 @@ namespace IVMCTrim ...@@ -930,7 +960,10 @@ namespace IVMCTrim
{ {
// report progress // report progress
Console.WriteLine($"{outputDirectory}: {episode}/{parameters.TotalEpisodes} ({(double)episode / parameters.TotalEpisodes:P})\tf={evaluation.Fitness}"); Console.WriteLine($"{outputDirectory}: {episode}/{parameters.TotalEpisodes} ({(double)episode / parameters.TotalEpisodes:P})\tf={evaluation.Fitness}");
}
if (episode % (reportingPeriodMultiplier * 10000) == 0)
{
// produce grn plot // produce grn plot
var grnPlot = PlotHelpers.IntegralCartesianAxes($"Episode {episode}", "row", "col"); var grnPlot = PlotHelpers.IntegralCartesianAxes($"Episode {episode}", "row", "col");
grnPlot.Axes.Add(PlotHelpers.Gray()); grnPlot.Axes.Add(PlotHelpers.Gray());
...@@ -938,23 +971,7 @@ namespace IVMCTrim ...@@ -938,23 +971,7 @@ namespace IVMCTrim
grnPlot.ExportPdf(path($"episode{episode}.pdf"), 0.5, true); grnPlot.ExportPdf(path($"episode{episode}.pdf"), 0.5, true);
// run tracee // run tracee
var ctx = new ExecutionContext(new MersenneTwister(3)); // common seed (chosen so that it has a mix of cL and C0) var fitnessSamples = Model.RunTracee(parameters, individual);
var env = new IvmcEnvironment(parameters.ModuleSize, parameters.ModuleCount);
var clone = individual.Clone(); // don't want to modify the real guy
var fitnessSamples = new List<DataPoint>();
void sample(IvmcEnvironment _env, IndividualEvaluation stepIndividualEvaluation, int _episode, int evolutionaryStep)
{
if (evolutionaryStep % 100 == 0)
fitnessSamples.Add(new DataPoint(_episode * parameters.EvolutionaryStepsPerEpisode + evolutionaryStep, stepIndividualEvaluation.Evaluation.Fitness));
}
int traceeEpisodeCount = 4;
for (int traceeEpisodes = 0; traceeEpisodes < traceeEpisodeCount; traceeEpisodes++)
{
Model.RunEpisode(traceeEpisodes, ctx, parameters, env, ref clone, sample);
}
// plot tracee // plot tracee
var traceePlot = PlotHelpers.LinearAxes($"Episode {episode}", "Evolutionary Step", "Fitness"); var traceePlot = PlotHelpers.LinearAxes($"Episode {episode}", "Evolutionary Step", "Fitness");
......
...@@ -9,7 +9,7 @@ It will produce some directories, each containing a spread of experiments and fi ...@@ -9,7 +9,7 @@ It will produce some directories, each containing a spread of experiments and fi
# ranges # ranges
function repeats($n) { 0..($n-1) | ForEach-Object { ,@("$_", "$_")} } function repeats($n) { 0..($n-1) | ForEach-Object { ,@($_.ToString("00"), $_.ToString("00"))} }
# funky ordering is to match the funky ordering of the runs that are used in the paper (for seed generation) (sorry) # funky ordering is to match the funky ordering of the runs that are used in the paper (for seed generation) (sorry)
$twentyHalf = (("0.00", "000"), ("0.10", "010"), ("0.20", "020"), ("0.30", "030"), ("0.40", "040"), ("0.50", "050"), ("0.60", "060"), ("0.70", "070"), ("0.80", "080"), ("0.90", "090"), ("1.00", "100"), ("0.05", "005"), ("0.15", "015"), ("0.25", "025"), ("0.35", "035"), ("0.45", "045"), ("0.55", "055"), ("0.65", "065"), ("0.75", "075"), ("0.85", "085"), ("0.95", "095")) $twentyHalf = (("0.00", "000"), ("0.10", "010"), ("0.20", "020"), ("0.30", "030"), ("0.40", "040"), ("0.50", "050"), ("0.60", "060"), ("0.70", "070"), ("0.80", "080"), ("0.90", "090"), ("1.00", "100"), ("0.05", "005"), ("0.15", "015"), ("0.25", "025"), ("0.35", "035"), ("0.45", "045"), ("0.55", "055"), ("0.65", "065"), ("0.75", "075"), ("0.85", "085"), ("0.95", "095"))
$one = (,("0", "0")) $one = (,("0", "0"))
...@@ -28,7 +28,7 @@ $repeats = repeats(4) # full batches were all 40 (CPUs per node on IRIDIS) ...@@ -28,7 +28,7 @@ $repeats = repeats(4) # full batches were all 40 (CPUs per node on IRIDIS)
# fixed high # fixed high
. .\genSpread.ps1 "FixHigh" "FixHigh" 400000 Z r Z r $one $repeats {param($x, $y) "Z=$x targetpackage=ivmc:custom targetstring=++++++++++++++++ modulesstring=4*4 ivmcvmpos=hhhh ivmcvmmos=0000 mg=0 g0string=++++++++++++++++"} $runName 100 $commonParamFile $noGen . .\genSpread.ps1 "FixHigh" "FixHigh" 400000 Z r Z r $one $repeats {param($x, $y) "Z=$x targetpackage=ivmc:custom targetstring=++++++++++++++++ modulesstring=4*4 ivmcvmpos=hhhh ivmcvmmos=0000 mg=0 g0string=++++++++++++++++"} $runName 100 $commonParamFile $noGen
# L2 (common super-additive; Ridge) # L2 (common super-additive; Quadratic)
. .\genSpread.ps1 "LTwo" "LTwo" 400000 Z r Z r $twentyHalf $repeats {param($x, $y) "Z=$x"} $runName 100 $commonParamFile $noGen "regfunc=l2" . .\genSpread.ps1 "LTwo" "LTwo" 400000 Z r Z r $twentyHalf $repeats {param($x, $y) "Z=$x"} $runName 100 $commonParamFile $noGen "regfunc=l2"
# MMSO (somewhat arbitrary strictly sub-additive) # MMSO (somewhat arbitrary strictly sub-additive)
......
# IvmcL010Bex
. seqIvmc.ps1 Standard\Standard\StandardZ000\runsOne\r00 40000 "040k" "IvmcL010BExZ000"
. seqIvmc.ps1 Standard\Standard\StandardZ050\runsOne\r00 40000 "040k" "IvmcL010BExZ050"
. seqIvmc.ps1 Standard\Standard\StandardZ095\runsOne\r00 120000 "120k" "IvmcL010BExZ095"
. seqIvmc.ps1 Standard\Standard\StandardZ100\runsOne\r00 400000 "400k" "IvmcL010BExZ100" "400000" "1*16"
# IvmcL010Bex Fixed G
. seqIvmc.ps1 FixHigh\FixHigh\FixHighZ0\runsOne\r00 10000 "010K" "IvmcL010BExZ000FixedG" "400000" "1*16"
# IvmcL010Bex Perfect G
. seqIvmc.ps1 PerfectG\PerfectG\PerfectGZ000\runsOne\r00 10000 "010K" "IvmcL010BExZ000PerfectG" "400000" "1*16"
# 204 - NoWs, non-IRIDIS run (unknown seed)
. seqIvmc \E204\E204\E204Z050\runsOne\r00 500000 "500K" "Ivmc204L800BExZ050" "500000" "20*4"
\ No newline at end of file
param($dir, $end = 120000, $postfix = '120K', $prefix = "IvmcL010Z095", $simend = 120000, $huskyModules="4*4", $ivmcDownsample=500, $rebase=$true, $z2traceeStart = 18000, $z2traceeEnd = 22000, $traceeSeed = 3, $denseEpoch=15000) param($dir, $end = 120000, $postfix = '120K', $prefix = "IvmcL010Z095", $simend = 120000, $huskyModules="4*4", $ivmcDownsample=500, $rebase=$true, $z2traceeStart = 18000, $z2traceeEnd = 22000, $traceeSeed = 3, $denseEpoch=15000)
<# Usage notes
Generates lots of tasty figures for a particular experiment
#>
$baseSize = 0.3 $baseSize = 0.3
$baseIntervalSize = 0.5 * 0.4 / $baseSize $baseIntervalSize = 0.5 * 0.4 / $baseSize
...@@ -27,14 +22,13 @@ m4m -plot $wsFile fitness= regcoefs=l end=$end size=$baseSize intervalsizeh=$bas ...@@ -27,14 +22,13 @@ m4m -plot $wsFile fitness= regcoefs=l end=$end size=$baseSize intervalsizeh=$bas
m4m -plot $wsFile fitness= huskyness=l end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:generations=0.0E+0 title:huskyness="Module Hierarchy" legend= title= out="$dir/husky$postfix" targetlines=none downsample=50 fig=B padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad modulesstring=$huskyModules m4m -plot $wsFile fitness= huskyness=l end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:generations=0.0E+0 title:huskyness="Module Hierarchy" legend= title= out="$dir/husky$postfix" targetlines=none downsample=50 fig=B padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad modulesstring=$huskyModules
m4m -plot $wsFile fitness=ls end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:generations=0.0E+0 legend= title= out="$dir/fitness$postfix" targetlines=none downsample=50 start=0 fig=C padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad m4m -plot $wsFile fitness=ls end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:generations=0.0E+0 legend= title= out="$dir/fitness$postfix" targetlines=none downsample=50 start=0 fig=C padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad
m4m -plot "$dir\ivmcswitches_t.dat" end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:x=0.0E+0 legend= title= out="$dir/ivmcswitchness$postfix" meandownsample=$ivmcDownsample title:y="Module Switches" keep=4 plottype=scatter fig=D padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad m4m -plot "$dir\ivmcswitches_t.dat" end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:x=0.0E+0 legend= title= out="$dir/ivmcswitchness$postfix" meandownsample=$ivmcDownsample title:y="Module Switches" keep=4 plottype=scatter fig=D padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad
m4m -plot "$dir\ivmcsolves_t.dat" end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:x=0.0E+0 legend= title= out="$dir/ivmcswitchness$postfix" meandownsample=$ivmcDownsample title:y="Freq. Max-Fit. Ph." keep=4 plottype=scatter fig=C padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad
# orange line of loathing (win-freq) special case # orange line of loathing (win-freq) special case
m4m -plot "$dir\fitnessSat120000(best).dat" end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:x=0.0E+0 legend= title= out="$dir/winfreq$postfix" meandownsample=$ivmcDownsample samplescale=100 title:y="Success Frequency" keep=1 samplethreshold=0.99 plottype=scatter fig=C padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad m4m -plot "$dir\fitnessSat120000(best).dat" end=$end size=$baseSize intervalsizeh=$baseIntervalSize intervalsizev=$ybaseIntervalSize format:x=0.0E+0 legend= title= out="$dir/winfreq$postfix" meandownsample=$ivmcDownsample samplescale=100 title:y="Success Frequency" keep=1 samplethreshold=0.99 plottype=scatter fig=C padding="NaN;4;NaN;NaN" minpad=$commonPad maxpad=$commonPad
m4m -plot $wsFile epoch=$end size=$baseSize intervalsize=$baseIntervalSize legend= title= out="$dir/g$postfix" forceaspect m4m -plot $wsFile epoch=$end size=$baseSize intervalsize=$baseIntervalSize legend= title= out="$dir/g$postfix" forceaspect
# tracees (new) # tracees (new)
$traceeCentre = 24000 $traceeCentre = 24000
$traceeStart = $traceeCentre - 100 $traceeStart = $traceeCentre - 100
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment