Example #1
0
 private void Escenario1()
 {
     arreglo = new ArregloCola <int>(5);
     arreglo.AgregarElemento(3, 1);
     arreglo.AgregarElemento(2, 1);
     arreglo.AgregarElemento(2, 3);
 }
Example #2
0
        private int asignarCola(List <int[]> ids, ArregloCola <Pasajero> cola, int stopId)
        {
            int retorno    = -1;
            int auxRetorno = Contiene(ids, stopId);

            if (auxRetorno == -1)
            {
                for (int i = 0; i < cola.DarTamano() && retorno == -1; i++)
                {
                    if (!cola.colaEnUso(i))
                    {
                        cola.inicializarCola(i);
                        int[] auxAgrega = { stopId, i };
                        ids.Add(auxAgrega);
                        retorno = i;
                    }
                }
            }
            else
            {
                retorno = ids[auxRetorno][1];
            }

            return(retorno);
        }
Example #3
0
 private void EscenarioTamano()
 {
     colas = new ArregloCola <int> [1000];
     for (int i = 0; i < colas.Length; i++)
     {
         colas[i] = new ArregloCola <int>(5);
     }
 }
 private void EscenarioTamano()
 {
     colas = new ArregloCola<int>[1000];
     for (int i = 0; i < colas.Length; i++)
     {
         colas[i] = new ArregloCola<int>(5);
     }
 }
        private void Escenario1()
        {
            arreglo = new ArregloCola<int>(5);
            arreglo.AgregarElemento(3, 1);
            arreglo.AgregarElemento(2, 1);
            arreglo.AgregarElemento(2, 3);

        }
Example #6
0
 public Parada(int id, String nombre, double latitud, double longitud) {
     Id = id;
     Nombre = nombre;
     Latitud = latitud;
     Longitud = longitud;
     Estado = false;
     IdUltimoBus = 0;
     ColasPasajeros = new ArregloCola<Pasajero>(15);
     rutas = new string[6];
 }
Example #7
0
 public Parada(int id, String nombre, double latitud, double longitud)
 {
     Id             = id;
     Nombre         = nombre;
     Latitud        = latitud;
     Longitud       = longitud;
     Estado         = false;
     IdUltimoBus    = 0;
     ColasPasajeros = new ArregloCola <Pasajero>(15);
     rutas          = new string[6];
 }
Example #8
0
 private void Escenario()
 {
     arreglo = new ArregloCola <int>(5);
 }
 private void Escenario()
 {
     arreglo = new ArregloCola<int>(5);
 }
Example #10
0
        private int asignarCola(List<int[]> ids, ArregloCola<Pasajero> cola, int stopId)
        {
            int retorno = -1;
            int auxRetorno = Contiene(ids, stopId);
            if (auxRetorno == -1)
            {
                for (int i = 0; i < cola.DarTamano() && retorno == -1; i++)
                {
                    if (!cola.colaEnUso(i))
                    {
                        cola.inicializarCola(i);
                        int[] auxAgrega = { stopId, i };
                        ids.Add(auxAgrega);
                        retorno = i;
                    }
                }
            }
            else
            {
                retorno = ids[auxRetorno][1];
            }

            return retorno;

        }
Example #11
0
        /// <summary>
        /// Permite realizar las operaciones del bus, que consiten en desenso de pasajeros, subir pasajeros y avanzar a otra estación.
        /// </summary>
        /// <param name="tiempo"></param>
        /// <param name="grafo"></param>
        /// <returns></returns>
        public void AtiendeBus(int tiempo, GrafoMatriz <Estacion> grafo)
        {
            if (tiempo == siguienteInteraccion)
            {
                Estacion[] estaciones = grafo.DarVertices();



                int EstacionActualRuta = ruta.DarParadas()[EstacionActual][0];
                int NumParada          = ruta.DarParadas()[EstacionActual][1];
                int NumCola            = ruta.DarParadas()[EstacionActual][2];

                if (ruta.DarParadas().Count <= EstacionActual + 1)
                {
                    TerminoRecorrido = true;
                }
                Estacion estacion = estaciones[EstacionActualRuta];
                Parada   parada   = estacion.DarParadas()[NumParada];
                if (!parada.Estado && !Estado)
                {
                    parada.Estado = true;
                    this.Estado   = true;
                    for (int i = 0; i < Pasajeros.Length; i++)
                    {
                        if (Pasajeros[i] != null)
                        {
                            if (Pasajeros[i].EsMiEstacion(EstacionActual, this, grafo) == 4)
                            {
                                Pasajeros[i] = null;
                                CapacidadActual--;
                            }
                            else if (Pasajeros[i].EsMiEstacion(EstacionActual, this, grafo) == 1)
                            {
                                estaciones[EstacionActual].agregarPasajeros(Pasajeros[i]);
                                estaciones[EstacionActual].AumentarCantidadPasajeros();
                                Pasajeros[i] = null;
                                CapacidadActual--;
                            }
                        }
                    }


                    ArregloCola <Pasajero> pasajeros = parada.ColasPasajeros;

                    while (!pasajeros.ColaVacia(NumCola) && CapacidadActual < Capacidad)
                    {
                        agregarPasajero(pasajeros.ObtenerElemento(NumCola));
                        pasajeros.EliminarElemento(NumCola);
                        CapacidadActual++;
                    }

                    siguienteInteraccion++;
                    datos[tiempo] = "Nombre estación: " + grafo.DarVertices()[EstacionActualRuta].GetNombre() + " Siguiente interacción: " + siguienteInteraccion + " Cantidad pasajeros: " + CapacidadActual + " Tiempo Actual: " + tiempo + " Numero parada: " + NumParada + " Cola: " + NumCola;
                }
                else if (Estado)
                {
                    datos[tiempo] = "Atiende";
                    parada.Estado = false;
                    this.Estado   = false;
                    EstacionActual++;
                    if ((tiempo > 120 && tiempo < 240) || (tiempo > 780 && tiempo < 900))
                    {
                        siguienteInteraccion += (int)(grafo.DarMatriz()[EstacionActualRuta, ruta.DarParadas()[EstacionActual][0]] / VELOCIDAD_PICO);
                    }
                    else
                    {
                        //Console.WriteLine(ruta.DarParadas()[EstacionActual][0]);
                        //Console.WriteLine(grafo.DarMatriz()[EstacionActualRuta, ruta.DarParadas()[EstacionActual][0]]);
                        siguienteInteraccion += (int)(grafo.DarMatriz()[EstacionActualRuta, ruta.DarParadas()[EstacionActual][0]] / VELOCIDAD_VALLE);
                    }
                }
                else
                {
                    datos[tiempo] = "Espera Atención";
                    siguienteInteraccion++;
                }
            }
            else
            {
                datos[tiempo] = "Espera";
            }
            Utilidades.ExportarInfo(datos, @"Informacion\bus" + this.ruta.GetNombre() + " ", this.GetHashCode());
        }