/// <summary> /// Prepares the configuration settings at each server. /// *Training Data /// *UDFs /// *Fitness Function /// *Everything else /// This method builds a list of modeler interfaces at each server. Remember, /// each time the Modeler property is used from IGPServer, a NEW modeler is /// created...so only want to do this once for each modeling session; hence, /// have to access it and keep track of it on the client side. /// </summary> /// <param name="ServerManager"></param> /// <param name="Modelers"></param> /// <param name="Training"></param> /// <returns>True/False upon success or failure</returns> private bool InitializeServers(ServerManagerSingleton ServerManager, ref List <IGPModeler> Modelers, ref GPModelingData Training) { #if GPLOG GPLog.ReportLine("Initializing Distributed Servers...", true); #endif // // Create a modeler sponsor m_FunctionSetSponsor = fmMain.SponsorServer.Create("FunctionSet"); m_ModelerSponsor = fmMain.SponsorServer.Create("Modeler"); // // Build a list of modeler interfaces #if GPLOG GPLog.ReportLine("Number of GPServers: " + ServerManager.Count, true); #endif if (m_DELReportStatus != null) { m_DELReportStatus("Enumerating distributed servers..."); } List <IGPServer> Servers = new List <IGPServer>(ServerManager.Count); Modelers = new List <IGPModeler>(ServerManager.Count); foreach (IGPServer iServer in ServerManager) { Modelers.Add(iServer.Modeler); // // We also keep track of the servers so we set the right function set // with the right server. Servers.Add(iServer); } m_Modelers = Modelers; // // Based upon the selected topology, send interfaces to the connected // servers. switch (m_Profile.ModelingProfile.DistributedTopology) { case GPEnums.DistributedTopology.Ring: InitializeServersTopologyRing(Modelers); break; case GPEnums.DistributedTopology.Star: InitializeServersTopologyStar(Modelers); break; } // // Report the list of servers to the UI - they're ordered the same as the interfaces, // so the foreach is a safe way to do it. foreach (String Description in ServerManager.Descriptions.Values) { #if GPLOG GPLog.ReportLine("Server Description: " + Description, true); #endif // // Report back to the UI we have a new valid server to record data for if (m_DELValidatedServer != null) { m_DELValidatedServer(Description); } } // // Transimit the training data #if GPLOG GPLog.Report("Loading training data...", true); #endif if (m_DELReportStatus != null) { m_DELReportStatus("Loading training data..."); } Training = new GPModelingData(); Training.LoadFromDB(m_TrainingID, null, null); #if GPLOG GPLog.ReportLine("...Complete", false); #endif // // Asynchronously call initialization on each modeler List <DEL_InitializeModeler> DelegateList = new List <DEL_InitializeModeler>(Servers.Count); List <IAsyncResult> ResultList = new List <IAsyncResult>(Servers.Count); for (int ServerIndex = 0; ServerIndex < Servers.Count; ServerIndex++) { // // Make an asynchronous call to initialize DEL_InitializeModeler delInit = new DEL_InitializeModeler(InitializeModeler); IAsyncResult ar = delInit.BeginInvoke(Servers[ServerIndex], Modelers[ServerIndex], Training, null, null); DelegateList.Add(delInit); ResultList.Add(ar); } // // Go into a loop to wait for all the method calls to complete for (int Delegate = 0; Delegate < DelegateList.Count; Delegate++) { DelegateList[Delegate].EndInvoke(ResultList[Delegate]); } return(true); }
private void lvFiles_SelectedIndexChanged(object sender, EventArgs e) { if (m_DeletingItem) { return; } if ((lvFiles.SelectedIndices.Count <= 0) || (m_bLoadFile == false)) { return; } // // Grab the DBCode int ModelingFileID = Convert.ToInt32(lvFiles.Items[lvFiles.SelectedIndices[0]].Tag.ToString()); // // Ge the Training loaded from the database m_gpData = new GPModelingData(); tsLabel.Text = "Loading From Database"; Cursor PrevCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; Application.DoEvents(); m_gpData.LoadFromDB( ModelingFileID, new GPModelingData.DELInitProgress(InitProgress), new GPModelingData.DELIncrementProgress(IncrementProgress)); this.Cursor = PrevCursor; tsLabel.Text = ""; // // Setup the X-Axis selection combo box cbXAxis.Items.Clear(); // // If we have time series data, handle it separately for (int Column = 0; Column < m_gpData.Columns; Column++) { cbXAxis.Items.Add(m_gpData.Header[Column]); } cbXAxis.SelectedItem = cbXAxis.Items[0]; // // If this is a time series, autocheck the count box chkCount.Checked = m_gpData.TimeSeries; chkCount.Enabled = !m_gpData.TimeSeries; // // Place this Training into the grid DisplayDataGrid(m_gpData); NameColumns(); // // Place this Training into the graph DisplayDataGraph(m_gpData); // // If this file is in use, disable the Delete Button btnDelete.Enabled = !GPModelingData.FileInUse(ModelingFileID); tsProgress.Value = 0; }