示例#1
0
        public ResponseModel(RequestModel reqModel)
        {
            MethodType = reqModel.MethodType;
            Goal       = reqModel.Goal;
            Facts      = new List <char>(reqModel.Facts);
            Nodes      = new List <Node>(reqModel.Nodes);
            Rules      = new List <Rule>();
            Production = new List <Rule>();
            Trace      = new List <TraceElement>();

            var reqModelTempRules = reqModel.Rules;

            //Normalize rules if backward method
            if (MethodType.ToLower() == "backward")
            {
                var ruleWithGoal = reqModelTempRules.FirstOrDefault(x => x.RightSide == reqModel.Goal);
                if (ruleWithGoal != null)
                {
                    var indexOfRuleWithGoal = reqModelTempRules.IndexOf(ruleWithGoal);
                    var rules     = reqModel.Rules;
                    var firstRule = rules[0];
                    rules[0] = ruleWithGoal;
                    rules[indexOfRuleWithGoal] = firstRule;
                    reqModelTempRules          = rules;
                }

                Rules.AddRange(reqModelTempRules);
            }
            else
            {
                Rules.AddRange(reqModel.Rules);
            }
        }
示例#2
0
        public void GenerateIterationsFromTrace()
        {
            if (MethodType.ToLower() == "forward")
            {
                var groups = Trace.GroupBy(x => x.IterationNumber, (key, g) => new Iteration()
                {
                    Trace  = g.ToList(),
                    Number = key
                });

                FCTrace = groups.ToList();
                Trace   = new List <TraceElement>();
            }
        }