Exemplo n.º 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;
        }
Exemplo n.º 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));
 }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
0
 public override void GenerateEvent(Entity E = null)
 {
     Entity e = new Entity();
     e.InterArrival_Time = TimeSpan.FromSeconds(0);
     e.Id = 1;
     e.Amount = EntityAmount != null ? EntityAmount[current_number-1] : 1;
     e.statistic.EntityId = e.Id;
     Env.Statistics.Add(e.statistic);
     Event ev = new Event(Event.Type.C, Env.System_Time, this, Env , e);
     Env.FEL.Enqueue(Env.System_Time, ev);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 7
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++;
        }
Exemplo n.º 8
0
 public abstract void Process(Event.Type T, Entity E, Actor C = null);
Exemplo n.º 9
0
 public override void GenerateEvent(Entity E)
 {
     Event e = new Event(Event.Type.C, Env.System_Time, this, Env, E);
     Env.FEL.Enqueue(e.Time,e);
 }