/// <summary> /// Calculate a new step /// The result is stored in Delta /// Note: This method does not advance time! /// </summary> /// <param name="simulation">Time-based simulation</param> /// <returns>True if the timestep isn't cut</returns> public bool LteControl(TimeSimulation simulation) { // Invoke truncation event TruncationEventArgs args = new TruncationEventArgs(simulation, Delta); Truncate?.Invoke(this, args); double newdelta = args.Delta; if (newdelta > 0.9 * Delta) { if (Order == 1) { Order = 2; // Invoke truncation event args = new TruncationEventArgs(simulation, Delta); Truncate?.Invoke(this, args); newdelta = args.Delta; if (newdelta <= 1.05 * Delta) { Order = 1; } } Delta = newdelta; return(true); } // Truncation too strict, we'll have to recalculate the timepoint Rollback(); Delta = newdelta; return(false); }
public double[] expNeg(double[] vectorAleatorios, double parametro, bool esFrecuencia) { int cantidad = vectorAleatorios.Length; double frecuencia = 0; // Verifico si el parametro ingresado es frecuencia. // True : Si es así lo copio tal cual (Frecuencia = parametro) // False : Si no lo es (porque es una media), calculo la frecuencia segun la media (Frecuencia = 1/parametro). if (esFrecuencia) { frecuencia = parametro; } else { frecuencia = 1 / parametro; } double[] vectorExpNeg = new double[cantidad]; for (int i = 0; i < cantidad; i++) { // X = (-1/frecuencia) * ln(1 - RND) double X = (-1 / frecuencia) * Math.Log(1 - vectorAleatorios[i]); vectorExpNeg[i] = Truncate.truncar(X, 4); } return(vectorExpNeg); }
public void TestCleanup() { using (ApplicationDbContext context = new ApplicationDbContext()) { Truncate.Exec(context); Seed.Exec(context); Console.WriteLine("TestCleanup"); } }
public void Truncate_Left_To_Right() { var truncate = new Truncate(234, TruncateMethod.LeftToRight); Assert.IsTrue(truncate.CanTruncate()); Assert.AreEqual(34, truncate.NextValue()); Assert.IsTrue(truncate.CanTruncate()); Assert.AreEqual(4, truncate.NextValue()); Assert.IsFalse(truncate.CanTruncate()); Assert.AreEqual(4, truncate.CurrentValue()); }
public void Truncate_Right_To_Left() { var truncate = new Truncate(345, TruncateMethod.RightToLeft); Assert.IsTrue(truncate.CanTruncate()); Assert.AreEqual(34, truncate.NextValue()); Assert.IsTrue(truncate.CanTruncate()); Assert.AreEqual(3, truncate.NextValue()); Assert.IsFalse(truncate.CanTruncate()); Assert.AreEqual(3, truncate.CurrentValue()); }
public override string Transform(string text) { string tx = IgnoreCase ? text.ToUpper() : text; string tc = IgnoreCase ? Truncate.ToUpper() : Truncate; if (FromStart && tx.StartsWith(tc)) { return(text.Substring(Truncate.Length)); } else if (tx.EndsWith(tc)) { return(text.Substring(0, text.Length - Truncate.Length)); } return(text); }
public double[] generarAleatorios01(int cantidad) { double[] vectorAleatorios = new double[cantidad]; Random aleatorio = new Random(); for (int i = 0; i < cantidad; i++) { double num = Truncate.truncar(aleatorio.NextDouble(), 4); if (num == 0) { num = 0.0001; } vectorAleatorios[i] = num; } return(vectorAleatorios); }
//X = vectorUniforme[i]; //A = limiteInferior; //B = limiteSuperior; //RND = vectorAleatorios[i]; public double[] uniforme(double[] vectorAleatorios, double limiteInferior, double limiteSuperior) { // obtengo cantidad de numeros a generar int cantidad = vectorAleatorios.Length; // Genero vector con distribucion uniforme (A-B) double[] vectorUniforme = new double[cantidad]; for (int i = 0; i < cantidad; i++) { // X = A + RND * (B-A); -> Formula para generar Uniformes (A-B) double X = limiteInferior + vectorAleatorios[i] * (limiteSuperior - limiteInferior); vectorUniforme[i] = Truncate.truncar(X, 4); } return(vectorUniforme); }
public void TestThrowsExceptionOnNegativeSize() { long negativeSize = -42; string fileName = Path.GetRandomFileName(); List <string> files = new List <string>(); files.Add(fileName); try { Truncate.TruncateFiles(new TruncateOptions { Size = negativeSize }, files); } finally { new FileInfo(fileName).Delete(); } }
protected void Page_Load(object sender, EventArgs e) { DataTable dtSeneste = new DataTable(); dtSeneste = objCar.hentSenest(); if (!IsPostBack) { foreach (DataRow drSenest in dtSeneste.Rows) { //RouteValueDictionary parameters = new RouteValueDictionary //{ // { "id", drSenest["fldDelID"].ToString() }, // { "NiceUrl", Funtioner.CreateNiceUrl(drSenest["fldDelNavn"].ToString()) } //}; //VirtualPathData vpd = RouteTable.Routes.GetVirtualPath(null, "Bestillingsiden", parameters); litSeneste.Text += "<div class='column-prod'>"; litSeneste.Text += "<div class='seneste-prod'>"; litSeneste.Text += "<a href='Produkt.aspx?id=" + drSenest["fldDelID"] + "'>" + "<img src='Images/Dele/" + drSenest["fldDelBillede"] + "' alt='" + drSenest["fldDelNavn"] + "' class='senest-img' style='margin-bottom: 5px;' ></a>"; litSeneste.Text += "<h4>" + drSenest["fldDelNavn"] + "</h4>"; litSeneste.Text += "<p><b>Mærke: " + drSenest["fldMaerkeNavn"] + "</b></p>"; litSeneste.Text += "<p>" + Truncate.TruncateAtWord(drSenest["fldDelTekst"].ToString(), 118) + "</p>"; litSeneste.Text += "<a href='Produkt.aspx?id=" + drSenest["fldDelID"] + "' class='btn-laesmere'>Se Produkt</a>"; litSeneste.Text += "</div>"; litSeneste.Text += "</div>"; } DataTable dtMaerke = objCar.hentmaerke(); ddlMaerke.Items.Add(new ListItem("-- Vælg Mærke --", "0")); foreach (DataRow drMaerke in dtMaerke.Rows) { ddlMaerke.Items.Add(new ListItem(drMaerke["fldMaerkeNavn"].ToString(), drMaerke["fldMaerkeID"].ToString())); } } }
public IEnumerator <ITask> TruncateHandler(Truncate truncate) { double value; #if URT_MINCLR if (truncate.Body.A >= 0.0) { value = math.Floor(truncate.Body.A); } else { value = math.Ceiling(truncate.Body.A); } #else value = math.Truncate(truncate.Body.A); #endif truncate.ResponsePort.Post(new Response(value)); yield break; }
public static void Decode(ModuleDefMD module) { Log10.RemovedMutations(module); Log.RemovedMutations(module); //Cos.RemovedMutations(module); Truncate.RemovedMutations(module); Floor.RemovedMutations(module); Round.RemoveMutations(module); DoubleParse.RemoveMutations(module); Length.RemoveMutations(module); EmpyTypes.RemoveMutations(module); Abs.RemoveMutations(module); SizeOf.RemoveMutations(module); Add.RemoveMutations(module); Sub.RemoveMutations(module); Mul.RemoveMutations(module); Div.RemoveMutations(module); ToInt32.RemoveMutations(module); Xor.RemoveMutations(module); Ldci4ToConvi4Handler.Fix(module); }
public double[] normal(double[] vectorAleatorios, double media, double desviacion) { int cantidad = vectorAleatorios.Length; double[] vectorNormal = new double[cantidad]; for (int i = 0; i < cantidad; i += 2) { // N1 = ((-2 * ln(RND1)^0,5).cos(2.Pi.RND2)) * desviacion + media // N2 = ((-2 * ln(RND1)^0,5).sen(2.Pi.RND2)) * desviacion + media double RND1 = vectorAleatorios[i]; double RND2 = vectorAleatorios[i + 1]; double PI = Math.PI; double n1 = (Math.Pow(-2 * Math.Log(RND1), 0.5) * Math.Cos(2 * PI * RND2)) * desviacion + media; double n2 = (Math.Pow(-2 * Math.Log(RND1), 0.5) * Math.Sin(2 * PI * RND2)) * desviacion + media; vectorNormal[i] = Truncate.truncar(n1, 4); vectorNormal[i + 1] = Truncate.truncar(n2, 4); } return(vectorNormal); }
public MySqlFunctionManager(bool allowFuncDefChange) { this.allowFuncDefChange = allowFuncDefChange; parsingStrateg["CAST"] = FunctionParsingStrategy.Cast; parsingStrateg["POSITION"] = FunctionParsingStrategy.Position; parsingStrateg["SUBSTR"] = FunctionParsingStrategy.Substring; parsingStrateg["SUBSTRING"] = FunctionParsingStrategy.Substring; parsingStrateg["TRIM"] = FunctionParsingStrategy.Trim; parsingStrateg["AVG"] = FunctionParsingStrategy.Avg; parsingStrateg["COUNT"] = FunctionParsingStrategy.Count; parsingStrateg["GROUP_CONCAT"] = FunctionParsingStrategy.GroupConcat; parsingStrateg["MAX"] = FunctionParsingStrategy.Max; parsingStrateg["MIN"] = FunctionParsingStrategy.Min; parsingStrateg["SUM"] = FunctionParsingStrategy.Sum; parsingStrateg["ROW"] = FunctionParsingStrategy.Row; parsingStrateg["CHAR"] = FunctionParsingStrategy.Char; parsingStrateg["CONVERT"] = FunctionParsingStrategy.Convert; parsingStrateg["EXTRACT"] = FunctionParsingStrategy.Extract; parsingStrateg["TIMESTAMPADD"] = FunctionParsingStrategy.Timestampadd; parsingStrateg["TIMESTAMPDIFF"] = FunctionParsingStrategy.Timestampdiff; parsingStrateg["GET_FORMAT"] = FunctionParsingStrategy.GetFormat; functionPrototype["ABS"] = new Abs(null); functionPrototype["ACOS"] = new Acos(null); functionPrototype["ADDDATE"] = new Adddate(null); functionPrototype["ADDTIME"] = new Addtime(null); functionPrototype["AES_DECRYPT"] = new AesDecrypt(null); functionPrototype["AES_ENCRYPT"] = new AesEncrypt(null); functionPrototype["ANALYSE"] = new Analyse(null); functionPrototype["ASCII"] = new Ascii(null); functionPrototype["ASIN"] = new Asin(null); functionPrototype["ATAN2"] = new Atan2(null); functionPrototype["ATAN"] = new Atan(null); functionPrototype["BENCHMARK"] = new Benchmark(null); functionPrototype["BIN"] = new Bin(null); functionPrototype["BIT_AND"] = new BitAnd(null); functionPrototype["BIT_COUNT"] = new BitCount(null); functionPrototype["BIT_LENGTH"] = new BitLength(null); functionPrototype["BIT_OR"] = new BitOR(null); functionPrototype["BIT_XOR"] = new BitXor(null); functionPrototype["CEIL"] = new Ceiling(null); functionPrototype["CEILING"] = new Ceiling(null); functionPrototype["CHAR_LENGTH"] = new CharLength(null); functionPrototype["CHARACTER_LENGTH"] = new CharLength(null); functionPrototype["CHARSET"] = new Charset(null); functionPrototype["COALESCE"] = new Coalesce(null); functionPrototype["COERCIBILITY"] = new Coercibility(null); functionPrototype["COLLATION"] = new Collation(null); functionPrototype["COMPRESS"] = new Compress(null); functionPrototype["CONCAT_WS"] = new ConcatWs(null); functionPrototype["CONCAT"] = new Concat(null); functionPrototype["CONNECTION_ID"] = new ConnectionId(null); functionPrototype["CONV"] = new Conv(null); functionPrototype["CONVERT_TZ"] = new ConvertTz(null); functionPrototype["COS"] = new Cos(null); functionPrototype["COT"] = new Cot(null); functionPrototype["CRC32"] = new Crc32(null); functionPrototype["CURDATE"] = new Curdate(); functionPrototype["CURRENT_DATE"] = new Curdate(); functionPrototype["CURRENT_TIME"] = new Curtime(); functionPrototype["CURTIME"] = new Curtime(); functionPrototype["CURRENT_TIMESTAMP"] = new Now(); functionPrototype["CURRENT_USER"] = new CurrentUser(); functionPrototype["CURTIME"] = new Curtime(); functionPrototype["DATABASE"] = new Database(null); functionPrototype["DATE_ADD"] = new DateAdd(null); functionPrototype["DATE_FORMAT"] = new DateFormat(null); functionPrototype["DATE_SUB"] = new DateSub(null); functionPrototype["DATE"] = new Date(null); functionPrototype["DATEDIFF"] = new Datediff(null); functionPrototype["DAY"] = new Dayofmonth(null); functionPrototype["DAYOFMONTH"] = new Dayofmonth(null); functionPrototype["DAYNAME"] = new Dayname(null); functionPrototype["DAYOFWEEK"] = new Dayofweek(null); functionPrototype["DAYOFYEAR"] = new Dayofyear(null); functionPrototype["DECODE"] = new Decode(null); functionPrototype["DEFAULT"] = new Default(null); functionPrototype["DEGREES"] = new Degrees(null); functionPrototype["DES_DECRYPT"] = new DesDecrypt(null); functionPrototype["DES_ENCRYPT"] = new DesEncrypt(null); functionPrototype["ELT"] = new Elt(null); functionPrototype["ENCODE"] = new Encode(null); functionPrototype["ENCRYPT"] = new Encrypt(null); functionPrototype["EXP"] = new Exp(null); functionPrototype["EXPORT_SET"] = new ExportSet(null); // functionPrototype.put("EXTRACT", new Extract(null)); functionPrototype["EXTRACTVALUE"] = new ExtractValue(null); functionPrototype["FIELD"] = new Field(null); functionPrototype["FIND_IN_SET"] = new FindInSet(null); functionPrototype["FLOOR"] = new Floor(null); functionPrototype["FORMAT"] = new Format(null); functionPrototype["FOUND_ROWS"] = new FoundRows(null); functionPrototype["FROM_DAYS"] = new FromDays(null); functionPrototype["FROM_UNIXTIME"] = new FromUnixtime(null); // functionPrototype.put("GET_FORMAT", new GetFormat(null)); functionPrototype["GET_LOCK"] = new GetLock(null); functionPrototype["GREATEST"] = new Greatest(null); functionPrototype["HEX"] = new Hex(null); functionPrototype["HOUR"] = new Hour(null); functionPrototype["IF"] = new IF(null); functionPrototype["IFNULL"] = new IFNull(null); functionPrototype["INET_ATON"] = new InetAton(null); functionPrototype["INET_NTOA"] = new InetNtoa(null); functionPrototype["INSERT"] = new Insert(null); functionPrototype["INSTR"] = new Instr(null); functionPrototype["INTERVAL"] = new Interval(null); functionPrototype["IS_FREE_LOCK"] = new IsFreeLock(null); functionPrototype["IS_USED_LOCK"] = new IsUsedLock(null); functionPrototype["ISNULL"] = new IsNull(null); functionPrototype["LAST_DAY"] = new LastDay(null); functionPrototype["LAST_INSERT_ID"] = new LastInsertId(null); functionPrototype["LCASE"] = new Lower(null); functionPrototype["LEAST"] = new Least(null); functionPrototype["LEFT"] = new Left(null); functionPrototype["LENGTH"] = new Length(null); functionPrototype["LN"] = new Log(null); // Ln(X) equals Log(X) functionPrototype["LOAD_FILE"] = new LoadFile(null); functionPrototype["LOCALTIME"] = new Now(); functionPrototype["LOCALTIMESTAMP"] = new Now(); functionPrototype["LOCATE"] = new Locate(null); functionPrototype["LOG10"] = new Log10(null); functionPrototype["LOG2"] = new Log2(null); functionPrototype["LOG"] = new Log(null); functionPrototype["LOWER"] = new Lower(null); functionPrototype["LPAD"] = new Lpad(null); functionPrototype["LTRIM"] = new Ltrim(null); functionPrototype["MAKE_SET"] = new MakeSet(null); functionPrototype["MAKEDATE"] = new Makedate(null); functionPrototype["MAKETIME"] = new Maketime(null); functionPrototype["MASTER_POS_WAIT"] = new MasterPosWait(null); functionPrototype["MD5"] = new Md5(null); functionPrototype["MICROSECOND"] = new Microsecond(null); functionPrototype["MID"] = new Substring(null); functionPrototype["MINUTE"] = new Minute(null); functionPrototype["MONTH"] = new Month(null); functionPrototype["MONTHNAME"] = new Monthname(null); functionPrototype["NAME_CONST"] = new NameConst(null); functionPrototype["NOW"] = new Now(); functionPrototype["NULLIF"] = new NullIF(null); functionPrototype["OCT"] = new Oct(null); functionPrototype["OCTET_LENGTH"] = new Length(null); functionPrototype["OLD_PASSWORD"] = new OldPassword(null); functionPrototype["ORD"] = new Ord(null); functionPrototype["PASSWORD"] = new Password(null); functionPrototype["PERIOD_ADD"] = new PeriodAdd(null); functionPrototype["PERIOD_DIFF"] = new PeriodDiff(null); functionPrototype["PI"] = new PI(null); functionPrototype["POW"] = new Pow(null); functionPrototype["POWER"] = new Pow(null); functionPrototype["QUARTER"] = new Quarter(null); functionPrototype["QUOTE"] = new Quote(null); functionPrototype["RADIANS"] = new Radians(null); functionPrototype["RAND"] = new Rand(null); functionPrototype["RELEASE_LOCK"] = new ReleaseLock(null); functionPrototype["REPEAT"] = new Repeat(null); functionPrototype["REPLACE"] = new Replace(null); functionPrototype["REVERSE"] = new Reverse(null); functionPrototype["RIGHT"] = new Right(null); functionPrototype["ROUND"] = new Round(null); functionPrototype["ROW_COUNT"] = new RowCount(null); functionPrototype["RPAD"] = new Rpad(null); functionPrototype["RTRIM"] = new Rtrim(null); functionPrototype["SCHEMA"] = new Database(null); functionPrototype["SEC_TO_TIME"] = new SecToTime(null); functionPrototype["SECOND"] = new Second(null); functionPrototype["SESSION_USER"] = new User(null); functionPrototype["SHA1"] = new Sha1(null); functionPrototype["SHA"] = new Sha1(null); functionPrototype["SHA2"] = new Sha2(null); functionPrototype["SIGN"] = new Sign(null); functionPrototype["SIN"] = new Sin(null); functionPrototype["SLEEP"] = new Sleep(null); functionPrototype["SOUNDEX"] = new Soundex(null); functionPrototype["SPACE"] = new Space(null); functionPrototype["SQRT"] = new Sqrt(null); functionPrototype["STD"] = new Std(null); functionPrototype["STDDEV_POP"] = new StdDevPop(null); functionPrototype["STDDEV_SAMP"] = new StdDevSamp(null); functionPrototype["STDDEV"] = new StdDev(null); functionPrototype["STR_TO_DATE"] = new StrToDate(null); functionPrototype["STRCMP"] = new Strcmp(null); functionPrototype["SUBDATE"] = new Subdate(null); functionPrototype["SUBSTRING_INDEX"] = new SubstringIndex(null); functionPrototype["SUBTIME"] = new Subtime(null); functionPrototype["SYSDATE"] = new Sysdate(null); functionPrototype["SYSTEM_USER"] = new User(null); functionPrototype["TAN"] = new Tan(null); functionPrototype["TIME_FORMAT"] = new TimeFormat(null); functionPrototype["TIME_TO_SEC"] = new TimeToSec(null); functionPrototype["TIME"] = new Time(null); functionPrototype["TIMEDIFF"] = new Timediff(null); functionPrototype["TIMESTAMP"] = new Timestamp(null); // functionPrototype.put("TIMESTAMPADD", new Timestampadd(null)); // functionPrototype.put("TIMESTAMPDIFF", new Timestampdiff(null)); functionPrototype["TO_DAYS"] = new ToDays(null); functionPrototype["TO_SECONDS"] = new ToSeconds(null); functionPrototype["TRUNCATE"] = new Truncate(null); functionPrototype["UCASE"] = new Upper(null); functionPrototype["UNCOMPRESS"] = new Uncompress(null); functionPrototype["UNCOMPRESSED_LENGTH"] = new UncompressedLength(null); functionPrototype["UNHEX"] = new Unhex(null); functionPrototype["UNIX_TIMESTAMP"] = new UnixTimestamp(null); functionPrototype["UPDATEXML"] = new UpdateXml(null); functionPrototype["UPPER"] = new Upper(null); functionPrototype["USER"] = new User(null); functionPrototype["UTC_DATE"] = new UtcDate(null); functionPrototype["UTC_TIME"] = new UtcTime(null); functionPrototype["UTC_TIMESTAMP"] = new UtcTimestamp(null); functionPrototype["UUID_SHORT"] = new UuidShort(null); functionPrototype["UUID"] = new Uuid(null); functionPrototype["VALUES"] = new Values(null); functionPrototype["VAR_POP"] = new VarPop(null); functionPrototype["VAR_SAMP"] = new VarSamp(null); functionPrototype["VARIANCE"] = new Variance(null); functionPrototype["VERSION"] = new Version(null); functionPrototype["WEEK"] = new Week(null); functionPrototype["WEEKDAY"] = new Weekday(null); functionPrototype["WEEKOFYEAR"] = new Weekofyear(null); functionPrototype["YEAR"] = new Year(null); functionPrototype["YEARWEEK"] = new Yearweek(null); }
public virtual void Truncate(Truncate builder) { Append("TRUNCATE TABLE "); Table(builder.Table); }
public string[][] ObtenerSimulacion(int cantidad, int limInf, int limSup) { // Los 2 vectores con los que vamos a trabajar. string[] vectorSimulacion = new string[11]; string[] vectorSimulacion_menos1 = new string[11]; // Cantidad de filas que vamos a mostrar. int simul_a_mostrar = (limSup - limInf) + 1; // Creo el vector que contendra las simulaciones a mostrar string[][] simulaciones = new string[simul_a_mostrar][]; // Variables varias Random aleatorio = new Random(); // Valor RND int acumSusc = 0; int acumVentas = 0; int num = 0; int z = 0; for (int i = 1; i <= cantidad; i++) { // Reseteo los vectores para cara simulacion for (int j = 0; j < 11; j++) { vectorSimulacion[j] = " "; vectorSimulacion_menos1[j] = " "; } // Visitas vectorSimulacion[0] = (i).ToString(); // RND AbrePuerta double RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[1] = RND.ToString(); // AbrePuerta foreach (Opcion opcion in AbrePuerta.opciones) { if (RND > opcion.acum) { vectorSimulacion[2] = opcion.nombre; } } // RND HombreMujer RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[3] = RND.ToString(); // Hombre/Mujer if (vectorSimulacion[2] == "SI") { foreach (Opcion opcion in AtiendePuerta.opciones) { if (RND > opcion.acum) { vectorSimulacion[4] = opcion.nombre; } } // RND Venta RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[5] = RND.ToString(); if (vectorSimulacion[4] == "Mujer") { foreach (Opcion opcion in VentaMujer.opciones) { if (RND > opcion.acum) { vectorSimulacion[6] = opcion.nombre; } } } else { foreach (Opcion opcion in VentaHombre.opciones) { if (RND > opcion.acum) { vectorSimulacion[6] = opcion.nombre; } } } if (vectorSimulacion[6] == "SI") { acumVentas++; } // RND Suscripcion RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[8] = RND.ToString(); if (vectorSimulacion[6] == "SI") { if (vectorSimulacion[4] == "Mujer") { foreach (Opcion opcion in SuscripcionMujer.opciones) { if (RND > opcion.acum) { vectorSimulacion[9] = opcion.nombre; } } } else { foreach (Opcion opcion in SuscripcionHombre.opciones) { if (RND > opcion.acum) { vectorSimulacion[9] = opcion.nombre; } } } } } if (vectorSimulacion[9] == " ") { num = 0; } else { num = Convert.ToInt32(vectorSimulacion[9]); } acumSusc += num; vectorSimulacion[10] = acumSusc.ToString(); vectorSimulacion[7] = acumVentas.ToString(); if (i >= limInf && i <= limSup) { simulaciones[z] = new string[11]; for (int u = 0; u < 11; u++) { simulaciones[z][u] = vectorSimulacion[u]; } z++; } } return(simulaciones); }
/// <summary> /// Removes all the rows from the given column family. /// </summary> public void RemoveAllRows() { var op = new Truncate(); ExecuteOperation(op); }
public string[][] ObtenerSimulacion(int cantidad, int limInf, int limSup) { // Los 2 vectores con los que vamos a trabajar. string[] vectorSimulacion = new string[11]; string[] vectorSimulacion_menos1 = new string[11]; // Cantidad de filas que vamos a mostrar. int simul_a_mostrar = (limSup - limInf) + 1; // Creo el vector que contendra las simulaciones a mostrar string[][] simulaciones = new string[simul_a_mostrar][]; // Variables varias Random aleatorio = new Random(); // Valor RND int num; int z = 0; for (int a = 0; a < vectorSimulacion_menos1.Length; a++) { if (a == 7 || a == 10) { vectorSimulacion_menos1[a] = "0"; } else { vectorSimulacion_menos1[a] = " "; } } for (int i = 1; i <= cantidad; i++) { // Reseteo el vector para cada simulacion for (int j = 0; j < vectorSimulacion.Length; j++) { if (j == 7 || j == 10) { // Conservo los valores de los acumuladores vectorSimulacion[j] = vectorSimulacion_menos1[j]; } else { vectorSimulacion[j] = " "; } } // Visitas vectorSimulacion[0] = (i).ToString(); // RND AbrePuerta (si abre la puerta o no) double RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[1] = RND.ToString(); foreach (Opcion opcion in AbrePuerta.opciones) { if (RND > opcion.acum) { vectorSimulacion[2] = opcion.nombre; } } // RND HombreMujer (Si es mujer o hombre) RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[3] = RND.ToString(); if (vectorSimulacion[2] == "SI") { foreach (Opcion opcion in AtiendePuerta.opciones) { if (RND > opcion.acum) { vectorSimulacion[4] = opcion.nombre; } } // RND Venta (si vendio o no vendio) RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[5] = RND.ToString(); if (vectorSimulacion[4] == "Mujer") { foreach (Opcion opcion in VentaMujer.opciones) { if (RND > opcion.acum) { vectorSimulacion[6] = opcion.nombre; } } } else { foreach (Opcion opcion in VentaHombre.opciones) { if (RND > opcion.acum) { vectorSimulacion[6] = opcion.nombre; } } } // Cuento las ventas realizadas. if (vectorSimulacion[6] == "SI") { vectorSimulacion[7] = (Convert.ToInt32(vectorSimulacion[7]) + 1).ToString(); } // RND Suscripcion (Cuantas suscripciones compro dependiendo el sexo) RND = Truncate.truncar(aleatorio.NextDouble(), 3); vectorSimulacion[8] = RND.ToString(); if (vectorSimulacion[6] == "SI") { if (vectorSimulacion[4] == "Mujer") { foreach (Opcion opcion in SuscripcionMujer.opciones) { if (RND > opcion.acum) { vectorSimulacion[9] = opcion.nombre; } } } else { foreach (Opcion opcion in SuscripcionHombre.opciones) { if (RND > opcion.acum) { vectorSimulacion[9] = opcion.nombre; } } } } } // Acumulo las suscripciones vendidas if (vectorSimulacion[9] == " ") { num = 0; } else { num = Convert.ToInt32(vectorSimulacion[9]); } vectorSimulacion[10] = (Convert.ToInt32(vectorSimulacion_menos1[10]) + num).ToString(); // Copio el vector simulacion al vector menos 1 para la proxima simulacion. for (int r = 0; r < vectorSimulacion.Length; r++) { vectorSimulacion_menos1[r] = vectorSimulacion[r]; } // Pregunto si debo mostrar la informacion de la simulacion actual o no. if (i >= limInf && i <= limSup) { simulaciones[z] = new string[11]; for (int u = 0; u < 11; u++) { simulaciones[z][u] = vectorSimulacion[u]; } z++; } } return(simulaciones); }
public override void Truncate(Truncate builder) { Append("DELETE"); Append(" FROM "); Table(builder.Table); }