Beispiel #1
0
        public virtual void reverse()
        {
            FileSystemDataLoader loader = new FileSystemDataLoader(reverseValue);
            MainAppData          data   = loader.createRobotData(output);

            reverseData(data);
        }
        private Engine wireEngine(MainSettings mainSettings, MainAppData data, RobotKiller killer, RobotBreeder breeder, Population population)
        {
            EngineSettings    engineSettings    = getEngineSettings(mainSettings);
            TimePointExecutor timePointExecutor = wireTimePointExecutor(mainSettings);

            return(EngineFactory.getDefaultEngine(engineSettings, data, timePointExecutor, killer, breeder, population));
        }
Beispiel #3
0
        public override MainSettings getSettings(UserOutput output)
        {
            ISet <string> parsedKeys = new HashSet <string>();

            try
            {
                IDictionary <string, string> map = buildFileMap();
                MainSettings settings            = MainSettings.Settings;
                MainAppData  data = createData(map, parsedKeys, output);
                settings.startTimePoint = data.FirstTimePoint;
                settings.endTimePoint   = data.LastTimePoint;
                settings.dataSettings   = getDataDir(map, parsedKeys);
                applySettingsFromMap(settings, map, parsedKeys);
                checkAllSettingsParsed(map, parsedKeys);
                return(settings);
            }
            catch (IOException e)
            {
                throw new Exception("Unable to read file " + fileName, e);
            }
            catch (IllegalAccessException e)
            {
                throw new Exception(e);
            }
        }
Beispiel #4
0
        public void Initialize(MainAppData mainAppData)
        {
            MainAppData = mainAppData;

            BackupSelectedMenuData = new MenuData("Default.BackupSelected")
            {
                Header       = "Backup Selected Projects",
                ClickCommand = new ActionCommand(() => { BackupSelectedProjects(); }),
                IsEnabled    = false
            };

            BackupSelectedToMenuData = new MenuData("Default.BackupSelectedTo")
            {
                Header       = "Backup Selected Projects To...",
                ClickCommand = new ActionCommand(BackupSelectedProjectsTo),
                IsEnabled    = false
            };

            StartGitGenerationMenuData = new MenuData("Default.StartGitGenerator")
            {
                Header       = "Start Git Generator...",
                ClickCommand = new ActionCommand(OpenGitGeneratorWindow),
                IsEnabled    = false
            };

            MainAppData.MenuBarData.File.Register(Data.ModuleName,
                                                  new SeparatorData(),
                                                  BackupSelectedMenuData,
                                                  BackupSelectedToMenuData,
                                                  StartGitGenerationMenuData
                                                  );
        }
 public virtual void setSettings(EngineSettings engineSettings, TimePointExecutor timePointExecutor, MainAppData data, RobotKiller killer, RobotBreeder breeder, Population population)
 {
     this.engineSettings    = engineSettings;
     this.timePointExecutor = timePointExecutor;
     this.killer            = killer;
     this.breeder           = breeder;
     this.population        = population;
     this.data = data;
 }
Beispiel #6
0
        private void assignTimePoints(MainSettings defaults, MainAppData data)
        {
            TimePoint first = data.FirstTimePoint;
            TimePoint last  = data.LastTimePoint;
            long      diff  = last.Value - first.Value;
            long      count = Math.Abs(r.nextLong() % diff);

            defaults.startTimePoint = new TimePoint(last.Value - count);
            defaults.endTimePoint   = last;
        }
