Exemplo n.º 1
0
        /*public override void ProcessLaneTurns(LaneAgent LA, int[] Turns)
         * {
         *  throw new Exception("The method or operation is not implemented2.");
         * }*/
        public override void ProcessStage(StageAgent SA)
        {
            SA.LanePhases.Clear();
            //test that number of lanes and weights is the same
            if (SA.Lanes.Count != SA.Weights.Count)
            {
                throw (new Exception("The number of weights does not match the number of lanes"));
            }

            Bid B = new Bid();
            //double pBid = 0;
            int Lcount = SA.Lanes.Count;

            for (int i = 0; i < Lcount; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    SA.LanePhases.Add(SA.Lanes[i].LaneBid.TurningBids[j]);         //AH - Not considering Weights
                    for (int k = 0; k < 3; k++)
                    {
                        SA.RoadStates[j, k] = SA.Lanes[i].RoadState[j, k];          //This makes the assumption that there is only one lane!
                    }
                }
                //pBid += SA.Lanes[i].LaneBid.Scalar * SA.Weights[i];
            }



            //B.Scalar = pBid;
            //Console.WriteLine(pBid);
            //SA.StageBid = B;
        }
Exemplo n.º 2
0
        //Function to read get the agent data from the XML file
        protected void FindAgents(NetworkData NDin, ref ZoneAgent ZAin)
        {
            XmlNodeList JunctionsData = NetworkStruct.GetElementsByTagName("Junction");

            foreach (XmlNode Jcn in JunctionsData)
            {
                string SignalNode = Jcn.SelectSingleNode("SignalNode").FirstChild.Value;
                int    NumStages  = Convert.ToInt32(Jcn.SelectSingleNode("Stages").FirstChild.Value);

                JunctionAgent TempJA = new JunctionAgent(NDin, Strat, SignalNode, NumStages);

                XmlNodeList StageData = Jcn.SelectNodes("Stage");
                foreach (XmlNode Stg in StageData)
                {
                    StageAgent TempSA = new StageAgent(NDin, Strat);

                    XmlNodeList AgentData = Stg.SelectNodes("Agent");
                    foreach (XmlNode Agt in AgentData)
                    {
                        LaneAgent TempLA = new LaneAgent(NDin, Strat);
                        TempLA.Duplicate = Convert.ToBoolean(Agt.SelectSingleNode("Duplicate").FirstChild.Value);
                        TempLA.Name      = Agt.SelectSingleNode("name").FirstChild.Value;
                        //TempLA.UpstreamAgents = Agt.SelectSingleNode("UpstreamAgents").FirstChild.Value;
                        XmlNodeList RoadData = Agt.SelectNodes("RoadSec");
                        foreach (XmlNode Rsec in RoadData)
                        {
                            string Snode, Enode;
                            int    Lane, OLanes;
                            double Oset;

                            Snode  = Rsec.SelectSingleNode("StartNode").FirstChild.Value;
                            Enode  = Rsec.SelectSingleNode("EndNode").FirstChild.Value;
                            Lane   = Convert.ToInt32(Rsec.SelectSingleNode("Lane").FirstChild.Value);
                            OLanes = Convert.ToInt32(Rsec.SelectSingleNode("OfLanes").FirstChild.Value);
                            Oset   = Convert.ToDouble(Rsec.SelectSingleNode("Offset").FirstChild.Value);

                            TempLA.RoadSegments.Add(new LaneAgent.BitOfRoad(Snode, Enode, Lane, OLanes, Oset));
                        }
                        TempSA.Lanes.Add(TempLA);
                    }
                    TempSA.NeutralWeight();
                    TempJA.Stages.Add(TempSA);
                }
                ZAin.Junctions.Add(TempJA);
            }
        }
Exemplo n.º 3
0
 //public abstract void ProcessLaneTurns(LaneAgent LA, int[] Turns);       //AH added
 public abstract void ProcessStage(StageAgent SA);