Esempio n. 1
0
 public void FCFS_Test()
 {
     Queue<Request> queue = new Queue<Request>(array);
     Queue<Request> resultQueue = new Queue<Request>(array);
     queue = RequestAlgorithms.FCFS(queue, new Drive.Stats(100, 50, i => 10 + i * 0.2, 0.3, 0.5, null, 0, 0, true, 10, 0.2));
     Assert.IsTrue(resultQueue.OrderBy(request => request.ArrivalTime).Zip(queue, (request, request1) => comparisonFunc(request, request1)).Aggregate((b, b1) => b && b1));
 }
Esempio n. 2
0
 public static Queue<Request> SSTF(Queue<Request> requestQueue, Drive.Stats driveStatistics)
 {
     if (requestQueue.Count <= 1)
         return new Queue<Request>(requestQueue);
     return
         new Queue<Request>(
             requestQueue.OrderBy(request => Utilities.RequestDistance(request, driveStatistics)));
 }
Esempio n. 3
0
 /// <summary>
 /// 回数順にランダムソートを行う
 /// </summary>
 /// <param name="Team"></param>
 public void RandamSortByCount(ref Queue<Member> Team)
 {
     IEnumerable<Member> query = Team.OrderBy(member => member.day.Count).ThenBy(member => member.Score);
     foreach (Member member in query)
     {
         Team.Dequeue();
         Team.Enqueue(member);
     }
 }
        public void AStar(Grafo grafo, Nodo origem, Nodo destino)
        {
            grafo.nodos = this.limpaNodos(grafo.nodos);

            fila = new Queue<Nodo>();
            Visitacao = new List<Nodo>();

            foreach (Nodo nodo in grafo.nodos) {
                if (nodo == origem)
                    continue;

                nodo.TempoInicio = int.MaxValue;
                nodo.predecessor = null;
                nodo.Cor = Cor.Branco;
            }
            origem.Cor = Cor.Cinza;
            origem.TempoInicio = 0;
            origem.predecessor = null;
            // Adiciona o nodo de origem na fila.
            fila.Enqueue(origem);
            while (fila.Count > 0) {
                Nodo u = fila.Dequeue();
                Visitacao.Add(u);
                if (u == destino)
                    break;
                foreach (Nodo v in u.ListaAdj) {
                    if (v.Cor == Cor.Branco) {
                        v.Cor = Cor.Cinza;
                        v.TempoInicio = u.TempoInicio + 1;
                        v.predecessor = u;
                        //fila.enqueueNodeOrdered(v, 'F');
                        fila.Enqueue(v);
                        fila = new Queue<Nodo>(fila.OrderBy(linq => linq.F));
                    }
                }
                u.Cor = Cor.Preto;
            }
            this.fazCaminhoSolucao();
        }
Esempio n. 5
0
 public static Queue<Request> FCFS(Queue<Request> requestQueue, Drive.Stats driveStatistics)
 {
     if (requestQueue.Count <= 1)
         return new Queue<Request>(requestQueue);
     return new Queue<Request>(requestQueue.OrderBy(request => request.ArrivalTime));
 }
Esempio n. 6
0
 /// <summary>
 /// 番号順にランダムソートを行う
 /// </summary>
 /// <param name="Team"></param>
 public void RandamSortByNo(ref Queue<Member> Team)
 {
     IEnumerable<Member> query = Team.OrderBy(member => member.No);
     foreach (Member member in query)
     {
         Team.Dequeue();
         Team.Enqueue(member);
     }
 }