Esempio n. 1
0
        /// <summary>
        /// Gets map data for a single genome
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        public static string mapdata(genome g)
        {
            //Initializing the file
            string data = "var genomes = new Array();\n";
            data += "var markers;\n";
            data += "markers = new Array();";
            foreach (int i in g.sequence) {
                cemetery c = cemsList[i];
                data += "markers.push({title:\"" + c.name + "\",lat:" + c.lat + ",lon:" + c.lon + ",temp:" + c.temps[i] + "});";
            }
            data += "genomes.push(markers);";

            return data;
        }
Esempio n. 2
0
 // check straight add order
 CheckConnectionOrder(genome, expectedAddOrder, currentConnections, reversed: false);
Esempio n. 3
0
function generateNetwork(genome)

    local network = { }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //Getting command line parameters
            if (args.Length > 0) {
                Program.chanceOfMutation  = Double.Parse(args[0]);
                Program.chanceOfCrossover = Double.Parse(args[1]);
                Program.totalGenerations = int.Parse(args[2]);
                reportname = "mute=" + Program.chanceOfMutation + "-cross=" + Program.chanceOfCrossover + "-runs=" + Program.totalGenerations + ".html";
            }

            //A friendly welcoming message
            Console.WriteLine("Welcome to the Cemetery Distance Calculator.  Reading the data");

            //Step 1: Reading in the data
            readData();

            //Step 2: Generate the first generation
            Console.WriteLine("Generating the most responsible parents in the world");
            List<genome> startgen = new List<genome>();
            for (int i = 0; i < generationSize; i++) {

                genome g = new genome(maxCrossoverSize);
                g.randomize();
                startgen.Add(g);

                Console.WriteLine("Travel Miles: " + g.travelDist + " | Penalty: " + g.penalty);
            }

            // ---- Start Loop ---- //

            // 3: Figure out children
            List<genome> nextGeneration = startgen;
            for (int i = 0; i < totalGenerations; i++) {

                List<genome> parents = nextGeneration;
                List<genome> children = new List<genome>();

                foreach (genome g in parents) {
                    genome childToAdd = g.getChild(chanceOfCrossover, chanceOfMutation);
                    children.Add(childToAdd);
                }

                nextGeneration = new List<genome>();
                nextGeneration = elitismTest(parents, children);

                //Keeping track of each generation for reporting purposes
                generation gen = new generation(nextGeneration);
                genealogy.Add(gen);

                if (i % 100 == 0)
                {
                    Console.WriteLine(" Generation " + i + " | Average Fitness:" + gen.avgFitness());
                    Console.WriteLine("                  Best Fitness:" + gen.bestFitness());
                }
            }
            // ---- End Loop ------ //

            //Step 4: Generate Reports
            //Generating the maps
            Console.WriteLine("Writing maps...");
            mapReport(nextGeneration);
            Console.WriteLine("Writing progress report...");
            progressReport(genealogy);

            System.Diagnostics.Process.Start(Program.reportname);
        }