Beispiel #1
0
        public void PrintStatistics()
        {
            double count = 0, TimeInSystem = 0;

            foreach (var t in Transitions)
            {
                TimeInSystem += t.AverageTimeInSystem;
                if (Transitions.IndexOf(t) >= Boundary1 && Transitions.IndexOf(t) >= Boundary1)
                {
                    count += t.Count;
                }
            }

            AverageAmountOfBusy /= Count;
            Console.WriteLine($"Average time of detail: {TimeInSystem / Transitions.Last().Count}");
            Console.WriteLine($"Average amount of busy devices: {AverageAmountOfBusy}");
            Console.WriteLine("Workloads of devices:");
            int k = 0;

            foreach (var p in Positions.Where(p => p.Type == "Free condition"))
            {
                k++;
                Console.WriteLine($"Average workload of device {k}: {p.AmountOfPerformance / p.TimeOfPerformance}");
            }
        }
Beispiel #2
0
 public void FindTNext(List <Position> positions)
 {
     foreach (var p in positions)
     {
         int indexOfArc = GetNextElement(p.NextArcs);
         //foreach (var a in p.NextArcs)
         //{
         //    if (a.NextTransition != null)
         //    {
         //        int index = Transitions.IndexOf(a.NextTransition);
         //        if (Transitions[index].CheckConditionsOfTransitions(Positions))
         //        {
         //            Transitions[index].FindTNext();
         //        }
         //    }
         //}
         if (p.NextArcs.Count > 0)
         {
             if (p.NextArcs[indexOfArc].NextTransition != null)
             {
                 int index = Transitions.IndexOf(p.NextArcs[indexOfArc].NextTransition);
                 if (Transitions[index].CheckConditionsOfTransitions(Positions))
                 {
                     Transitions[index].FindTNext();
                 }
             }
         }
     }
 }
Beispiel #3
0
        //симитировать шаги
        public void Simulate(double timeModeling)
        {
            if (!IsStartCondition())
            {
                throw new Exception("Start condition is not performed");
            }
            SetProbabilities();
            int prev = -1;

            //int transition = 0;
            while (TCurrent < timeModeling)
            {
                TNext = Double.MaxValue;

                foreach (var t in Transitions)
                {
                    if (t.TNext < TNext && t.CheckConditionsOfTransitions(Positions))
                    {
                        TNext          = t.TNext;
                        NextTransition = Transitions.IndexOf(t);
                    }
                }
                if (!(prev == 0 && NextTransition == 0))
                {
                    Console.WriteLine($"Transition: {Transitions[NextTransition].Name} time = {TNext}");
                    Console.WriteLine();
                }

                foreach (var t in Transitions)
                {
                    t.CountStatistics(TNext - TCurrent, Positions);
                }
                TCurrent = TNext;
                foreach (var t in Transitions)
                {
                    t.TCurrent = TCurrent;
                }
                //CountBusy();
                if (Transitions[NextTransition].CheckConditionsOfTransitions(Positions))
                {
                    List <Position> pos = Transitions[NextTransition].OutArcs.Select(x => x.NextPosition).ToList();
                    Positions = Transitions[NextTransition].TakeMarkers(Positions);
                    FindTNext(pos);
                }
                prev = NextTransition;
                Count++;
            }
            //PrintStatistics();
        }
Beispiel #4
0
        //симитировать шаги
        public void Simulate(int modelingSteps)
        {
            SetProbabilities();
            int prev = -1;

            List <int> available = new List <int>();
            int        previous  = 4;

            for (int i = 0; i < modelingSteps; i++)
            {
                if (Math.Abs(previous - i) >= 4)
                {
                    Positions[0].MarkersCount = 1;
                    NextTransition            = 0;
                    previous = i;
                }
                else
                {
                    foreach (var t in Transitions)
                    {
                        if (t.CheckConditionsOfTransitions(Positions) && available.Contains(Transitions.IndexOf(t)) == true)
                        {
                            NextTransition = Transitions.IndexOf(t);
                        }
                    }
                }
                available.Clear();
                if (!(prev == NextTransition))
                {
                    Console.WriteLine();
                }

                foreach (var p in Positions)
                {
                    p.CountStatistics();
                }

                if (Transitions[NextTransition].CheckConditionsOfTransitions(Positions) && !(prev == NextTransition))
                {
                    List <Position> pos = Transitions[NextTransition].OutArcs.Select(x => x.NextPosition).ToList();
                    Positions = Transitions[NextTransition].TakeMarkers(Positions);
                    available = FindNextTransition(pos);
                }
                prev = NextTransition;
                Count++;
            }
            PrintStatistics();
        }
Beispiel #5
0
 public int FindNext(int transition)
 {
     foreach (var t in Transitions)
     {
         if (t.CheckConditionsOfTransitions(Positions))
         {
             transition = Transitions.IndexOf(t);
             return(transition);
         }
         else
         {
             transition = -1;
         }
     }
     return(transition);
 }
Beispiel #6
0
 public void FindTNext(List <Position> positions)
 {
     foreach (var p in positions)
     {
         foreach (var a in p.NextArcs)
         {
             if (a.NextTransition != null)
             {
                 int index = Transitions.IndexOf(a.NextTransition);
                 if (Transitions[index].CheckConditionsOfTransitions(Positions))
                 {
                     Transitions[index].FindTNext();
                 }
             }
         }
     }
 }
Beispiel #7
0
        public List <int> FindNextTransition(List <Position> positions)
        {
            List <int> available = new List <int>();

            foreach (var p in positions)
            {
                int indexOfArc = GetNextElement(p.NextArcs);
                if (p.NextArcs.Count > 0)
                {
                    if (p.NextArcs[indexOfArc].NextTransition != null)
                    {
                        available.Add(Transitions.IndexOf(p.NextArcs[indexOfArc].NextTransition));
                    }
                }
            }
            return(available);
        }
Beispiel #8
0
 public int GetTransitionIdx(EditorTransition editorTransition)
 {
     return(Transitions.IndexOf(editorTransition));
 }
 /// <summary>
 /// Returns a generated TransitionID
 /// </summary>
 /// <param name="transition"></param>
 /// <returns></returns>
 /// <autor>Andrej Albrecht</autor>
 public String GetTransitionID(Transition transition)
 {
     return("t" + Transitions.IndexOf(transition));
 }