/// <summary> /// Manages the modeling for a batch process. /// </summary> /// <param name="Process"></param> /// <returns>true if model was created, false otherwise</returns> private bool BatchModel(BatchProcess Process) { #if GPLOG GPLog.ReportLine("Batch Processing: Requesting a program.", true); #endif // // Create the modeler object - the parameter to this thread is // the model profile. m_Modeler = new GPModeler( Process.Profile, Process.TrainingDataID, null, //new GPModeler.DEL_ValidatedServer(AddValidatedServer), new GPModeler.DEL_ReportStatus(ReceiveStatus), new GPModeler.DEL_ReportFitness(ReceiveFitness), null); //new GPModeler.DEL_GenerationComplete(GenerationComplete)); // // Make an asynchronous call that gets the modeling started MethodInvoker miModeler = new MethodInvoker(m_Modeler.RequestProgram); IAsyncResult ar = miModeler.BeginInvoke(null, null); // // Wait for the modeling to complete miModeler.EndInvoke(ar); // // Record the time of completion Process.TimeCompleted = DateTime.Now; // // Check to see if we were canceled if (m_CancelSimulation) { #if GPLOG GPLog.ReportLine("Batch Processing: Simulation Canceled", true); #endif Process.Canceled = true; // // Reset the cancel flag m_CancelSimulation = false; return(false); } #if GPLOG GPLog.ReportLine("Batch Processing: Program request complete.", true); #endif // // Save the best program to the database int ProgramID = 0; // A dummy variable m_Modeler.SaveBestToDB(Process.ProjectID, ref ProgramID); return(true); }
/// <summary> /// The entry point for a modeling thread. This connects to the server, /// sends the modeling profile, training Training and then requests the model /// to be written. /// </summary> /// <param name="arg">Reference to the modeling profile</param> private void ModelThread(Object arg) { #if GPLOG GPLog.ReportLine("Requesting a program.", true); #endif // // Create the modeler object - the parameter to this thread is // the model profile. m_Modeler = new GPModeler( (GPProjectProfile)arg, m_Project.DataTrainingID, new GPModeler.DEL_ValidatedServer(AddValidatedServer), new GPModeler.DEL_ReportStatus(UpdateModelStatus), new GPModeler.DEL_ReportFitness(ReportFitness), new GPModeler.DEL_GenerationComplete(GenerationComplete)); // // Make an asynchronous call that gets the modeling started MethodInvoker miModeler = new MethodInvoker(m_Modeler.RequestProgram); IAsyncResult ar = miModeler.BeginInvoke(null, null); // // Now we can go ahead and enable the cancel button EnableCancel(); // // Wait for the modeling to complete miModeler.EndInvoke(ar); #if GPLOG GPLog.ReportLine("Program request complete.", true); #endif // // Save the best program to the database int ProgramID = 0; if (m_Modeler.SaveBestToDB(m_Project.DBCode, ref ProgramID)) { // // Update the results display and select this program UpdateModelStatus("Saving best program..."); UpdateModelResults(ProgramID); } // // Do some cleanup, now that the modeling is complete EnableModelButton(); ProgressReset(); UpdateModelStatus(""); EnableStatusMarquee(false); }