public void TestLine_Unify_Reify_0() { var graph = new RelationGraph(); var a = new Var("a"); var line = new Line(a, 1, 1.0); var ls = new LineSymbol(line); graph.AddNode(ls); List<ShapeSymbol> lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); var lineSymbol = lines[0] as LineSymbol; Assert.NotNull(lineSymbol); Assert.True(lineSymbol.CachedSymbols.Count == 0); var eqGoal = new EqGoal(a, 1); // a=1 graph.AddNode(eqGoal); lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); var currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 1); var cachedLineSymbol = currLine.CachedSymbols.ToList()[0] as LineSymbol; Assert.NotNull(cachedLineSymbol); var cachedLine = cachedLineSymbol.Shape as Line; Assert.NotNull(cachedLine); Assert.True(cachedLine.A.Equals(1.0)); Assert.True(cachedLine.B.Equals(1.0)); Assert.True(cachedLine.C.Equals(1.0)); graph.DeleteNode(eqGoal); lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 0); Assert.True(currLine.CachedGoals.Count == 0); var eqGoal2 = new EqGoal(a, 3); graph.AddNode(eqGoal2); lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 1); Assert.True(currLine.CachedGoals.Count == 1); graph.DeleteNode(eqGoal2); lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 0); Assert.True(currLine.CachedGoals.Count == 0); }
public void TestLine_Unify_Reify_1() { var graph = new RelationGraph(); var a = new Var('a'); var point = new Point(2, a); var ps = new PointSymbol(point); graph.AddNode(ps); var line = new Line(1, a, 1.0); var ls = new LineSymbol(line); graph.AddNode(ls); List <ShapeSymbol> points = graph.RetrieveShapeSymbols(ShapeType.Point); Assert.True(points.Count == 1); var pt = points[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.CachedSymbols.Count == 0); var eqGoal = new EqGoal(a, 1); // a=1 graph.AddNode(eqGoal); points = graph.RetrieveShapeSymbols(ShapeType.Point); Assert.True(points.Count == 1); pt = points[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.CachedSymbols.Count == 1); var cachedPs = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(cachedPs); var cachedPt = cachedPs.Shape as Point; Assert.NotNull(cachedPt); Assert.True(cachedPt.XCoordinate.Equals(2.0)); Assert.True(cachedPt.YCoordinate.Equals(1.0)); var lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); var currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 1); var cachedLineSymbol = currLine.CachedSymbols.ToList()[0] as LineSymbol; Assert.NotNull(cachedLineSymbol); var cachedLine = cachedLineSymbol.Shape as Line; Assert.NotNull(cachedLine); Assert.True(cachedLine.A.Equals(1.0)); Assert.True(cachedLine.B.Equals(1.0)); Assert.True(cachedLine.C.Equals(1.0)); }
public void TestLine_Unify_Reify_SequenceUncertainty_0() { var graph = new RelationGraph(); var a = new Var('a'); var eqGoal = new EqGoal(a, 1); // a=1 graph.AddNode(eqGoal); var line = new Line(1, a, 1.0); var ls = new LineSymbol(line); graph.AddNode(ls); List <ShapeSymbol> lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); var currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 1); var cachedLineSymbol = currLine.CachedSymbols.ToList()[0] as LineSymbol; Assert.NotNull(cachedLineSymbol); var cachedLine = cachedLineSymbol.Shape as Line; Assert.NotNull(cachedLine); Assert.True(cachedLine.A.Equals(1.0)); Assert.True(cachedLine.B.Equals(1.0)); Assert.True(cachedLine.C.Equals(1.0)); }
public void TestPoint_Unify_Reify_0() { var graph = new RelationGraph(); //true positive var x = new Var('x'); var y = new Var('y'); var point = new Point(x, y); var ps = new PointSymbol(point); graph.AddNode(ps); Assert.True(graph.Nodes.Count == 1); /* * * Current Status: * * (x,y) * * next input: * * x=1 */ var eqGoal = new EqGoal(x, 1); // x=1 graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 2); List <ShapeSymbol> shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); var pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 1); Assert.True(pt.CachedSymbols.Count == 1); var gPointSymbol = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(gPointSymbol); var gPoint = gPointSymbol.Shape as Point; Assert.NotNull(gPoint); Assert.False(gPoint.Concrete); Assert.True(1.0.Equals(gPoint.XCoordinate)); Assert.True(y.Equals(gPoint.YCoordinate)); /****** * current status: * (1,y) * * next input: * x = 2 ****/ #region Block 2 var eqGoal1 = new EqGoal(x, 2); // x=2 graph.AddNode(eqGoal1); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 2); Assert.True(pt.CachedSymbols.Count == 2); Assert.False(point.Concrete); #endregion /****** * current status: * (1,y) * (2,y) * * next input: * y = 1 ****/ #region Block 3 var eqGoal2 = new EqGoal(y, 1); // y = 1 graph.AddNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.False(point.Concrete); Assert.True(ps.CachedGoals.Count == 3); Assert.True(ps.CachedSymbols.Count == 2); foreach (var ss in ps.CachedSymbols) { Assert.True(ss.Shape.Concrete); } var goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /****** * current status: * (1,1) * (2,1) * * next input: * y = 2 ****/ #region Block 4 var eqGoal3 = new EqGoal(y, 2); // y = 2 graph.AddNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); ps = shapes[0] as PointSymbol; Assert.NotNull(ps); Assert.False(ps.Shape.Concrete); Assert.True(ps.CachedGoals.Count == 4); Assert.True(ps.CachedSymbols.Count == 4); foreach (var css in ps.CachedSymbols) { Assert.True(css.Shape.Concrete); } #endregion /* * current status: * (1,1), (2,1), (1,2), (2,2) * * next input: * delete y = 2 * */ #region Block 5 graph.DeleteNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); foreach (var ss in pt.CachedSymbols) { Assert.True(ss.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /* * current status: * (1,1), (2,1) * * next input: * delete y = 1 * */ #region Block 6 graph.DeleteNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); #endregion /* foreach (var shape in pt.CachedSymbols) * { * Assert.False(shape.Shape.Concrete); * } * goals = graph.RetrieveGoals(); * Assert.True(goals.Count == 2); * * * ///////////////////////////////////////////// * * graph.DeleteNode(ps); * shapes = graph.RetrieveShapeSymbols(); * Assert.True(shapes.Count == 0);*/ }
public void TestLine_Unify_Reify_1() { var graph = new RelationGraph(); var a = new Var('a'); var point = new Point(2, a); var ps = new PointSymbol(point); graph.AddNode(ps); var line = new Line(1, a, 1.0); var ls = new LineSymbol(line); graph.AddNode(ls); List<ShapeSymbol> points = graph.RetrieveShapeSymbols(ShapeType.Point); Assert.True(points.Count == 1); var pt = points[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.CachedSymbols.Count == 0); var eqGoal = new EqGoal(a, 1); // a=1 graph.AddNode(eqGoal); points = graph.RetrieveShapeSymbols(ShapeType.Point); Assert.True(points.Count == 1); pt = points[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.CachedSymbols.Count == 1); var cachedPs = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(cachedPs); var cachedPt = cachedPs.Shape as Point; Assert.NotNull(cachedPt); Assert.True(cachedPt.XCoordinate.Equals(2.0)); Assert.True(cachedPt.YCoordinate.Equals(1.0)); var lines = graph.RetrieveShapeSymbols(ShapeType.Line); Assert.True(lines.Count == 1); var currLine = lines[0] as LineSymbol; Assert.NotNull(currLine); Assert.True(currLine.CachedSymbols.Count == 1); var cachedLineSymbol = currLine.CachedSymbols.ToList()[0] as LineSymbol; Assert.NotNull(cachedLineSymbol); var cachedLine = cachedLineSymbol.Shape as Line; Assert.NotNull(cachedLine); Assert.True(cachedLine.A.Equals(1.0)); Assert.True(cachedLine.B.Equals(1.0)); Assert.True(cachedLine.C.Equals(1.0)); }
public void TestPoint_Unify_Reify_0() { var graph = new RelationGraph(); //true positive var x = new Var('x'); var y = new Var('y'); var point = new Point(x, y); var ps = new PointSymbol(point); graph.AddNode(ps); Assert.True(graph.Nodes.Count == 1); /* * * Current Status: * * (x,y) * * next input: * * x=1 */ var eqGoal = new EqGoal(x, 1); // x=1 graph.AddNode(eqGoal); Assert.True(graph.Nodes.Count == 2); List<ShapeSymbol> shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); var pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 1); Assert.True(pt.CachedSymbols.Count == 1); var gPointSymbol = pt.CachedSymbols.ToList()[0] as PointSymbol; Assert.NotNull(gPointSymbol); var gPoint = gPointSymbol.Shape as Point; Assert.NotNull(gPoint); Assert.False(gPoint.Concrete); Assert.True(1.0.Equals(gPoint.XCoordinate)); Assert.True(y.Equals(gPoint.YCoordinate)); /****** * current status: * (1,y) * * next input: * x = 2 ****/ #region Block 2 var eqGoal1 = new EqGoal(x, 2); // x=2 graph.AddNode(eqGoal1); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.True(pt.Equals(ps)); Assert.True(pt.CachedGoals.Count == 2); Assert.True(pt.CachedSymbols.Count == 2); Assert.False(point.Concrete); #endregion /****** * current status: * (1,y) * (2,y) * * next input: * y = 1 ****/ #region Block 3 var eqGoal2 = new EqGoal(y, 1); // y = 1 graph.AddNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.False(point.Concrete); Assert.True(ps.CachedGoals.Count == 3); Assert.True(ps.CachedSymbols.Count == 2); foreach (var ss in ps.CachedSymbols) { Assert.True(ss.Shape.Concrete); } var goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /****** * current status: * (1,1) * (2,1) * * next input: * y = 2 ****/ #region Block 4 var eqGoal3 = new EqGoal(y, 2); // y = 2 graph.AddNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); ps = shapes[0] as PointSymbol; Assert.NotNull(ps); Assert.False(ps.Shape.Concrete); Assert.True(ps.CachedGoals.Count == 4); Assert.True(ps.CachedSymbols.Count == 4); foreach (var css in ps.CachedSymbols) { Assert.True(css.Shape.Concrete); } #endregion /* * current status: * (1,1), (2,1), (1,2), (2,2) * * next input: * delete y = 2 * */ #region Block 5 graph.DeleteNode(eqGoal3); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); foreach (var ss in pt.CachedSymbols) { Assert.True(ss.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 3); #endregion /* * current status: * (1,1), (2,1) * * next input: * delete y = 1 * */ #region Block 6 graph.DeleteNode(eqGoal2); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 1); pt = shapes[0] as PointSymbol; Assert.NotNull(pt); Assert.False(pt.Shape.Concrete); Assert.True(pt.CachedGoals.Count == 3); Assert.True(pt.CachedSymbols.Count == 2); #endregion /* foreach (var shape in pt.CachedSymbols) { Assert.False(shape.Shape.Concrete); } goals = graph.RetrieveGoals(); Assert.True(goals.Count == 2); ///////////////////////////////////////////// graph.DeleteNode(ps); shapes = graph.RetrieveShapeSymbols(); Assert.True(shapes.Count == 0);*/ }