public PartitionedProblemSpace(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, QueryFeatureVector query) { graph = g; partitions = new List <ProblemEquivalenceClass>(); this.query = query; totalProblems = 0; }
public string ConstructProblemAndSolution(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph) { // Sort the givens and path for ease in readability; they are reverse-sorted TopologicalSortProblem(); StringBuilder str = new StringBuilder(); str.AppendLine("Source: "); for (int g = givens.Count - 1; g >= 0; g--) { str.AppendLine("\t (" + givens[g] + ")" + graph.GetNode(givens[g]).ToString()); } str.AppendLine("Suppressed Source: "); foreach (int s in suppressedGivens) { str.AppendLine("\t (" + s + ")" + graph.GetNode(s).ToString()); } str.AppendLine("HyperEdges:"); foreach (PebblerHyperEdge <A> edge in edges) { str.AppendLine("\t" + edge.ToString() + "\t" + edge.annotation.ToString()); } str.AppendLine(" Path:"); for (int p = path.Count - 1; p >= 0; p--) { str.AppendLine("\t (" + path[p] + ")" + graph.GetNode(path[p]).ToString()); } str.Append(" -> Goal: (" + goal + ")" + graph.GetNode(goal).ToString()); return(str.ToString()); }
public PartitionedProblemSpace(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, QueryFeatureVector query) { graph = g; partitions = new List<ProblemEquivalenceClass>(); this.query = query; totalProblems = 0; }
public TemplateProblemGenerator(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, Pebbler.Pebbler pebbler, ProblemAnalyzer.PathGenerator generator) { graph = g; this.pebbler = pebbler; pathGenerator = generator; }
public TemplateProblemGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, Pebbler.Pebbler pebbler, ProblemAnalyzer.PathGenerator generator) { graph = g; this.pebbler = pebbler; pathGenerator = generator; }
public Pebbler(Hypergraph.Hypergraph<GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, PebblerHypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> pGraph) { this.graph = graph; this.pebblerGraph = pGraph; forwardPebbledEdges = new HyperEdgeMultiMap<Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); backwardPebbledEdges = new HyperEdgeMultiMap<Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); forwardPebbledEdges.SetOriginalHypergraph(graph); backwardPebbledEdges.SetOriginalHypergraph(graph); }
public Pebbler(Hypergraph.Hypergraph <GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, PebblerHypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> pGraph) { this.graph = graph; this.pebblerGraph = pGraph; forwardPebbledEdges = new HyperEdgeMultiMap <Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); backwardPebbledEdges = new HyperEdgeMultiMap <Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); forwardPebbledEdges.SetOriginalHypergraph(graph); backwardPebbledEdges.SetOriginalHypergraph(graph); }
public AreaHypergraph(List<Atomizer.AtomicRegion> atoms, List<Circle> circles, List<Polygon>[] polygons, List<Sector> minorSectors, List<Sector> majorSectors) { // Ensure the capacity of the powerset. graph = new Hypergraph.Hypergraph<Region, SimpleRegionEquation>((int)Math.Pow(2, atoms.Count)); BuildNodes(atoms, circles, polygons, minorSectors, majorSectors); BuildEdges(atoms); visited = new bool[graph.Size()]; // Precompute any shapes in which we know we can compute the area; this is done in BuildNodes() memoizedSolutions = new ComplexRegionEquation[graph.Size()]; }
public AreaHypergraph(List <Atomizer.AtomicRegion> atoms, List <Circle> circles, List <Polygon>[] polygons, List <Sector> minorSectors, List <Sector> majorSectors) { // Ensure the capacity of the powerset. graph = new Hypergraph.Hypergraph <Region, SimpleRegionEquation>((int)Math.Pow(2, atoms.Count)); BuildNodes(atoms, circles, polygons, minorSectors, majorSectors); BuildEdges(atoms); visited = new bool[graph.Size()]; // Precompute any shapes in which we know we can compute the area; this is done in BuildNodes() memoizedSolutions = new ComplexRegionEquation[graph.Size()]; }
// // Determine which of the given nodes will be suppressed // public void DetermineSuppressedGivens(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph) { // Determine the suppressed nodes in the graph and break // the givens into those that must be explicitly stated to the user and those that are implicit. foreach (int g in givens) { ConcreteAST.GroundedClause clause = graph.vertices[g].data; if (clause.IsAxiomatic() || clause.IsIntrinsic() || !clause.IsAbleToBeASourceNode()) { suppressedGivens.Add(g); } } suppressedGivens.ForEach(s => givens.Remove(s)); }
public GradedProblemTree(Problem <Hypergraph.EdgeAnnotation> thatProblem, Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { goal = thatProblem.goal; edges = new Dictionary <List <List <int> >, List <int> >(); this.graph = g; // Note: the edges in this structure are reversed foreach (PebblerHyperEdge <Hypergraph.EdgeAnnotation> edge in thatProblem.edges) { // Construct the list of lists (as nodes are now multi-element lists) List <List <int> > sources = new List <List <int> >(); foreach (int src in edge.sourceNodes) { sources.Add(Utilities.MakeList <int>(src)); } edges.Add(sources, Utilities.MakeList <int>(edge.targetNode)); } }
public GradedProblemTree(Problem<Hypergraph.EdgeAnnotation> thatProblem, Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { goal = thatProblem.goal; edges = new Dictionary<List<List<int>>, List<int>>(); this.graph = g; // Note: the edges in this structure are reversed foreach (PebblerHyperEdge<Hypergraph.EdgeAnnotation> edge in thatProblem.edges) { // Construct the list of lists (as nodes are now multi-element lists) List<List<int>> sources = new List<List<int>>(); foreach (int src in edge.sourceNodes) { sources.Add(Utilities.MakeList<int>(src)); } edges.Add(sources, Utilities.MakeList<int>(edge.targetNode)); } }
public PathGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> hypergraph) { this.graph = hypergraph; GRAPH_DIAMETER = hypergraph.vertices.Count; }
public PathGenerator(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> hypergraph) { this.graph = hypergraph; GRAPH_DIAMETER = hypergraph.vertices.Count; }
// // Construct the main Hypergraph // private void ConstructHypergraph() { // Resets all saved data to allow multiple problems GenericInstantiator.Instantiator.Clear(); // Build the hypergraph through instantiation graph = instantiator.Instantiate(figure, givens); // Construct the hypergraph wrapper to give access to the front-end. hgWrapper = new EngineUIBridge.HypergraphWrapper(graph); if (Utilities.DEBUG) { graph.DumpNonEquationClauses(); graph.DumpEquationClauses(); } }
public void SetOriginalHypergraph(Hypergraph.Hypergraph<GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; forwardPebbledEdges.SetOriginalHypergraph(g); backwardPebbledEdges.SetOriginalHypergraph(g); }
public void SetOriginalHypergraph(Hypergraph.Hypergraph <GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; }
public HypergraphWrapper(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; hintGenerator = new HintGenerator.HintGenerator(g); }
// // Create a new problem based on thisProblem and thatProblem in accordance with the above comments (repeated here) // // This problem { This Givens } { This Path } -> This Goal // The new problem is of the form: { That Givens } { That Path } -> Goal // Combined: { New Givens U This Givens \minus This Goal} {This Path U This Goal } -> Goal // public void Append(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, HyperEdgeMultiMap <A> forwardEdges, Problem <A> thatProblem) { if (thatProblem.goal == -1) { throw new ArgumentException("Attempt to append with an empty problem " + this + " " + thatProblem); } // // If this is an empty problem, populate it like a copy constructor and return // if (this.goal == -1) { givens = new List <int>(thatProblem.givens); goal = thatProblem.goal; path = new List <int>(thatProblem.path); edges = new List <PebblerHyperEdge <A> >(thatProblem.edges); suppressedGivens = new List <int>(thatProblem.suppressedGivens); thatProblem.edges.ForEach(edge => this.AddEdge(edge)); return; } // // Standard appending of an existent problem to another existent problem // if (!this.givens.Contains(thatProblem.goal)) { throw new ArgumentException("Attempt to append problems that do not connect goal->given" + this + " " + thatProblem); } // Degenerate by removing the new problem goal from THIS source node. this.givens.Remove(thatProblem.goal); // Add the 'new problem' goal node to the path of the new Problem (uniquely) Utilities.AddUnique <int>(this.path, thatProblem.goal); // Add the path nodes to THIS path Utilities.AddUniqueList <int>(this.path, thatProblem.path); // Add all the new sources to the degenerated old sources; do so uniquely Utilities.AddUniqueList <int>(this.givens, thatProblem.givens); Utilities.AddUniqueList <int>(this.suppressedGivens, thatProblem.suppressedGivens); // Add all of the edges of that problem to this problem; this also adds to the problem graph thatProblem.edges.ForEach(edge => this.AddEdge(edge)); if (this.ContainsCycle()) { throw new Exception("Problem contains a cycle" + this.graph.GetStronglyConnectedComponentDump()); // Remove an edge from this problem? } // Now, if there exists a node in the path AND in the givens, remove it from the givens. foreach (int p in this.path) { if (this.givens.Remove(p)) { // if (Utilities.PROBLEM_GEN_DEBUG) System.Diagnostics.Debug.WriteLine("A node existed in the path AND givens (" + p + "); removing from givens"); } } PerformDeducibilityCheck(forwardEdges); }
public HintGenerator(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; }
public SynthesisAreaHypergraphCreator(List<Figure> shapes) { figures = new List<Figure>(shapes); graph = new Hypergraph.Hypergraph<Region,SimpleRegionEquation>(); }
public ProblemEquivalenceClass(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; elements = new List <Problem <Hypergraph.EdgeAnnotation> >(); }
public AreaHypergraphCreator(List <Figure> shapes) { figures = new List <Figure>(shapes); graph = new Hypergraph.Hypergraph <Region, SimpleRegionEquation>(); }
public HypergraphWrapper(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; hintGenerator = new HintGenerator.HintGenerator(g); }
public ProblemEquivalenceClass(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; elements = new List<Problem<Hypergraph.EdgeAnnotation>>(); }
public HintGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; }