Ejemplo n.º 1
0
        public static SimData ScoreStates(bool ground_truth, State A, State B)
        {
            Stopwatch s = new Stopwatch();

            s.Start();
            ProgramNode program = Synthesizer.Learn(1, A, B);

            s.Stop();
            Synthesizer.Engine.ClearLearningCache();

            return(new SimData {
                A = Synthesizer.StateToString(A),
                B = Synthesizer.StateToString(B),
                GroundTruth = ground_truth,
                SynthesisTime = Convert.ToUInt32(s.ElapsedMilliseconds),
                Pattern = (program == null ? "<NULL>" : program.AcceptVisitor(new TokensCollector()).CombinedDescription()),
                Cost = Convert.ToSingle(program == null ? -DefaultTokens.Any.Score
                                                        : -program.GetFeatureValue(Learner.Instance.ScoreFeature)),
                Score = Convert.ToSingle(1.0 / (program == null ? Witnesses.ScoreTransform(-DefaultTokens.Any.Score)
                                                                : Witnesses.ScoreTransform(-program.GetFeatureValue(Learner.Instance.ScoreFeature))))
            });
        }
Ejemplo n.º 2
0
 public static string Description(this ProgramNode node)
 => node.AcceptVisitor(new TokensCollector()).Describe();