private PipeSystem(int index, Vertex[] vertices, Vertex[][] edges, Valve[] openValvesAtStart) { Debug.Assert(edges.Length == vertices.Length, "Parameter edges must specify edges for all vertices (even if the list is empty)"); Index = index; graph.AddVertexRange(vertices); foreach (Vertex[] vEdges in edges) { for (int i = 1; i < vEdges.Length; i++) { graph.AddEdge(new Edge(vEdges[0], vEdges[i])); } } foreach (Vertex vertex in vertices) { if (vertex is Fan) { Fan f = (Fan)vertex; f.PipeSystem = this; fans.Add(f); } if (vertex is Valve) { Valve v = (Valve)vertex; v.PipeSystem = this; valves.Add(v); } if (vertex is Inlet) { Inlet i = (Inlet)vertex; i.PipeSystem = this; inlets.Add(i); } if (vertex is Outlet) { Outlet o = (Outlet)vertex; o.PipeSystem = this; outlets.Add(o); } } this.openValvesAtStart = openValvesAtStart; Log.Verbose("Created pipe system with {0} inlets, {1} outlets, {2} valves and {3} fans.", inlets.Count, outlets.Count, valves.Count, fans.Count); }
public static PipeSystem CreateV3e3(int psIndex) { Log.Debug("Creating pipe system 'V3e3'."); Inlet v50 = new Inlet(0, -1); Fan v52 = new Fan(2, 2, 160, -166); Valve v54 = new Valve(4, 2, 160, -194); Fan v60 = new Fan(0, 0, 180, -120); Valve v61 = new Valve(1, 2, 180, -146); Valve v63 = new Valve(3, 1, 188, -194); Valve v70 = new Valve(0, 0, 208, -120); Outlet v75 = new Outlet(5, -1); Fan v80 = new Fan(0, 1, 235, -120); Valve v81 = new Valve(1, 3, 246, -146); Fan v83 = new Fan(3, 1, 246, -184); Valve v84 = new Valve(4, 3, 246, -214); Vertex[] vertices = { v50, v52, v54, v60, v61, v63, v70, v75, v80, v81, v83, v84 }; Vertex[][] edges = { new Vertex[] { v50, v60 }, new Vertex[] { v52, v54, v61}, new Vertex[] { v54, v63, v75, v84}, new Vertex[] { v60, v70 }, new Vertex[] { v61, v63, v81, v83}, new Vertex[] { v63, v75, v81, v83, v84}, new Vertex[] { v70, v80 }, new Vertex[] { v75, v84 }, new Vertex[] { v80, v81 }, new Vertex[] { v81, v83 }, new Vertex[] { v83, v84 }, new Vertex[] { v84 }, }; Valve[] openValvesAtStart = { v54, v70, v81, v84 }; PipeSystem result = new PipeSystem(psIndex, vertices, edges, openValvesAtStart); Debug.Assert(result.graph.VertexCount == 12, "wrong vertex count"); Debug.Assert(result.graph.EdgeCount == 19, "wrong edge count"); return(result); }
public static PipeSystem CreateV3e2(int psIndex) { Log.Debug("Creating pipe system 'V3e2'."); Valve v21 = new Valve(1, 1, 64, -130); Fan v23 = new Fan(3, 0, 64, -158); Valve v32 = new Valve(2, 0, 90, -154); Valve v34 = new Valve(4, 1, 90, -214); Inlet v40 = new Inlet(0, -1); Fan v41 = new Fan(1, 0, 118, -112); Fan v42 = new Fan(2, 1, 104, -176); Valve v43 = new Valve(3, 0, 120, -196); Outlet v45 = new Outlet(5, -1); Vertex[] vertices = { v21, v23, v32, v34, v40, v41, v42, v43, v45 }; Vertex[][] edges = { new Vertex[] { v21, v23, v32, v41 }, new Vertex[] { v23, v34 }, new Vertex[] { v32, v41, v42 }, new Vertex[] { v34, v43, v45 }, new Vertex[] { v40, v41 }, new Vertex[] { v41 }, new Vertex[] { v42, v43 }, new Vertex[] { v43, v45 }, new Vertex[] { v45 }, }; Valve[] openValvesAtStart = { v21, v32, v34, v43 }; PipeSystem result = new PipeSystem(psIndex, vertices, edges, openValvesAtStart); Debug.Assert(result.graph.VertexCount == 9, "wrong vertex count"); Debug.Assert(result.graph.EdgeCount == 11, "wrong edge count"); return(result); }
internal FanTriggeredEventArgs(PipeSystem system, Fan fan) { System = system; Fan = fan; }