Example #1
0
        public static PipeSystem CreateV3e4(int psIndex)
        {
            Log.Debug("Creating pipe system 'V3e4'.");

            Valve  v90  = new Valve(0, 1, 288, -120);
            Fan    v91  = new Fan(1, 1, 288, -144);
            Valve  v94  = new Valve(4, 4, 288, -202);
            Inlet  v100 = new Inlet(0, -1);
            Valve  v102 = new Valve(2, 1, 326, -158);
            Fan    v104 = new Fan(4, 0, 306, -222);
            Valve  v110 = new Valve(0, 2, 312, -102);
            Valve  v113 = new Valve(3, 2, 326, -204);
            Fan    v120 = new Fan(0, 2, 344, -102);
            Valve  v122 = new Valve(2, 2, 352, -176);
            Fan    v123 = new Fan(3, 2, 354, -206);
            Valve  v125 = new Valve(5, 0, 350, -244);
            Valve  v131 = new Valve(1, 4, 370, -138);
            Valve  v133 = new Valve(3, 3, 392, -206);
            Fan    v141 = new Fan(1, 2, 396, -138);
            Valve  v142 = new Valve(2, 3, 412, -156);
            Valve  v150 = new Valve(0, 3, 428, -120);
            Outlet v155 = new Outlet(5, -1);

            Vertex[] vertices = { v90, v91, v94, v100, v102, v104, v110, v113, v120, v122, v123, v125, v131, v133, v141, v142, v150, v155 };

            Vertex[][] edges =
            {
                new Vertex[] { v90,  v91,  v100 },
                new Vertex[] { v91,  v94,  v102 },
                new Vertex[] { v94,  v102, v104 },
                new Vertex[] { v100, v110 },
                new Vertex[] { v102, v113, v122 },
                new Vertex[] { v104, v113, v125 },
                new Vertex[] { v110, v120 },
                new Vertex[] { v113, v122, v123, v125},
                new Vertex[] { v120, v131, v150 },
                new Vertex[] { v122, v131 },
                new Vertex[] { v123, v133 },
                new Vertex[] { v125, v133, v142, v150, v155},
                new Vertex[] { v131, v141, v150 },
                new Vertex[] { v133, v142, v150, v155},
                new Vertex[] { v141, v142 },
                new Vertex[] { v142, v150, v155 },
                new Vertex[] { v150, v155 },
                new Vertex[] { v155 },
            };

            Valve[] openValvesAtStart = { v90, v94, v102, v122, v125, v131, v133, v142 };

            PipeSystem result = new PipeSystem(psIndex, vertices, edges, openValvesAtStart);

            Debug.Assert(result.graph.VertexCount == 18, "wrong vertex count");
            Debug.Assert(result.graph.EdgeCount == 32, "wrong edge count");
            return(result);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }