private double DameValor(double a, double b) { double valor = 0; switch (tipo) { case ('e'): { valor = -a *Math.Log(NrosAleatorios.DameNro()); break; } case ('u'): { valor = (a + (b - a) * NrosAleatorios.DameNro()); break; } case ('w'): { valor = -Math.Log(NrosAleatorios.DameNro()); valor = Math.Pow(valor, 1 / b); valor = a * valor; break; } default: { valor = 0; break; } } return(valor); }
public ServidoresSerie(int c, double tea, List <double> tds) { tipo = 'e'; cantidad = c + 1; TEA = tea; reloj = tiempo_prox_arribo = 0; for (int i = 0; i < cantidad; i++) { TDS.Add(tds[i]); area_bajo_b.Add(0); area_bajo_q.Add(0); tiempo_prox_partida.Add(10000000000); demora_total.Add(0); nro_cli_en_cola.Add(0); nro_cli_comp_dem.Add(0); estado_serv.Add(0); TIOS.Add(0); } if (cantidad != 4) { for (int i = 0; i < 4 - cantidad; i++) { tiempo_prox_partida.Add(0); } } tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); }
public ServidorSimple(double tea, double tds) { tipo = 'e'; TEA = tea; TDS = tds; reloj = area_bajo_b = area_bajo_q = tiempo_prox_arribo = tiempo_prox_partida = TIOS = 0; nro_cli_en_cola = nro_cli_comp_dem = estado_serv = 0; tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); tiempo_prox_partida = 10000000000; }
public ServidorSimple(char ttea, List <double> tea, char ttds, List <double> tds) { tipotea = ttea; tipotds = ttds; if (tipotea == 'u') { tea_a = tea[0]; tea_b = tea[1]; tipo = tipotea; if (tipotds == 'e') { TDS = tds[0]; } else { tds_a = tds[0]; tds_b = tds[1]; } } else if (tipotds == 'u') { tds_a = tds[0]; tds_b = tds[1]; tipo = tipotea; if (tipotea == 'e') { TEA = tea[0]; } else { tea_a = tea[0]; tea_b = tea[1]; } } reloj = area_bajo_b = area_bajo_q = tiempo_prox_arribo = tiempo_prox_partida = TIOS = 0; nro_cli_en_cola = nro_cli_comp_dem = estado_serv = 0; if (tipotea != 'e') { tiempo_prox_arribo = DameValor(tea_a, tea_b); } else { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); } //tiempo_prox_arribo = - tea_a * Math.Log(NrosAleatorios.DameNro()); tiempo_prox_partida = 10000000000; tipo = 'd'; }
private double DameValor(double a, double b) { switch (tipo) { case ('u'): return(a + (b - a) * NrosAleatorios.DameNro()); case ('w'): { double valor = -Math.Log(NrosAleatorios.DameNro()); valor = Math.Pow(valor, 1 / b); valor = a * valor; return(valor); } default: return(0); } }
public void partida() { if (nro_cli_en_cola == 0) { estado_serv[ind] = 0; area_bajo_b[ind] = area_bajo_b[ind] + (reloj - TIOS[ind]); tiempo_prox_partida[ind] = 1000000000; paso[ind] = false; } else { demora_total[ind] = demora_total[ind] + (reloj - arribos[1]); area_bajo_q[ind] = area_bajo_q[ind] + (nro_cli_en_cola * (reloj - tiempo_ult_evento)); arribos.Remove(arribos[1]); nro_cli_en_cola = nro_cli_en_cola - 1; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS[ind] * Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(TDS_a[ind], TDS_b[ind]); } else { tiempo_prox_partida[ind] = -TDS[ind] * Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(TDS_a[ind], TDS_b[ind]); } } }
public void partida() { if (nro_cli_en_cola == 0) { estado_serv = 0; area_bajo_b = area_bajo_b + (reloj - TIOS); tiempo_prox_partida = 1000000000; } else { demora_total = demora_total + (reloj - arribos[1]); area_bajo_q = area_bajo_q + (nro_cli_en_cola * (reloj - tiempo_ult_evento)); arribos.Remove(arribos[1]); nro_cli_en_cola = nro_cli_en_cola - 1; nro_cli_comp_dem = nro_cli_comp_dem + 1; if (tipo == 'e') { tiempo_prox_partida = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida = Exponential.Sample(TDS); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida = DameValor(tds_a, tds_b); } else { tiempo_prox_partida = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida = DameValor(tds_a, tds_b); } } }
public ServidoresSerie(char t, int c, List <double> tea, List <double> tds_a, List <double> tds_b) { tipo = t; cantidad = c + 1; tea_a = tea[0]; tea_b = tea[1]; reloj = tiempo_prox_arribo = 0; for (int i = 0; i < cantidad; i++) { TDS_a.Add(tds_a[i]); TDS_b.Add(tds_b[i]); area_bajo_b.Add(0); area_bajo_q.Add(0); tiempo_prox_partida.Add(10000000000); demora_total.Add(0); nro_cli_en_cola.Add(0); nro_cli_comp_dem.Add(0); estado_serv.Add(0); TIOS.Add(0); } if (cantidad != 4) { for (int i = 0; i < 4 - cantidad; i++) { tiempo_prox_partida.Add(0); } } if (tipo == 'e') { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); } else { tiempo_prox_arribo = DameValor(tea_a, tea_b); } }
public Servidores_paralelos_con_colas_indep(char t, double teaa, double teab, double tdsa, double tdsb, int nro_max, double prob) { tipo = 'd'; nro_cli_max = nro_max; prob_cambio = prob; tea_a = teaa; tea_b = teab; tds_a = tdsa; tds_b = tdsb; tipotds = t; tipotea = t; reloj = tiempo_prox_arribo = 0; for (int i = 0; i < 3; i++) { area_bajo_b.Add(0); area_bajo_q.Add(0); tiempo_prox_partida.Add(10000000000); demora_total.Add(0); nro_cli_comp_dem.Add(0); estado_serv.Add(0); TIOS.Add(0); } if (tipo == 'e') { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); } else { tiempo_prox_arribo = DameValor(tea_a, tea_b); } }
public Servidores_paralelos_con_colas_indep(double tea, double tds, int nro_max, double prob) { tipo = 'e'; prob_cambio = prob; nro_cli_max = nro_max; TDS = tds; TEA = tea; reloj = tiempo_prox_arribo = 0; for (int i = 0; i < 3; i++) { area_bajo_b.Add(0); area_bajo_q.Add(0); tiempo_prox_partida.Add(10000000000); demora_total.Add(0); //nro_cli_en_cola.Add(0); nro_cli_comp_dem.Add(0); estado_serv.Add(0); TIOS.Add(0); } tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); }
public void arribo() { if (tipo == 'e') { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); } else if (tipo == 'd') { tipo = tipotea; if (tipo != 'e') { tiempo_prox_arribo = DameValor(TEA_a, TEA_b); } else { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_arribo = DameValor(TEA_a, TEA_b); //tiempo_prox_arribo = -tea_a * Math.Log(NrosAleatorios.DameNro()); } if (estado_serv[ind] == 0) { TIOS[ind] = reloj; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; estado_serv[ind] = 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS[ind] * Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(TDS_a[ind], TDS_b[ind]); } else { tiempo_prox_partida[ind] = -TDS[ind] * Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(TDS_a[ind], TDS_b[ind]); } } else { nro_cli_en_cola = nro_cli_en_cola + 1; arribos.Add(reloj); } }
public void cambio() { int nro_cli_en_cola_max = 0; int cola_min = 1000; int indsal = 0; /*for (int i = 0; i < 3; i++) * { * if(nro_cli_en_cola[i]>nro_cli_max) * { * if(nro_cli_en_cola[i]>nro_cli_en_cola_max) * { * nro_cli_en_cola_max = nro_cli_en_cola[i]; * indsal = i; * } * } * }*/ if (arribos_s1.Count() > nro_cli_max) { if (arribos_s1.Count() > nro_cli_en_cola_max) { nro_cli_en_cola_max = arribos_s1.Count(); indsal = 0; } } else if (arribos_s2.Count() > nro_cli_max) { if (arribos_s2.Count() > nro_cli_en_cola_max) { nro_cli_en_cola_max = arribos_s2.Count(); indsal = 1; } } else /*(arribos_s3.Count() > nro_cli_max)*/ { if (arribos_s3.Count() > nro_cli_en_cola_max) { nro_cli_en_cola_max = arribos_s3.Count(); indsal = 2; } } if (nro_cli_en_cola_max != 0) { double nro = NrosAleatorios.DameNro(); if (nro <= prob_cambio) { /*for (int i = 0; i < 3; i++) * { * if (nro_cli_en_cola[i] < cola_min) * { * cola_min = nro_cli_en_cola[i]; * ind = i; * } * }*/ if (arribos_s1.Count() < cola_min) { cola_min = arribos_s1.Count(); ind = 0; } else if (arribos_s2.Count() < cola_min) { cola_min = arribos_s2.Count(); ind = 1; } else { cola_min = arribos_s3.Count(); ind = 2; } } switch (indsal) { case 0: { arribo(); arribos_s1.Remove(arribos_s1[arribos_s1.Count - 1]); break; } case 1: { arribo(); arribos_s2.Remove(arribos_s2[arribos_s2.Count - 1]); break; } case 2: { arribo(); arribos_s3.Remove(arribos_s3[arribos_s3.Count - 1]); break; } } } }
public void arribo() { if (tipo == 'e') { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); } else if (tipo == 'd') { tipo = tipotea; if (tipo != 'e') { tiempo_prox_arribo = DameValor(tea_a, tea_b); } else { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_arribo = DameValor(tea_a, tea_b); //tiempo_prox_arribo = -tea_a * Math.Log(NrosAleatorios.DameNro()); } if (estado_serv == 0) { TIOS = reloj; nro_cli_comp_dem = nro_cli_comp_dem + 1; estado_serv = 1; if (tipo == 'e') { tiempo_prox_partida = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida = Exponential.Sample(TDS); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida = DameValor(tds_a, tds_b); } else { tiempo_prox_partida = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida = DameValor(tds_a, tds_b); } } else { nro_cli_en_cola = nro_cli_en_cola + 1; arribos.Add(reloj); } }
private void btn_simular_Click(object sender, EventArgs e) { int msj = Validar(this.Controls); if (msj == 0) { String nom_graf = "Exponencial"; cli_cola = new List <double>(); dem_prom = new List <double>(); utilizacion = new List <double>(); cli_en_cola.Series.Clear(); dem_prom_cli.Series.Clear(); utilizacion_serv.Series.Clear(); cli_en_cola.Series.Add(nom_graf); cli_en_cola.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; cli_en_cola.Series[nom_graf].Color = Color.Green; cli_en_cola.Series[nom_graf].BorderWidth = 3; dem_prom_cli.Series.Add(nom_graf); dem_prom_cli.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; dem_prom_cli.Series[nom_graf].Color = Color.Red; dem_prom_cli.Series[nom_graf].BorderWidth = 3; utilizacion_serv.Series.Add(nom_graf); utilizacion_serv.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; utilizacion_serv.Series[nom_graf].Color = Color.Blue; utilizacion_serv.Series[nom_graf].BorderWidth = 3; NrosAleatorios.GenerarNros(Convert.ToInt32(txtHs.Text)); for (int i = 0; i < tiempos.Length; i++) { ServidorSimple ServidorSimple_Exp; if (arribo) { ServidorSimple_Exp = new ServidorSimple(Convert.ToDouble(txtTEA.Text), tiempos[i]); } else { ServidorSimple_Exp = new ServidorSimple(tiempos[i], Convert.ToDouble(txtTDS.Text)); } while (ServidorSimple_Exp.reloj < Convert.ToDouble(txtHs.Text)) { char proximo_evento = ServidorSimple_Exp.rutinadetiempo(); if (proximo_evento == 'a') { ServidorSimple_Exp.arribo(); } else { ServidorSimple_Exp.partida(); } } DataPoint punto = new DataPoint(tiempos[i], ServidorSimple_Exp.CantPromClientesCola); cli_en_cola.Series[nom_graf].Points.Add(punto); cli_cola.Add(ServidorSimple_Exp.CantPromClientesCola); punto = new DataPoint(tiempos[i], ServidorSimple_Exp.DemPromedio); dem_prom_cli.Series[nom_graf].Points.Add(punto); dem_prom.Add(ServidorSimple_Exp.DemPromedio); punto = new DataPoint(tiempos[i], ServidorSimple_Exp.UtilServidor); utilizacion_serv.Series[nom_graf].Points.Add(punto); utilizacion.Add(ServidorSimple_Exp.UtilServidor); NrosAleatorios.ReiniciarR(); } cli_en_cola.ChartAreas[0].AxisY.Maximum = DameMaximo(cli_cola) * 1.2; dem_prom_cli.ChartAreas[0].AxisY.Maximum = DameMaximo(dem_prom) * 1.2; utilizacion_serv.ChartAreas[0].AxisY.Maximum = DameMaximo(utilizacion) * 1.2; NrosAleatorios.ReiniciarN(); } else { string mensaje = null; switch (msj) { case (1): mensaje = "Existen campos vacíos."; break; case (2): mensaje = "Verifique el formato las horas: deben ser enteras."; break; case (3): mensaje = "El TDS tiene que ser un decimal entre 0,1 y 1."; break; case (4): mensaje = "El TEA tiene que ser un decimal entre 0,1 y 1."; break; case (5): mensaje = "El TDS tiene que ser un decimal entre 0,1 y 1."; break; case (6): mensaje = "El TEA tiene que ser un decimal entre 0,1 y 1."; break; case (7): mensaje = "Debe ingresar un TEA o un TDS"; break; default: break; } MessageBox.Show(mensaje, "¡ Atención !", MessageBoxButtons.OK); } }
internal void partida_arribo(char prox) { int ind1 = 0; int ind2 = 0; switch (prox) { case ('b'): { ind1 = 0; ind2 = 1; break; } case ('c'): { ind1 = 1; ind2 = 2; break; } case ('d'): { ind1 = 2; ind2 = 3; break; } default: { break; } } //Partida servidor ind1 if (nro_cli_en_cola[ind1] == 0) { estado_serv[ind1] = 0; area_bajo_b[ind1] = area_bajo_b[ind1] + (reloj - TIOS[ind1]); tiempo_prox_partida[ind1] = 1000000000; } else { if (prox == 'b') { demora_total[ind1] = demora_total[ind1] + (reloj - arriboss1[1]); arriboss1.Remove(arriboss1[1]); } else if (prox == 'c') { demora_total[ind1] = demora_total[ind1] + (reloj - arriboss2[1]); arriboss2.Remove(arriboss2[1]); } else if (prox == 'd') { demora_total[ind1] = demora_total[ind1] + (reloj - arriboss3[1]); arriboss3.Remove(arriboss3[1]); } area_bajo_q[ind1] = area_bajo_q[ind1] + (nro_cli_en_cola[ind1] * (reloj - tiempo_ult_evento)); nro_cli_en_cola[ind1] = nro_cli_en_cola[ind1] - 1; nro_cli_comp_dem[ind1] = nro_cli_comp_dem[ind1] + 1; if (tipo == 'e') { tiempo_prox_partida[ind1] = -TDS[ind1] * Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind1] = DameValor(TDS_a[ind1], TDS_b[ind1]); } else { tiempo_prox_partida[ind1] = -TDS[ind1] * Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind1] = DameValor(TDS_a[ind1], TDS_b[ind1]); } } //Arribo servidor ind2 if (estado_serv[ind2] == 0) { nro_cli_comp_dem[ind2] = nro_cli_comp_dem[ind2] + 1; TIOS[ind2] = reloj; estado_serv[ind2] = 1; if (tipo == 'e') { tiempo_prox_partida[ind2] = -TDS[ind2] * Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind2] = DameValor(TDS_a[ind2], TDS_b[ind2]); } else { tiempo_prox_partida[ind2] = -TDS[ind2] * Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind2] = DameValor(TDS_a[ind2], TDS_b[ind2]); } } else { nro_cli_en_cola[ind2] = nro_cli_en_cola[ind2] + 1; if (prox == 'b') { arriboss2.Add(reloj); } else if (prox == 'c') { arriboss3.Add(reloj); } else if (prox == 'd') { arriboss4.Add(reloj); } } }
public void partida() { if (nro_cli_en_cola[cantidad - 1] == 0) { estado_serv[cantidad - 1] = 0; area_bajo_b[cantidad - 1] = area_bajo_b[cantidad - 1] + (reloj - TIOS[cantidad - 1]); tiempo_prox_partida[cantidad - 1] = 1000000000; } else { if (cantidad == 2) { demora_total[cantidad - 1] = demora_total[cantidad - 1] + (reloj - arriboss2[1]); arriboss2.Remove(arriboss2[1]); } else if (cantidad == 3) { demora_total[cantidad - 1] = demora_total[cantidad - 1] + (reloj - arriboss3[1]); arriboss3.Remove(arriboss3[1]); } else if (cantidad == 4) { demora_total[cantidad - 1] = demora_total[cantidad - 1] + (reloj - arriboss4[1]); arriboss4.Remove(arriboss4[1]); } area_bajo_q[cantidad - 1] = area_bajo_q[cantidad - 1] + (nro_cli_en_cola[cantidad - 1] * (reloj - tiempo_ult_evento)); nro_cli_en_cola[cantidad - 1] = nro_cli_en_cola[cantidad - 1] - 1; nro_cli_comp_dem[cantidad - 1] = nro_cli_comp_dem[cantidad - 1] + 1; if (tipo == 'e') { tiempo_prox_partida[cantidad - 1] = -TDS[cantidad - 1] * Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[cantidad - 1] = DameValor(TDS_a[cantidad - 1], TDS_b[cantidad - 1]); } else { tiempo_prox_partida[cantidad - 1] = -TDS[cantidad - 1] * Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[cantidad - 1] = DameValor(TDS_a[cantidad - 1], TDS_b[cantidad - 1]); } } }
public ServidoresParalelo(int cant, char ttea, List <double> tea, char ttds, List <double> tds) { cantidad = cant + 1; tipotea = ttea; tipotds = ttds; if (tipotea == 'u') { TEA_a = tea[0]; TEA_b = tea[1]; tipo = tipotea; for (int i = 0; i < cantidad; i++) { if (tipotds == 'e') { TDS.Add(tds[0]); } else { TDS_a.Add(tds[0]); TDS_b.Add(tds[1]); } } } else if (tipotds == 'u') { int h = cantidad * 2; for (int i = 0; i < h; i++) { if (i == 0) { TDS_a.Add(tds[i]); } else { if (i % 2 == 0) { TDS_a.Add(tds[i]); } else { TDS_b.Add(tds[i]); } } } tipo = tipotea; if (tipotea == 'e') { TEA = tea[0]; } else { TEA_a = tea[0]; TEA_b = tea[1]; } } for (int i = 0; i < cantidad; i++) { area_bajo_b.Add(0); area_bajo_q.Add(0); tiempo_prox_partida.Add(10000000000); demora_total.Add(0); nro_cli_en_cola = 0; nro_cli_comp_dem.Add(0); estado_serv.Add(0); TIOS.Add(0); } if (tipotea != 'e') { tiempo_prox_arribo = DameValor(TEA_a, TEA_b); } else { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; }
public void arribo() { if (tipo == 'e') { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_arribo = Exponential.Sample(TEA); } else if (tipo == 'd') { tipo = tipotea; if (tipo != 'e') { tiempo_prox_arribo = DameValor(tea_a, tea_b); } else { tiempo_prox_arribo = -TEA *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_arribo = DameValor(tea_a, tea_b); //tiempo_prox_arribo = -tea_a * Math.Log(NrosAleatorios.DameNro()); } if (estado_serv[ind] == 0) { TIOS[ind] = reloj; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; estado_serv[ind] = 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } else { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } } else { //nro_cli_en_cola[ind] = nro_cli_en_cola[ind] + 1; switch (ind) { case 0: { arribos_s1.Add(reloj); break; } case 1: { arribos_s2.Add(reloj); break; } case 2: { arribos_s3.Add(reloj); break; } default: { break; } } } }
private void btn_simular_Click(object sender, EventArgs e) { int msj = Validar(this.Controls); if (msj == 0) { String nom_graf = "Exponencial"; c = form_cantidadservidores.nro + 1; cli_en_cola_s1.Series.Clear(); cli_en_cola_s2.Series.Clear(); dem_prom_cli_s1.Series.Clear(); dem_prom_cli_s2.Series.Clear(); utilizacion_serv1.Series.Clear(); utilizacion_serv2.Series.Clear(); cli_cola1 = new List <double>(); dem_prom1 = new List <double>(); utilizacion1 = new List <double>(); cli_cola2 = new List <double>(); dem_prom2 = new List <double>(); utilizacion2 = new List <double>(); cli_en_cola_s1.Series.Add(nom_graf); cli_en_cola_s1.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; cli_en_cola_s1.Series[nom_graf].Color = Color.Green; cli_en_cola_s1.Series[nom_graf].BorderWidth = 3; cli_en_cola_s2.Series.Add(nom_graf); cli_en_cola_s2.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; cli_en_cola_s2.Series[nom_graf].Color = Color.Green; cli_en_cola_s2.Series[nom_graf].BorderWidth = 3; dem_prom_cli_s1.Series.Add(nom_graf); dem_prom_cli_s1.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; dem_prom_cli_s1.Series[nom_graf].Color = Color.Red; dem_prom_cli_s1.Series[nom_graf].BorderWidth = 3; dem_prom_cli_s2.Series.Add(nom_graf); dem_prom_cli_s2.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; dem_prom_cli_s2.Series[nom_graf].Color = Color.Red; dem_prom_cli_s2.Series[nom_graf].BorderWidth = 3; utilizacion_serv1.Series.Add(nom_graf); utilizacion_serv1.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; utilizacion_serv1.Series[nom_graf].Color = Color.Blue; utilizacion_serv1.Series[nom_graf].BorderWidth = 3; utilizacion_serv2.Series.Add(nom_graf); utilizacion_serv2.Series[nom_graf].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column; utilizacion_serv2.Series[nom_graf].Color = Color.Blue; utilizacion_serv2.Series[nom_graf].BorderWidth = 3; NrosAleatorios.GenerarNros(Convert.ToInt32(txtHs.Text)); for (int i = 0; i < tiempos.Length; i++) { ServidoresSerie ServidoresSerie_Exp; TDS = new List <double>(); if (arribo) { TDS.Add(tiempos[i]); TDS.Add(tiempos[i]); ServidoresSerie_Exp = new ServidoresSerie(c, Convert.ToDouble(txtTEA.Text), TDS); } else { TDS.Add(Convert.ToDouble(this.txtTDS1.Text)); TDS.Add(Convert.ToDouble(this.txtTDS2.Text)); ServidoresSerie_Exp = new ServidoresSerie(c, tiempos[i], TDS); } while (ServidoresSerie_Exp.reloj < Convert.ToDouble(txtHs.Text)) { char proximo_evento = ServidoresSerie_Exp.rutinadetiempo(); if (proximo_evento == 'a') { ServidoresSerie_Exp.arribo(); } else if (proximo_evento == 'b') { ServidoresSerie_Exp.partida_arribo(proximo_evento); } else if (proximo_evento == 'c') { ServidoresSerie_Exp.partida_arribo(proximo_evento); } else if (proximo_evento == 'd') { ServidoresSerie_Exp.partida_arribo(proximo_evento); } else { ServidoresSerie_Exp.partida(); } } cli_en_cola_s1.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.CantPromClientesColaS(0))); cli_en_cola_s2.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.CantPromClientesColaS(1))); cli_cola1.Add(ServidoresSerie_Exp.CantPromClientesColaS(0)); cli_cola2.Add(ServidoresSerie_Exp.CantPromClientesColaS(1)); dem_prom_cli_s1.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.DemPromedioS(0))); dem_prom_cli_s2.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.DemPromedioS(1))); dem_prom1.Add(ServidoresSerie_Exp.DemPromedioS(0)); dem_prom2.Add(ServidoresSerie_Exp.DemPromedioS(1)); utilizacion_serv1.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.UtilServidor(0))); utilizacion_serv2.Series[nom_graf].Points.Add(new DataPoint(tiempos[i], ServidoresSerie_Exp.UtilServidor(1))); utilizacion1.Add(ServidoresSerie_Exp.UtilServidor(0)); utilizacion2.Add(ServidoresSerie_Exp.UtilServidor(1)); NrosAleatorios.ReiniciarR(); } cli_en_cola_s1.ChartAreas[0].AxisY.Maximum = DameMaximo(cli_cola1) * 1.2; dem_prom_cli_s1.ChartAreas[0].AxisY.Maximum = DameMaximo(dem_prom1) * 1.2; utilizacion_serv1.ChartAreas[0].AxisY.Maximum = DameMaximo(utilizacion1) * 1.2; cli_en_cola_s2.ChartAreas[0].AxisY.Maximum = DameMaximo(cli_cola2) * 1.2; dem_prom_cli_s2.ChartAreas[0].AxisY.Maximum = DameMaximo(dem_prom2) * 1.2; utilizacion_serv2.ChartAreas[0].AxisY.Maximum = DameMaximo(utilizacion2) * 1.2; NrosAleatorios.ReiniciarN(); } else { string mensaje = null; switch (msj) { case (1): mensaje = "Existen campos vacíos."; break; case (2): mensaje = "Verifique el formato las horas: deben ser enteras."; break; case (3): mensaje = "Los TDS tienen que ser números decimales entre 0,1 y 1."; break; case (4): mensaje = "El TEA tiene que ser un decimal entre 0,1 y 1."; break; case (5): mensaje = "Los TDS tienen que ser números decimales entre 0,1 y 1."; break; case (6): mensaje = "El TEA tiene que ser un decimal entre 0,1 y 1."; break; case (7): mensaje = "Debe ingresar el TEA o los TDS"; break; default: break; } MessageBox.Show(mensaje, "¡ Atención !", MessageBoxButtons.OK); } }
public void partida() { switch (ind) { case 0: { if (arribos_s1.Count() == 0) { estado_serv[ind] = 0; area_bajo_b[ind] = area_bajo_b[ind] + (reloj - TIOS[ind]); tiempo_prox_partida[ind] = 1000000000; } else { demora_total[ind] = demora_total[ind] + (reloj - arribos_s1[0]); area_bajo_q[ind] = area_bajo_q[ind] + (/*nro_cli_en_cola[ind]*/ arribos_s1.Count() * (reloj - tiempo_ult_evento)); arribos_s1.Remove(arribos_s1[0]); //nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } else { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } } break; } case 1: { if (arribos_s2.Count() == 0) { estado_serv[ind] = 0; area_bajo_b[ind] = area_bajo_b[ind] + (reloj - TIOS[ind]); tiempo_prox_partida[ind] = 1000000000; } else { demora_total[ind] = demora_total[ind] + (reloj - arribos_s2[0]); area_bajo_q[ind] = area_bajo_q[ind] + (/*nro_cli_en_cola[ind]*/ arribos_s2.Count() * (reloj - tiempo_ult_evento)); arribos_s2.Remove(arribos_s2[0]); //nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } else { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } } break; } case 2: { if (arribos_s3.Count() == 0) { estado_serv[ind] = 0; area_bajo_b[ind] = area_bajo_b[ind] + (reloj - TIOS[ind]); tiempo_prox_partida[ind] = 1000000000; } else { demora_total[ind] = demora_total[ind] + (reloj - arribos_s3[0]); area_bajo_q[ind] = area_bajo_q[ind] + (/*nro_cli_en_cola[ind]*/ arribos_s3.Count() * (reloj - tiempo_ult_evento)); arribos_s3.Remove(arribos_s3[0]); //nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; if (tipo == 'e') { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); } else if (tipo == 'd') { tipo = tipotds; if (tipo != 'e') { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } else { tiempo_prox_partida[ind] = -TDS *Math.Log(NrosAleatorios.DameNro()); } tipo = 'd'; } else { tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); } } break; } } /* * if (nro_cli_en_cola[ind] == 0) * { * estado_serv[ind] = 0; * area_bajo_b[ind] = area_bajo_b[ind] + (reloj - TIOS[ind]); * tiempo_prox_partida[ind] = 1000000000; * //paso[ind] = false; * } * else * { * switch (ind) * { * case 0: * { * demora_total[ind] = demora_total[ind] + (reloj - arribos_s1[0]); * area_bajo_q[ind] = area_bajo_q[ind] + (nro_cli_en_cola[ind] * (reloj - tiempo_ult_evento)); * arribos_s1.Remove(arribos_s1[0]); * nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; * nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; * * if (tipo == 'e') * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); * } * else if (tipo == 'd') * { * tipo = tipotds; * if (tipo != 'e') * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * else * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * } * tipo = 'd'; * } * else * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * break; * } * case 1: * { * demora_total[ind] = demora_total[ind] + (reloj - arribos_s2[0]); * area_bajo_q[ind] = area_bajo_q[ind] + (nro_cli_en_cola[ind] * (reloj - tiempo_ult_evento)); * arribos_s2.Remove(arribos_s2[0]); * nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; * nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; * * if (tipo == 'e') * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); * } * else if (tipo == 'd') * { * tipo = tipotds; * if (tipo != 'e') * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * else * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * } * tipo = 'd'; * } * else * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * break; * } * case 2: * { * demora_total[ind] = demora_total[ind] + (reloj - arribos_s3[0]); * area_bajo_q[ind] = area_bajo_q[ind] + (nro_cli_en_cola[ind] * (reloj - tiempo_ult_evento)); * arribos_s3.Remove(arribos_s3[0]); * nro_cli_en_cola[ind] = nro_cli_en_cola[ind] - 1; * nro_cli_comp_dem[ind] = nro_cli_comp_dem[ind] + 1; * * if (tipo == 'e') * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * //tiempo_prox_partida[ind] = Exponential.Sample(TDS[ind]); * } * else if (tipo == 'd') * { * tipo = tipotds; * if (tipo != 'e') * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * else * { * tiempo_prox_partida[ind] = -TDS * Math.Log(NrosAleatorios.DameNro()); * } * tipo = 'd'; * } * else * { * tiempo_prox_partida[ind] = DameValor(tds_a, tds_b); * } * break; * } * } * }*/ }