private ProgramSet LearnImpl <TFeatureValue>(IEnumerable <Constraint <MergeConflict, IReadOnlyList <Node> > > constraints, Feature <TFeatureValue> feature, int?k, int?numRandomProgramsToInclude, ProgramSamplingStrategy samplingStrategy, CancellationToken cancel = default) { Grammar grammar = LanguageGrammar.Instance.Grammar; Dictionary <State, object> examples = constraints.OfType <Example <MergeConflict, IReadOnlyList <Node> > >() .ToDictionary( e => State.CreateForLearning(grammar.InputSymbol, e.Input), e => (object)e.Output); var spec = new ExampleSpec(examples); var witnesses = new WitnessFunctions(grammar); var engine = new SynthesisEngine( grammar, new SynthesisEngine.Config { Strategies = new ISynthesisStrategy[] { new DeductiveSynthesis(witnesses) }, UseThreads = false }); LearningTask task = k.HasValue ? LearningTask.Create(grammar.StartSymbol, spec, numRandomProgramsToInclude, samplingStrategy, k.Value, feature) : new LearningTask(grammar.StartSymbol, spec); ProgramSet set = engine.Learn(task, cancel); engine.Configuration.LogListener?.SaveLogToXML("log.xml"); if (k.HasValue) { return(set.Prune(k.Value, numRandomProgramsToInclude, feature, null, task.FeatureCalculationContext, samplingStrategy, engine.RandomNumberGenerator, engine.Configuration.LogListener)); } return(set); }