/// <summary> /// Changes the level of the provided skill, updating the results /// </summary> /// <param name="skill"></param> /// <param name="level"></param> /// <param name="updateSP"></param> /// <param name="includePrerequsites"></param> public void SetSkillLevel(StaticSkill skill, int level, LearningOptions options) { int index = skill.ArrayIndex; // May quit for if this level is alread equal (or greater, depending on the options) if ((options & LearningOptions.UpgradeOnly) != LearningOptions.None) { if (m_skillLevels[index] >= level) { return; } } else { if (m_skillLevels[index] == level) { return; } } // Update prerequisites if ((options & LearningOptions.IgnorePrereqs) == LearningOptions.None) { foreach (var prereq in skill.Prerequisites) { // Deal with recursive prereqs (like Polaris) if (prereq.Skill == skill) { continue; } // Set the prereq's level SetSkillLevel(prereq.Skill, prereq.Level, options | LearningOptions.UpgradeOnly); } } // Update training time if ((options & LearningOptions.IgnoreTraining) == LearningOptions.None) { m_trainingTime += this.GetTrainingTime(skill, level, TrainingOrigin.FromCurrent); m_trainedSkills.Add(new StaticSkillLevel(skill, level)); } // Update skillpoints if ((options & LearningOptions.FreezeSP) == LearningOptions.None) { UpdateSP(skill, level); } // Apply learning bonuses ApplyEffects(skill, level); // Updates the skill level m_skillLevels[index] = level; }
/// <summary> /// Changes the level of the provided skill, updating the results. /// </summary> /// <param name="skill">The skill.</param> /// <param name="level">The level.</param> /// <param name="options">The options.</param> private void SetSkillLevel(StaticSkill skill, long level, LearningOptions options = LearningOptions.None) { int index = skill.ArrayIndex; if (index > m_skillLevels.Length) { return; } // May quit for if this level is alread equal (or greater, depending on the options) if ((options & LearningOptions.UpgradeOnly) != LearningOptions.None) { if (m_skillLevels[index] >= level) { return; } } else { if (m_skillLevels[index] == level) { return; } } // Update prerequisites if ((options & LearningOptions.IgnorePrereqs) == LearningOptions.None) { // Deal with recursive prereqs (like Polaris) foreach (StaticSkillLevel prereq in skill.Prerequisites.Where(prereq => prereq.Skill != skill)) { // Set the prereq's level SetSkillLevel(prereq.Skill, prereq.Level, options | LearningOptions.UpgradeOnly); } } // Update training time if ((options & LearningOptions.IgnoreTraining) == LearningOptions.None) { TrainingTime += GetTrainingTime(skill, level); TrainedSkills.Add(new StaticSkillLevel(skill, level)); } // Update skillpoints if ((options & LearningOptions.FreezeSP) == LearningOptions.None) { UpdateSP(skill, level); } // Updates the skill level m_skillLevels[index] = level; }
private void xButtonLearn_Click(object sender, RoutedEventArgs e) { var trainingSet = _trainingSet; if (trainingSet == null) { return; } LearningOptions options = new LearningOptions(); // Prior options.DistributionDirichletAlpha = _dirichletAlpha; // Structure if (xRadStructureDisconnected.IsChecked == true) { options.Structure = LearningOptions.StructureEnum.DisconnectedStructure; } else if (xRadStructureRandom.IsChecked == true) { options.Structure = LearningOptions.StructureEnum.RandomStructure; options.StructureSeed = (int) DateTime.UtcNow .Subtract(DateTime.UtcNow.Date) .TotalMilliseconds; } else if (xRadStructureTree.IsChecked == true) { options.Structure = LearningOptions.StructureEnum.TreeStructure; } else if (xRadStructureGeneral.IsChecked == true) { options.Structure = LearningOptions.StructureEnum.GeneralStructure; } else { return; } // Parent limit options.StructureParentLimit = _parentLimit; App.Current.MainWindow.RequestTraining(trainingSet, options); }
private static void SimpleApi() { // The pattern of the simple API is: // => Learn(input, options, override_params) // => Learn[Csv|Fw](input, options, override_params) // --- // In the first case the type of program (CSV/FW) is automatically learned, while in the second case // it is specificed by the method called. The parameters to the functions are: // - input, which can be a string or a buffer (TextReader), specifies the text file to learn a program from // - (optional) options (LearningOptions) specify various options for learning // - (optional) override_params allow to override some of the learned program parameters, // and in that case the overridden parameter is not learned, but the provided value is used // (e.g., delimiter can be overriden; see the example below). // I. Learn CSV or FW program Program prog1 = ReadFlatFileLearner.Learn(CsvSampleInput); PrintProgramProperties(prog1); PrintProgramOutput(prog1, CsvSampleInput); // II. Learn FW program (learn on a buffer instead of a string) // Note: We override the number of lines to use for learning (the default was 200) // and specify the learning timeout. var options = new LearningOptions { TimeLimit = TimeSpan.FromSeconds(10), LinesToLearn = 30 }; FwProgram prog2; using (var reader = new StringReader(FwSampleInput)) { prog2 = ReadFlatFileLearner.LearnFw(reader, options); PrintProgramProperties(prog2); } using (var reader = new StringReader(FwSampleInput)) { PrintProgramOutput(prog2, reader); } // III. Learn CSV program with manually set delimiter CsvProgram prog3 = ReadFlatFileLearner.LearnCsv(CsvOverrideSampleInput, delimiter: ";"); PrintProgramProperties(prog3); PrintProgramOutput(prog3, CsvOverrideSampleInput); }
internal void RequestTraining(IObservationSet trainingSet, LearningOptions options) { if (trainingSet == null) { throw new ArgumentNullException(); } ILearningTask learningTask = new LearningTask( Guid.NewGuid().ToString(), trainingSet, options); learningTask.BayesianNetworkStarted += OnLearningStarted; learningTask.BayesianNetworkFinished += OnLearningFinished; Model.LearningTasks.Clear(); Model.LearningTasks.Add(learningTask); xLearningInspector.SetIsLearning(true); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //л┤ие var leaningOptions = new LearningOptions(); Configuration.GetSection("Learning").Bind(leaningOptions); //л┤ие2 leaningOptions = Configuration.GetSection("Learning").Get <LearningOptions>(); //л┤ие3 services.Configure <LearningOptions>(Configuration.GetSection("Learning")); //л┤ие6 services.Configure <AppInfoOptions>(Configuration.GetSection("App")); services.Configure <ThemeOptions>("DarkTheme", Configuration.GetSection("Themes:Dark")); services.Configure <ThemeOptions>("WhiteTheme", Configuration.GetSection("Themes:White")); services.AddControllers(); }