Пример #1
0
        public override void Process(Event.Type T, Entity E, Actor C = null)
        {
            this.Is_Busy = true;
            E.Arrival_Time = Env.System_Time;
            E.Delay = TimeSpan.FromSeconds(0);
            //Console.WriteLine(string.Format("Entity {0} entered the system at {1}", E.Id, Env.Seconds_From));
            base.CallNext(E);
            if (current_number <= Number_Of_Entities)
            {
                Entity en = new Entity();
                en.InterArrival_Time = Create_Distribution.Next_Time();
                en.Id = current_number;
                en.Amount = EntityAmount != null ? EntityAmount[current_number-1] : 1;
                en.statistic.EntityId = en.Id;
                en.statistic.Arrival = Env.Seconds_From + en.InterArrival_Time.TotalSeconds;
                en.statistic.InterArrival = en.InterArrival_Time.TotalSeconds;

                Env.Statistics.Add(en.statistic);
                Env.FEL.Enqueue(Env.System_Time.Add(en.InterArrival_Time),
                    new Event(Event.Type.C, Env.System_Time.Add(en.InterArrival_Time), this, Env, en));
                current_number++;
            }
            else
            {
                this.Is_Finished = true;
            }
            this.Is_Busy = false;
        }
Пример #2
0
 public override void Process(Event.Type T, Entity E,Actor C = null)
 {
     if (T == Event.Type.D){
         //Console.WriteLine(string.Format("Entity {0} left system at {1}", E.Id, Env.Seconds_From));
         E.statistic.Departure = Env.Seconds_From;
     }
     //else
         //Console.WriteLine(string.Format("Entity {0} failed at {1}", E.Id, Env.Seconds_From));
 }
Пример #3
0
        private Type T; //Event Type

        #endregion Fields

        #region Constructors

        //Constructor // E = Null for Arrival Event
        public Event(Type T, DateTime Time,  Actor A,Environment Env,Entity E,Actor Caller = null)
        {
            this.T = T;
            this.Time = Time;
            this.E = E;
            this.A = A;
            this.Env = Env;
            this.Caller = Caller;
        }
Пример #4
0
        public override void Process(Event.Type T, Entity E,Actor C = null)
        {
            base.CallNext(E);

            Seized--;
            Check_Busy();
            if (this.RQueue != null && !this.RQueue.Is_Empty)
            {
                Env.FEL.Enqueue(Env.System_Time, new Event(Event.Type.OUT, Env.System_Time, this.RQueue, Env, E,this));
            }
        }
Пример #5
0
 public override void Process(Event.Type T, Entity E,Actor C = null)
 {
     index = 0;
     while (index < Conds.Count)
     {
         if (Conds[index].eval())
         {
             Env.Sim_Actors[CondToTarget[index]].GenerateEvent(E);
             return;
         }
         index++;
     }
     Env.Sim_Actors[CondToTarget[index]].GenerateEvent(E);
 }
Пример #6
0
        public override void Process(Event.Type T, Entity E,Actor C)
        {
            if (T == Event.Type.IN)
            {
                if (Capacity > Queue_Length)
                {
                    E.Last_Queue_Time_In = Env.System_Time;
                    AQueue.Enqueue(E);
                    //Console.WriteLine(string.Format("Entity {0} enqueued in Queue{2} at {1}", E.Id, Env.Seconds_From,this.AID));
                }
                else
                {
                    Env.FEL.Enqueue(Env.System_Time, new Event(Event.Type.F, Env.System_Time, Env.System_Dispose.First(), Env, E));
                }

            }
            else
            {
                Entity e = AQueue.First();
                e.Delay += Env.System_Time.Subtract(e.Last_Queue_Time_In);
                C.GenerateEvent(e);
            }
        }
Пример #7
0
 public EQCond(Int64 ownerId, Actor actor1, Actor.StateType state)
 {
     this.actor1 = actor1;
     this.state = state;
 }
Пример #8
0
 public EQCond(Int64 ownerId, Actor actor1, Actor actor2)
 {
     this.actor1 = actor1;
     this.actor2 = actor2;
 }
Пример #9
0
        public override void Process(Event.Type T, Entity E,Actor A=null)
        {
            //////Console.WriteLine("Entity" + E.Id + " Entered Inventory" + this.AID + " for loading");

            Int64 LoadNeed = Level - Quantity;
            if (Quantity < Level)
            {
                if (LoadNeed <= E.Amount)
                {
                    Quantity = Level;
                    E.Amount = E.Amount - LoadNeed;
                }
                else throw new Exception("Not enough stock for Inventory(Id=" + AID);
            }
            ////////Console.WriteLine("Inventory" + this.AID  + " loaded " + LoadNeed + " units");

            base.CallNext(E);

            _current_state = StateProb.NextDouble();
            _demand = (Int64)DemandProb[_current_state].NextDouble();

            double Revenue = (_demand <= _quantity ? _demand : _quantity) * SalePricePerUnit;
            double LostProfit = (_demand >= _quantity ? _demand - _quantity : 0) * (SalePricePerUnit-PricePerUnit);
            double Scrap = 0;
            double LoadCost = LoadNeed * PricePerUnit;

            _quantity = _demand >= _quantity ? 0 : _quantity - _demand;

            if (_salvage) {
                Scrap = _quantity * ScrapPricePerUnit;
                _quantity = 0;
            }
            double Profit = Revenue - PricePerUnit * _level - LostProfit + Scrap;

            ResourceOtherStatistics RevStat = new ResourceOtherStatistics() { StatisticTitle = "Revenue", StatisticValue = Revenue };
            ResourceOtherStatistics LostStat = new ResourceOtherStatistics() { StatisticTitle = "Lost Profit", StatisticValue = LostProfit };
            ResourceOtherStatistics ScrapStat = new ResourceOtherStatistics() { StatisticTitle = "Salvage of Scrap", StatisticValue = Scrap };
            ResourceOtherStatistics ProfitStat = new ResourceOtherStatistics() { StatisticTitle = "Profit", StatisticValue = Profit };
            ResourceOtherStatistics DemandStat = new ResourceOtherStatistics() { StatisticTitle = "Demand", StatisticValue = _demand };
            ResourceOtherStatistics StateStat = new ResourceOtherStatistics() { StatisticTitle = "State", StatisticValue = _current_state };

            ResourceOtherStatistics[] Stats = new ResourceOtherStatistics[] {StateStat,DemandStat,RevStat,LostStat,ScrapStat,ProfitStat };

            Statistics.OtherStatistics.Add(_current_cycle, Stats);
            //////Console.WriteLine("Inventory" + this.AID + " ended cycle" + _current_cycle);
            _current_cycle++;
        }
Пример #10
0
 public abstract void Process(Event.Type T, Entity E, Actor C = null);