public override void RetrieveRenderKnowledge() { if (_query.CachedEntities.Count == 0) { return; } var lst = new ObservableCollection <IKnowledge>(); foreach (var cacheObj in _query.CachedEntities) { var cacheShapeSymbol = cacheObj as ShapeSymbol; var cacheGoal = cacheObj as EqGoal; var cacheEq = cacheObj as Equation; if (cacheShapeSymbol != null) { starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheShapeSymbol); var agShape = new AGShapeExpr(expr, cacheShapeSymbol); lst.Add(agShape); } else if (cacheGoal != null) { starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheGoal); var agGoal = new AGPropertyExpr(expr, cacheGoal); lst.Add(agGoal); } else if (cacheEq != null) { starPadSDK.MathExpr.Expr expr = ExprG.Generate(cacheEq); var agEq = new AGEquationExpr(expr, cacheEq); lst.Add(agEq); } } RenderKnowledge = lst; }
/// <summary> /// Goal Input Patter Match /// </summary> /// <param name="expr"></param> /// <param name="goal"></param> /// <param name="output"></param> /// <param name="userInput"></param> /// <returns></returns> private bool EvalExprPatterns(Expr expr, EqGoal goal, out object output, bool userInput = false) { object obj = null; if (!userInput) { obj = RelationGraph.AddNode(goal); } output = new AGPropertyExpr(expr, goal); return(true); }
/// <summary> /// Goal Input Patter Match /// </summary> /// <param name="expr"></param> /// <param name="goal"></param> /// <param name="output"></param> /// <param name="userInput"></param> /// <returns></returns> private bool EvalExprPatterns(Expr expr, EqGoal goal, out object output, bool userInput = false) { object obj = null; if (!userInput) { obj = RelationGraph.AddNode(goal); } output = new AGPropertyExpr(expr, goal); return true; }
private bool GoalVerify(IKnowledge obj, EqGoal eqGoal, out string msg, out object output) { msg = AGTutorMessage.VerifyWrong; output = null; List<Tuple<object, object>> trace = null; var agPropExpr = new AGPropertyExpr(obj.Expr, eqGoal); agPropExpr.IsSelected = true; agPropExpr.GenerateSolvingTrace(); trace = agPropExpr.AutoTrace; BehaviorGraphNode node; if (trace == null || trace.Count == 0) { node = UserGraph.UpdateSolvingCache(agPropExpr); //node = UserGraph.SearchInnerLoopNode(eqGoal); if (node == null) return false; } if (trace != null) { bool matchResult = UserGraph.Match(trace); if (!matchResult) return false; //insert nodes UserGraph.Insert(trace); CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode; } else { CurrentStateNode = UserGraph.SearchInnerLoopNode(eqGoal); } /* var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode); if (nextTuple1 == null) // query-end { msg = AGTutorMessage.SolvedProblem; return true; } */ msg = AGTutorMessage.VerifyCorrect; return true; }