public static void PrintBootomHeader(Guid guid, long maxInterations) { GICO.WriteLine(guid, String.Format("MC step:{0}", GCPS.McSteps));// maxInterations * GCPS.mcStepsLoop02_LIMITE * GCPS.chain.r.Count); GICO.WriteLine(guid, String.Format("NumberOfMovementsApplied {0}.", GCPS.chain.contMoves.NumberOfMovementsApplied.ToString())); GICO.WriteLine(guid, String.Format("NumberOfMovementsRejected {0}.", GCPS.chain.contMoves.NumberOfMovementsRejected.ToString())); GICO.WriteLine(guid, String.Format("SumOfAcceptedAndRejectedMovement {0}.", GCPS.chain.contMoves.SumOfAcceptedAndRejectedMovement.ToString())); }
/// <summary> /// Testa a existencia de um KINK apartir de uma posição do Monomero /// </summary> /// <param name="selectNode">Node selecionado</param> /// <param name="posInit">Retorna por referência o ponto inicial do Kink</param> /// <param name="posEnd">Retorna por referência o ponto final do Kink</param> /// <returns>Retorno TRUE se o Kink existir.</returns> internal static bool ExistKick(int selectNode, ref Structs.BasicStructs.Point posInit, ref Structs.BasicStructs.Point posEnd) { try { //Ponto Vizinho anterior do Monomero sorteado posInit = new Structs.BasicStructs.Point() { x = GCPS.chain.r[selectNode - 1].x, y = GCPS.chain.r[selectNode - 1].y, z = GCPS.chain.r[selectNode - 1].z }; //Ponto Vizinho posterior do Monomero sorteado posEnd = new Structs.BasicStructs.Point() { x = GCPS.chain.r[selectNode + 1].x, y = GCPS.chain.r[selectNode + 1].y, z = GCPS.chain.r[selectNode + 1].z }; //return (GridProteinFolding.Core.Internal.Maths4Simulation.Maths4Simulation.DistanceBetweenPointsWithSqrt(posInit, posEnd) == 1.4142135623730951); return(Classification.Kink.IsKink(selectNode)); } catch (System.ArgumentOutOfRangeException ex) { GICO.WriteLine(ex); return(false); } }
public static void PrintHeader(Guid guid, long maxInterations)//, int condStop) { //GICO.WriteLine(guid, String.Format("Condition to Stop (topological contacts): {0}", condStop.ToString())); //GICO.WriteLine(guid, String.Format("Max mcStepsLoop01: {0}", maxInterations.ToString())); GICO.WriteLine(guid, String.Format("MCSteps: {0}", (maxInterations * 5 * GCPS.chain.r.Count))); //GICO.WriteLine(guid, String.Format("Interations/Max mcStepsLoop01: {0}", GCPS.mcStepsLoop01 + @"/" + maxInterations)); lastNumber = -1; }
public void Process() { GICO.WriteLine(String.Format("ETL Service: Service is up and running!")); while (true) { System.Threading.Thread.Sleep(1000 * timeForConsulting); AfterSleep(); } }
public void PrintFormException(Exception ex) { ConsoleColor oldColour = Console.ForegroundColor; GICO.ForegroundColor(ConsoleColor.Red); GICO.WriteLine(ex); GICO.ForegroundColor(oldColour); new FormProtein().DisplayMessage(ex.Message.ToString()); PrintConsole(ex, true); }
public void Do() { GICO.WriteLine(String.Format(" Decrypt...")); Decrypt(); ConfigIntegrator configIntegrator = new ConfigIntegrator(param, false); GICO.WriteLine(String.Format(" MoveFile...")); MoveFile(ref configIntegrator); GICO.WriteLine(String.Format(" SimulationResults...")); SimulationResults(ref configIntegrator); if (param.output.distribution) { GICO.WriteLine(String.Format(" Output: Distribution...")); Distribution(ref configIntegrator); } if (param.output.evolution) { GICO.WriteLine(String.Format(" Output: EvolutionRadiusGyration...")); EvolutionRadiusGyration(ref configIntegrator); GICO.WriteLine(String.Format(" Output: EvolutionValueMediumOfEnergy...")); EvolutionValueMediumOfEnergy(ref configIntegrator); } if (param.output.configuration) { GICO.WriteLine(String.Format(" Output: Configuration...")); ConfigurationOutPut(ref configIntegrator); } //Excel GICO.WriteLine(String.Format(" Excel...")); Excel(param.output); if (param.output.configuration) { GICO.WriteLine(String.Format(" Output: LoadConfigurationOutPutToOrigin...")); //LoadConfigurationOutPutToOrigin(ref configIntegrator); //ORIGIN GICO.WriteLine(String.Format(" Origin...")); //Origin(); } configIntegrator = null; return; }
public bool Send(MailAddress to, string subject, string body) { SmtpSection settings = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); if (settings.Network.Password == null) { new Exception("Key (system.net/mailSettings/smtp) not is null!"); } System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); //client.Credentials = new NetworkCredential(settings.Network.UserName, settings.Network.Password); client.Credentials = new NetworkCredential(settings.Network.UserName, settings.Network.Password);//CryptorEngine.Decrypt(settings.Network.Password, true)); client.Port = settings.Network.Port; client.Host = settings.Network.Host; client.EnableSsl = true; try { MailAddress maFrom = new MailAddress(settings.From, settings.From, Encoding.UTF8), maTo = new MailAddress(to.Address, to.DisplayName, Encoding.UTF8); MailMessage mmsg = new MailMessage(maFrom.Address, maTo.Address); mmsg.Body = body; mmsg.BodyEncoding = Encoding.UTF8; mmsg.IsBodyHtml = true; mmsg.Subject = subject; mmsg.SubjectEncoding = Encoding.UTF8; client.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback); string userState = "SmtpClient.SendAsync"; client.SendAsync(mmsg, userState); //client.Send(mmsg); Console.WriteLine("Sending message...."); return(true); } catch (SmtpException ex) { GICO.WriteLine(ex); return(false); } }
private bool AfterSleep() { bool retRun = false; try { Guid[] guids = Proxy.GetGuidsToApplications(); if (guids != null) { foreach (Guid guid in guids) { ServiceParamWcf paramWCF = Proxy.GetOneProcessGuiForETL(guid); if (paramWCF != null) { ConsoleColor oldColour = Console.ForegroundColor; GICO.ForegroundColor(ConsoleColor.Yellow); GICO.WriteLine(string.Empty); GICO.WriteLine(String.Format("Guid running: {0}", guid.ToString())); GICO.ForegroundColor(oldColour); retRun = Run(paramWCF); Proxy.SetOneProcessByGuid(paramWCF.param.dataToProcess.Guid, BasicEnums.State.ResultsProcessed); GICO.WriteLine(String.Format("Finished Guid: {0}", guid.ToString())); GICO.WriteLine(string.Empty); } } } return(retRun); } catch (EndpointNotFoundException) { //new CustomLog().EndpointNotFoundException(ex); } return(false); }
public static void PrintPercentCompleted(Guid guid) { long maxInterations = GridProteinFolding.Middle.Helpers.ConfigurationHelpers.AppConfigClient.Param.dataToProcess.maxInterations; if (GCPS.mcStepsLoop01 != 0) { double percent = GCPS.mcStepsLoop01; percent = ((percent * 100) / maxInterations); int value = Convert.ToInt32(percent.ToString("00.##").Substring(0, 2)); switch (value) { case 10: case 20: case 30: case 40: case 50: case 60: case 70: case 80: case 90: case 100: if (lastNumber < value) { lastNumber = value; GICO.WriteLine(guid, lastNumber + "%.. "); // IO.Stream.StreamRecBlob(Marshalling.WriteToBinaryFile<Simulation>(string.Empty, GCPS.chain., false)); } break; } } else { GICO.WriteLine(guid, "0%.. "); } }
/// <summary> /// Aplica TEMPO de passo em MONTE CARLO! /// </summary> public static bool Run() { LatticeMoves objLatticeMoves = new LatticeMoves(); InitVariables.Do(); #region Criação Movimentação MoveSet StateControl.condStop = (GCPS.chain.r.Count + 1) * 2; StateControl.maxInterations = AppConfigClient.Param.dataToProcess.maxInterations; //numero maximo de tentativas StateControl.recPathEvery = 0; PrinterMessages.PrintHeader(AppConfigClient.CurrentGuid, StateControl.maxInterations);//, StateControl.condStop); //Salva a primeira configuração do monomero Recorder.RecTrajectoryFile(objLatticeMoves, AppConfigClient.Param.dataToProcess.splitFileEvery, true); //Salva snapshot calculo da "variação de energia" e salva em arquivo o valor de "U" CalculatingEnergy.existFileForSaveDebug = false; CalculatingEnergy.SaveValueOfDebugFile(); int maxValConTop = 0; DateTime startDateTime = DateTime.Now; Console.WriteLine("Start: {0}", startDateTime.ToString()); for (GCPS.mcStepsLoop01 = 0; GCPS.mcStepsLoop01 < StateControl.maxInterations; GCPS.mcStepsLoop01++) { //PRINT % PrinterMessages.PrintPercentCompleted(AppConfigClient.CurrentGuid); for (GCPS.mcStepsLoop02 = 0; GCPS.mcStepsLoop02 < GCPS.mcStepsLoop02_LIMITE; GCPS.mcStepsLoop02++) //loop externo de 5 passos { for (GCPS.mcStepsLoop03 = 0; GCPS.mcStepsLoop03 < GCPS.chain.r.Count; GCPS.mcStepsLoop03++) //loop para tamanha da cadeia { GCPS.chain.CopyToTempMonomero(); //Sorteiro o residuo para a tentativa de movimento LatticeMoves.SortMoviment(); //var occuredMotion armazena o boleano da ocorrência de movimentos dos três (3) tipos abaixo: bool occuredMotion = objLatticeMoves.LatticeTryModeSetCrankshaft(); if (!occuredMotion) { occuredMotion = objLatticeMoves.LatticeTryModeSetEnds(); if (!occuredMotion) { occuredMotion = objLatticeMoves.LatticeTryModeSetKink(); if (!occuredMotion) { GCPS.chain.contMoves.othersReject++; } } } //Verifica se ocorreu um movimento na cadeia temporária if (occuredMotion) { //Excluir valores energia (e) anterior se existentes ao node //CalculatingEnergy.DelEnergy(GCPS.tempMonomero.selectNode); //Rotina executa: Processa calculo da "variação de energia" e salva em arquivo o valor de "U" Reclassifica a cadeia TEMPORARIA //GCPS.tempMonomero.NeighborsUpdatePeerPoint(GCPS.tempMonomero.selectNode); //Reclassifica TODA A CADEIA GCPS.tempChain.NeighborsUpdateAll(); #region //Condição de Teste: //(1) deltaE <=0 -> "Aceita a nova configuração" //(2) deltaE >0 -> Então // - Calcula e^-deltaE*beta (calcE) // - Gerar um número randôico (r) entre 0 e 1 // Se r<=calcE então "Aceita a nova configuração" // Senão "Rejeita a nova configuração" #endregion //Efetua calcula das varívais do meio ambiente (deltaE, lastR e lastTransitionProbability, RG, DPP e etc) Structs.Environment.CalculateEnvironment(); if (AcceptMove()) { //Salva classificaca da cadeia GCPS.tempChain.NeighborsSave(GCPS.chain.isem, ref GCPS.chain.numberNeighborTopological); //Aceita o movimento GCPS.chain.AcceptMotion(); if (GCPS.chain.ECount() != (GCPS.chain.TotalNeighborTopological() / 2)) { new GridProteinFolding.Middle.Helpers.LoggingHelpers.Log().ErrorNeighborTopological(new ErrorNeighborTopological("GCPS.chain.ECount() != (GCPS.chain.TotalNeighborTopological() / 2"), Types.ErrorLevel.Warning); } //Snapshot(ref objLatticeMoves); //REC if (GCPS.chain.numberNeighborTopological >= (GCPS.chain.r.Count - 1)) { FoundData(startDateTime); Snapshot(ref objLatticeMoves); } //Condição de parada if (GCPS.chain.numberNeighborTopological >= (GCPS.chain.r.Count)) { FoundData(startDateTime); Snapshot(ref objLatticeMoves); if (Structs.Environment.rg == 1.41) { break; } } else { if (maxValConTop < GCPS.chain.numberNeighborTopological) { maxValConTop = GCPS.chain.numberNeighborTopological; FoundData(startDateTime); } } } GCPS.chain.interationEnergy = string.Empty; GCPS.chain.typeOfLattice = BasicEnums.Lattices.None; //Se movimento ocorreu, é necessário pré qualificar novamente toda a cadeia ClassificationMotion.PreClassificationOfMotion(); if (StateControl.condStop == GCPS.chain.TotalNeighborTopological()) { break; } } GCPS.McStepsDo(); } } } //Salva o movimento da cadeia Recorder.RecTrajectoryFileCalcSpinningRay(AppConfigClient.CurrentGuid, StateControl.maxInterations, objLatticeMoves); GICO.WriteLine(AppConfigClient.CurrentGuid, String.Format("MCSteps: {0}", GCPS.McSteps)); //Check Parse do ultimo arquivo valido if (!LatticeMoves.Parse()) { new GridProteinFolding.Middle.Helpers.LoggingHelpers.Log().ErroParseMoves(new ErroParseMovesException("ErroParseMoves"), Types.ErrorLevel.None); } //MoveSet de saída do movimento do ultimo arquivo valido Recorder.RecTrajectoryFile(objLatticeMoves, AppConfigClient.Param.dataToProcess.splitFileEvery); //MoveSet (RESULT) objLatticeMoves.RecMoveSet(AppConfigClient.CurrentGuid, SimulationResults + Directory.FileExtension); objLatticeMoves.Disposed(); objLatticeMoves = null; #endregion return(true); }
/// <summary> /// Aplica TEMPO de passo em MONTE CARLO! /// </summary> public static bool Run() { LatticeMoves objLatticeMoves = new LatticeMoves(); InitVariables.Do(); #region Criação Movimentação MoveSet //StateControl.condStop = (GCPS.chain.r.Count + 1) * 2; StateControl.maxInterations = AppConfigClient.Param.dataToProcess.maxInterations; //numero maximo de tentativas StateControl.recPathEvery = 0; PrinterMessages.PrintHeader(AppConfigClient.CurrentGuid, StateControl.maxInterations);//, StateControl.condStop); //Salva a primeira configuração do monomero Recorder.RecTrajectoryFile(objLatticeMoves, AppConfigClient.Param.dataToProcess.splitFileEvery, true); //Salva snapshot calculo da "variação de energia" e salva em arquivo o valor de "U" CalculatingEnergy.existFileForSaveDebug = false; CalculatingEnergy.SaveValueOfDebugFile(); //int maxValConTop = 0; bool stoped = false; DateTime startDateTime = DateTime.Now; Console.WriteLine("Start: {0}", startDateTime.ToString()); while (!stoped) { GCPS.chain.CopyToTempMonomero(); //Sorteiro o residuo para a tentativa de movimento LatticeMoves.SortMoviment(); //var occuredMotion armazena o boleano da ocorrência de movimentos dos três (3) tipos abaixo: bool occuredMotion = objLatticeMoves.LatticeTryModeSetCrankshaft(); if (!occuredMotion) { occuredMotion = objLatticeMoves.LatticeTryModeSetEnds(); if (!occuredMotion) { occuredMotion = objLatticeMoves.LatticeTryModeSetKink(); if (!occuredMotion) { GCPS.chain.contMoves.othersReject++; } } } //Verifica se ocorreu um movimento na cadeia temporária if (occuredMotion) { //Reclassifica TODA A CADEIA GCPS.tempChain.NeighborsUpdateAll(); //Efetua calcula das varívais do meio ambiente (deltaE, lastR e lastTransitionProbability, RG, DPP e etc) Structs.Environment.CalculateEnvironment(); if (AcceptMove()) { //Salva classificaca da cadeia GCPS.tempChain.NeighborsSave(GCPS.chain.isem, ref GCPS.chain.numberNeighborTopological); //Aceita o movimento GCPS.chain.AcceptMotion(); if (GCPS.chain.ECount() != (GCPS.chain.TotalNeighborTopological() / 2)) { new GridProteinFolding.Middle.Helpers.LoggingHelpers.Log().ErrorNeighborTopological(new ErrorNeighborTopological("GCPS.chain.ECount() != (GCPS.chain.TotalNeighborTopological() / 2"), Types.ErrorLevel.Warning); } //Condição de parada if (GCPS.chain.numberNeighborTopological >= (GCPS.chain.r.Count)) { FoundData(startDateTime); Snapshot(ref objLatticeMoves); if (CheckStruct()) { stoped = true; } } } GCPS.chain.interationEnergy = string.Empty; GCPS.chain.typeOfLattice = BasicEnums.Lattices.None; //Se movimento ocorreu, é necessário pré qualificar novamente toda a cadeia ClassificationMotion.PreClassificationOfMotion(); } GCPS.McStepsDo(); } //Salva o movimento da cadeia Recorder.RecTrajectoryFileCalcSpinningRay(AppConfigClient.CurrentGuid, StateControl.maxInterations, objLatticeMoves); GICO.WriteLine(AppConfigClient.CurrentGuid, String.Format("MCSteps: {0}", GCPS.McSteps)); //Check Parse do ultimo arquivo valido if (!LatticeMoves.Parse()) { new GridProteinFolding.Middle.Helpers.LoggingHelpers.Log().ErroParseMoves(new ErroParseMovesException("ErroParseMoves"), Types.ErrorLevel.None); } //MoveSet de saída do movimento do ultimo arquivo valido Recorder.RecTrajectoryFile(objLatticeMoves, AppConfigClient.Param.dataToProcess.splitFileEvery); //MoveSet (RESULT) objLatticeMoves.RecMoveSet(AppConfigClient.CurrentGuid, SimulationResults + Directory.FileExtension); //Compara estruturas com as TARGETS //ComparerTargets(GCPS.chain.r); #endregion //MoveSet de saída do movimento para SANDBOX Recorder.RecTrajectoryFileSandBox(objLatticeMoves); objLatticeMoves.Disposed(); objLatticeMoves = null; return(true); }
static void Main(string[] args) { //Check Folders GridProteinFolding.WCF.ServiceDistributed.Service.CheckWorkFolders(); //Run Hosts ServiceHost hostService = new ServiceHost(typeof(Service)); ServiceHost hostDocumentManagment = new ServiceHost(typeof(DocumentManagment)); //ServiceHost hostGeneratingResults = new ServiceHost(typeof(GeneratingResults)); try { #region hostService hostService.Open(); ServiceDescription serviceDesciption = hostService.Description; foreach (ServiceEndpoint endpoint in serviceDesciption.Endpoints) { ConsoleColor oldColour = Console.ForegroundColor; GICO.ForegroundColor(ConsoleColor.Red); GICO.WriteLine(ExtendedString.Format("Endpoint - address: {0}", endpoint.Address)); GICO.WriteLine(ExtendedString.Format(" - binding name:\t\t{0}", endpoint.Binding.Name)); GICO.WriteLine(ExtendedString.Format(" - contract name:\t\t{0}", endpoint.Contract.Name)); GICO.ForegroundColor(oldColour); } #endregion #region hostDocumentManagment hostDocumentManagment.Open(); serviceDesciption = hostDocumentManagment.Description; foreach (ServiceEndpoint endpoint in serviceDesciption.Endpoints) { ConsoleColor oldColour = Console.ForegroundColor; GICO.ForegroundColor(ConsoleColor.Red); GICO.WriteLine(ExtendedString.Format("Endpoint - address: {0}", endpoint.Address)); GICO.WriteLine(ExtendedString.Format(" - binding name:\t\t{0}", endpoint.Binding.Name)); GICO.WriteLine(ExtendedString.Format(" - contract name:\t\t{0}", endpoint.Contract.Name)); GICO.WriteLine(); GICO.ForegroundColor(oldColour); } #endregion //#region hostGeneratingResults //hostGeneratingResults.Open(); //serviceDesciption = hostGeneratingResults.Description; //foreach (ServiceEndpoint endpoint in serviceDesciption.Endpoints) //{ // ConsoleColor oldColour = Console.ForegroundColor; // GICO.ForegroundColor(ConsoleColor.Red); // GICO.WriteLine(String.Format("Endpoint - address: {0}", endpoint.Address)); // GICO.WriteLine(String.Format(" - binding name:\t\t{0}", endpoint.Binding.Name)); // GICO.WriteLine(String.Format(" - contract name:\t\t{0}", endpoint.Contract.Name)); // GICO.WriteLine(); // GICO.ForegroundColor(oldColour); //} //#endregion GICO.WriteLine("Service Distributed: Service is up and running!"); GICO.WriteLine(); ConsoleKeyInfo key; Console.WriteLine("Press the Escape (Esc) key to quit: \n"); do { key = Console.ReadKey(); } while (key.Key != ConsoleKey.Escape); } catch (Exception ex) { GICO.WriteLine(ex.Message.ToString()); GICO.WriteLine(ex.InnerException.ToString()); Console.ReadKey(); } finally { if (hostService.State != CommunicationState.Closed && hostService.State != CommunicationState.Faulted) { hostService.Close(); } hostService = null; if (hostDocumentManagment.State != CommunicationState.Closed && hostDocumentManagment.State != CommunicationState.Faulted) { hostDocumentManagment.Close(); } hostDocumentManagment = null; } }