Beispiel #7
0
        public override MainSettings getSettings(UserOutput output)
        {
            MainSettings defaults = MainSettings.Settings;

            defaults.populationDAO            = "";
            defaults.requireSymmetricalRobots = true;
            defaults.killNonPredictingRobots  = true;
            defaults.performTraining          = true;
            MainAppData data = getData(Main.DEFAULT_DATA_DIR, output);

            assignTimePoints(defaults, data);
            return(assignRandom(defaults));
        }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unused") public static com.alphatica.genotick.data.MainAppData reverse(com.alphatica.genotick.data.MainAppData data)
        public static MainAppData reverse(MainAppData data)
        {
            MainAppData reversedData = new MainAppData();

            foreach (DataSet set in data.listSets())
            {
                IList <Number []> originalNumbers = getOriginalNumbers(set);
                IList <Number []> reversedNumbers = reverseList(originalNumbers);
                string            reverseName     = getReverseFileName(set.Name);
                DataSet           reversedSet     = new DataSet(reversedNumbers, reverseName);
                reversedData.addDataSet(reversedSet);
            }
            return(reversedData);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("WeakerAccess") public void validateTimePoints(com.alphatica.genotick.data.MainAppData data)
        public virtual void validateTimePoints(MainAppData data)
        {
            TimePoint first = data.FirstTimePoint;
            TimePoint last  = data.LastTimePoint;

            if (startTimePoint.CompareTo(first) < 0)
            {
                startTimePoint = first;
            }
            if (endTimePoint.CompareTo(last) > 0)
            {
                endTimePoint = last;
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void checkSimulation(com.alphatica.genotick.ui.Parameters parameters) throws IllegalAccessException
        private static void checkSimulation(Parameters parameters)
        {
            if (!parameters.allConsumed())
            {
                output.errorMessage("Not all arguments processed: " + parameters.Unconsumed);
                exit(errorCodes.UNKNOWN_ARGUMENT);
            }
            Simulation simulation = new Simulation(output);

            input.Simulation = simulation;
            MainSettings settings = input.getSettings(output);
            MainAppData  data     = input.getData(settings.dataSettings, output);

            settings.validateTimePoints(data);
            simulation.start(settings, data);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("UnusedReturnValue") public java.util.List<com.alphatica.genotick.timepoint.TimePointStats> start(MainSettings mainSettings, com.alphatica.genotick.data.MainAppData data) throws IllegalAccessException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual IList <TimePointStats> start(MainSettings mainSettings, MainAppData data)
        {
            if (!validateSettings(mainSettings))
            {
                return(null);
            }
            logSettings(mainSettings);
            RobotKiller  killer  = getRobotKiller(mainSettings);
            Mutator      mutator = getMutator(mainSettings);
            RobotBreeder breeder = wireBreeder(mainSettings, mutator);

            population = wirePopulation(mainSettings);
            Engine engine = wireEngine(mainSettings, data, killer, breeder, population);
            IList <TimePointStats> results = engine.start(output);

            showSummary(results);
            return(results);
        }
Beispiel #12
0
        public void Initialize(MainAppData mainAppData)
        {
            MainAppData = mainAppData;

            BackupSelectedMenuData = new MenuData("DOS2.BackupSelected")
            {
                Header       = "Backup Selected Projects",
                ClickCommand = new ActionCommand(() => { BackupSelectedProjects(); }),
                IsEnabled    = false
            };

            BackupSelectedToMenuData = new MenuData("DOS2.BackupSelectedTo")
            {
                Header       = "Backup Selected Projects To...",
                ClickCommand = new ActionCommand(BackupSelectedProjectsTo),
                IsEnabled    = false
            };

            StartGitGenerationMenuData = new MenuData("DOS2.StartGitGenerator")
            {
                Header       = "Start Git Generator...",
                ClickCommand = new ActionCommand(OpenGitGeneratorWindow),
                IsEnabled    = false
            };

            MainAppData.MenuBarData.File.Register(Data.ModuleName,
                                                  new SeparatorData(),
                                                  new MenuData("DOS2.RefreshProjects")
            {
                Header    = "Refresh Projects",
                MenuItems = new ObservableCollectionExtended <IMenuData>()
                {
                    new MenuData("DOS2.RefreshAll", "Refresh All", new ActionCommand(RefreshAllProjects), System.Windows.Input.Key.F5),
                    new MenuData("DOS2.RefreshManagedData", "Refresh Managed Data", new ActionCommand(RefreshModProjects)),
                }
            },
                                                  new SeparatorData(),
                                                  BackupSelectedMenuData,
                                                  BackupSelectedToMenuData,
                                                  StartGitGenerationMenuData
                                                  );
        }
        public override MainSettings getSettings(UserOutput output)
        {
            string       dataDirectory = getString("Data directory", Main.DEFAULT_DATA_DIR);
            MainAppData  data          = getData(dataDirectory, output);
            MainSettings settings      = MainSettings.Settings;

            settings.dataSettings              = dataDirectory;
            settings.performTraining           = getBoolean("Perform training", settings.performTraining);
            settings.startTimePoint            = new TimePoint(getLong("Start time point", data.FirstTimePoint.Value));
            settings.endTimePoint              = new TimePoint(getLong("End time point", data.LastTimePoint.Value));
            settings.populationDAO             = getString("Population storage", settings.populationDAO);
            settings.processorInstructionLimit = getInteger("Processor instruction limit", settings.processorInstructionLimit);
            settings.resultThreshold           = getDouble("Result threshold", settings.resultThreshold);
            if (settings.performTraining)
            {
                settings.dataMaximumOffset          = getInteger("Data maximum offset", settings.dataMaximumOffset);
                settings.populationDesiredSize      = getInteger("Population desired size", settings.populationDesiredSize);
                settings.maximumDeathByAge          = getDouble("Maximum death rate by age", settings.maximumDeathByAge);
                settings.maximumDeathByWeight       = getDouble("Maximum death rate by weight", settings.maximumDeathByWeight);
                settings.probabilityOfDeathByAge    = getDouble("Probability of death by age", settings.probabilityOfDeathByAge);
                settings.probabilityOfDeathByWeight = getDouble("Probability of death by weight", settings.probabilityOfDeathByWeight);
                settings.inheritedChildWeight       = getDouble("Inherited child's weight", settings.inheritedChildWeight);
                settings.protectRobotsUntilOutcomes = getInteger("Protect robots until outcomes", settings.protectRobotsUntilOutcomes);
                settings.newInstructionProbability  = getDouble("Probability of new instruction", settings.newInstructionProbability);
                // This looks like an error but it's not. Default value for 'skipInstruction...' is same as 'newInstruction'
                // to keep robots more or less constant size.
                settings.skipInstructionProbability     = getDouble("Probability of skipping instruction", settings.newInstructionProbability);
                settings.instructionMutationProbability = getDouble("Instruction mutation probability", settings.instructionMutationProbability);
                settings.minimumOutcomesToAllowBreeding = getLong("Minimum outcomes to allow breeding", settings.minimumOutcomesToAllowBreeding);
                settings.minimumOutcomesBetweenBreeding = getLong("Minimum outcomes between breeding", settings.minimumOutcomesBetweenBreeding);
                settings.killNonPredictingRobots        = getBoolean("Kill non-predicting robots", settings.killNonPredictingRobots);
                settings.randomRobotsAtEachUpdate       = getDouble("Random robots at each update", settings.randomRobotsAtEachUpdate);
                settings.protectBestRobots        = getDouble("Protect best robots", settings.protectBestRobots);
                settings.requireSymmetricalRobots = getBoolean("Require symmetrical robots", settings.requireSymmetricalRobots);
                settings.ignoreColumns            = getInteger("Ignore columns for training", settings.ignoreColumns);
            }
            return(settings);
        }
        public AppController(MainWindow MainAppWindow)
        {
            _instance       = this;
            Log.AllCallback = AddLogMessage;

            Data = new MainAppData();

            Data.SaveKeywordsCommand   = new ActionCommand(SaveKeywords);
            Data.SaveKeywordsAsCommand = new ActionCommand(SaveKeywordsAs);

            ProjectControllers = new Dictionary <string, IProjectController>();

            OpenGitWebsiteCommand = new ActionCommand(() => { Helpers.Web.OpenUri("https://git-scm.com/downloads"); });

            SetSetupFoldersToMyDocumentsCommand = new ActionCommand(SwitchSettingsFoldersToMyDocuments);
            SetSetupFoldersToRelativeCommand    = new ActionCommand(MakeSettingsFolderPortable);

            OpenProjectReadmeInMarkdownConverterCommand = new ParameterCommand(OpenProjectReadmeInMarkdownConverter);

            mainWindow = MainAppWindow;

            Data.Portable = File.Exists(DefaultPaths.PortableSettingsFile);

            if (Data.Portable)
            {
                DefaultPaths.RootFolder = DefaultPaths.DefaultPortableRootFolder;
            }
            else
            {
                var myDocumentsRoot = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                if (Directory.Exists(myDocumentsRoot))
                {
                    DefaultPaths.RootFolder = Path.Combine(myDocumentsRoot, DefaultPaths.DefaultMyDocumentsRootFolder);
                }
            }

            InitDefaultMenus();
        }
Beispiel #15
0
        public static string GenerateTemplateFile(string defaultText, string filePath, IProjectData projectData, MainAppData mainAppData, IModuleData moduleData)
        {
            if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
            {
                defaultText = File.ReadAllText(filePath);
            }

            defaultText = ReplaceKeywords(defaultText, projectData, mainAppData, moduleData);

            return(defaultText);
        }
Beispiel #16
0
        public static string ReplaceKeywords(string sourceText, IProjectData projectData, MainAppData mainAppData, IModuleData moduleData)
        {
            string replacedText = sourceText;

            if (mainAppData != null)
            {
                if (projectData == null)
                {
                    Log.Here().Error($"Error replacing keywords for module {moduleData.ModuleName}: projectData is null.");

                    return(replacedText);
                }

                if (mainAppData.DateKeyList != null)
                {
                    //Reverse so $Date is replace after all the other variations
                    var keywords = mainAppData.DateKeyList.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName)).Reverse();
                    foreach (var keywordData in keywords)
                    {
                        replacedText = keywordData.ReplaceText(replacedText, projectData);
                    }

                    /*
                     * var tasks = mainAppData.DateKeyList.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName)).Reverse().Select(keywordData => Task.Run(() =>
                     * {
                     *      replacedText = keywordData.ReplaceText(replacedText, projectData);
                     * }));
                     *
                     * await Task.WhenAll(tasks);
                     */
                }
                else
                {
                    Log.Here().Error($"Error parsing DateKeyList for module {moduleData.ModuleName}: DateKeyList is null.");
                }

                if (mainAppData.AppKeyList != null)
                {
                    var keywords = mainAppData.AppKeyList.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName));
                    foreach (var keywordData in keywords)
                    {
                        replacedText = keywordData.ReplaceText(replacedText, projectData);
                    }

                    /*
                     * var tasks = mainAppData.AppKeyList.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName)).Select(keywordData => Task.Run(() =>
                     * {
                     *      Log.Here().Activity($"Replacing {keywordData.KeywordName} with {keywordData.KeywordValue}");
                     *      replacedText = keywordData.ReplaceText(replacedText, projectData);
                     * }));
                     *
                     * await Task.WhenAll(tasks);
                     */
                }
                else
                {
                    Log.Here().Error($"Error parsing DateKeyList for module {moduleData.ModuleName}: DateKeyList is null.");
                }

                if (moduleData.UserKeywords != null && moduleData.UserKeywords.Keywords != null)
                {
                    var keywords = moduleData.UserKeywords.Keywords.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName));
                    foreach (var keywordData in keywords)
                    {
                        replacedText = keywordData.ReplaceText(replacedText, projectData);
                    }

                    /*
                     * var tasks = moduleData.UserKeywords.Keywords.Where(keywordData => KeywordIsValid(keywordData) && replacedText.Contains(keywordData.KeywordName)).Select(keywordData => Task.Run(() =>
                     * {
                     *      replacedText = keywordData.ReplaceText(replacedText, projectData);
                     * }));
                     *
                     * await Task.WhenAll(tasks);
                     */
                }
                else
                {
                    Log.Here().Error($"Error parsing user keywords for module {moduleData.ModuleName}: UserKeywords is null.");
                }

                if (moduleData.UserKeywords != null && !String.IsNullOrEmpty(moduleData.UserKeywords.DateCustom) && replacedText.Contains("$DateCustom"))
                {
                    replacedText = replacedText.Replace("$DateCustom", DateTime.Now.ToString(moduleData.UserKeywords.DateCustom));
                }
            }

            return(replacedText);
        }
Beispiel #17
0
 private void reverseData(MainAppData data)
 {
     data.listSets().forEach(this.reverseSet);
 }