Esempio n. 1
0
        //public PrimalArrivalList Gen(int id)
        //{
        //    PrimalArrivalList arr = new PrimalArrivalList() { PAListID = id };
        //    for (int t = 0; t < TimeHorizon;)
        //    {
        //        double u1 = rng.NextDouble();
        //        double u2 = rng.NextDouble();
        //        t = (int)Math.Ceiling(t - (1 / MaxLamada) * Math.Log(u1));//这里向上取整,可能会影响结果。
        //        if ((u2 <= (MarketInfo.Ro(t) / MaxLamada)) && t < TimeHorizon)
        //        {
        //            double u3 = rng.NextDouble();
        //            PrimalArrival temp = new PrimalArrival()
        //            {
        //                ArriveTime = t,
        //                IndexOfMS = rollMS(t, u3).MSID
        //            };
        //            arr.Add(temp);
        //        }
        //    }
        //    return arr;
        //}
        public PrimalArrivalList Gen(int id)
        {
            PrimalArrivalList arr = new PrimalArrivalList()
            {
                PAListID = id, TimeHorizon = TimeHorizon
            };

            for (int t = 0; t < TimeHorizon; t++)
            {
                double u1 = rng.NextDouble();
                double u2 = rng.NextDouble();
                double u3 = rng.NextDouble();
                //t = (int)Math.Ceiling(t - (1 / MaxLamada) * Math.Log(u1));//这里向上取整,可能会影响结果。
                //if ((u2 <= (MarketInfo.Ro(t) / MaxLamada)) && t < TimeHorizon)
                if (u1 < MarketInfo.Ro(t))
                {
                    //double u3 = rng.NextDouble();
                    PrimalArrival temp = new PrimalArrival()
                    {
                        ArriveTime    = t,
                        IndexOfMS     = rollMS(t, u2).MSID,
                        ChoosingParam = u3
                    };
                    arr.Add(temp);
                }
            }
            return(arr);
        }
Esempio n. 2
0
        public PrimalArrivalList GetCurPAL()
        {
            PrimalArrivalList pal = new PrimalArrivalList();

            pal.PAListID = Convert.ToInt32(_reader.GetAttribute("ID"));
            while (_reader.Read())
            {
                if (_reader.NodeType == XmlNodeType.Element &&
                    _reader.Name == "PrimalArrival")
                {
                    pal.Add(new PrimalArrival()
                    {
                        ArriveTime = Convert.ToInt32(_reader.GetAttribute("Time")),
                        IndexOfMS  = Convert.ToInt32(_reader.GetAttribute("MS"))
                    });
                }
                else if (_reader.NodeType == XmlNodeType.Element &&
                         _reader.Name == "PrimalArrivalList")
                {
                    break;
                }
            }
            return(pal);
        }