// // Update the UI controls Population Structure section private void UpdateUI_PopulationStructure(GPProjectProfile Profile) { switch (Profile.ModelingProfile.PopulationBuild) { case GPEnums.PopulationInit.Full: cmbStructure_PopInit.SelectedIndex = cmbStructure_PopInit.Items.IndexOf("Full"); break; case GPEnums.PopulationInit.Grow: cmbStructure_PopInit.SelectedIndex = cmbStructure_PopInit.Items.IndexOf("Grow"); break; case GPEnums.PopulationInit.Ramped: cmbStructure_PopInit.SelectedIndex = cmbStructure_PopInit.Items.IndexOf("Ramped Half-Half"); break; } udPopulation_TreeDepth.Value = Profile.ModelingProfile.PopulationInitialDepth; switch (Profile.ModelingProfile.Reproduction) { case GPEnums.Reproduction.Tournament: cmbStructure_PopReproduction.SelectedIndex = cmbStructure_PopReproduction.Items.IndexOf("Tournament"); break; case GPEnums.Reproduction.OverSelection: cmbStructure_PopReproduction.SelectedIndex = cmbStructure_PopReproduction.Items.IndexOf("Overselection"); break; } udStructure_PopSize.Value = Profile.ModelingProfile.PopulationSize; }
// // Save the UI controls Population Structure section private void CollectUI_PopulationStructure(GPProjectProfile Profile) { // // TODO: need to not use text, need to use an ID of some kinds switch (cmbStructure_PopInit.Text) { case "Grow": Profile.ModelingProfile.PopulationBuild = GPEnums.PopulationInit.Grow; break; case "Full": Profile.ModelingProfile.PopulationBuild = GPEnums.PopulationInit.Full; break; case "Ramped Half-Half": Profile.ModelingProfile.PopulationBuild = GPEnums.PopulationInit.Ramped; break; } Profile.ModelingProfile.PopulationInitialDepth = (int)udPopulation_TreeDepth.Value; switch (cmbStructure_PopReproduction.Text) { case "Tournament": Profile.ModelingProfile.Reproduction = GPEnums.Reproduction.Tournament; break; case "Overselection": Profile.ModelingProfile.Reproduction = GPEnums.Reproduction.OverSelection; break; } Profile.ModelingProfile.PopulationSize = (int)udStructure_PopSize.Value; }
/// <summary> /// Add a new simulation to be performed. /// </summary> public void AddSimulation(GPProjectProfile Profile, int TrainingDataID, int ProjectID) { BatchProcess NewProcess = new BatchProcess(Profile, TrainingDataID, ProjectID); m_Queue.Add(NewProcess); // // Inform all clients a new process was just added foreach (KeyValuePair <IBatchClient, IBatchClient> Client in m_Clients) { Client.Value.AddProcess( NewProcess, GPDatabaseUtils.FieldValue(NewProcess.ProjectID, "tblProject", "Name"), NewProcess.Profile.Name, NewProcess.TimeAdded, NewProcess.TimeStarted, NewProcess.IsStarted); } // // Indicate to the thread a new model has been requested. This is done by sending // a "Default" command. What the effectively does is to make execing of simulations // the lowest priority event. We want register client events to take priority // over exec simulations, so they start getting updated as soon as possible. m_CommandQueue.Enqueue(Command.Default); wh_CommandEvent.Set(); }
// // Update the UI controls Terminal Set tab page private void UpdateUI_TerminalSet(GPProjectProfile Profile) { chkTS_RndInteger.Checked = Profile.ModelingProfile.UseRndInteger; txtTS_IntegerMin.Text = Profile.ModelingProfile.IntegerMin.ToString(); txtTS_IntegerMax.Text = Profile.ModelingProfile.IntegerMax.ToString(); chkTS_RndDouble.Checked = Profile.ModelingProfile.UseRndDouble; }
// // Save the UI controls Terminal Set tab page private void CollectUI_TerminalSet(GPProjectProfile Profile) { Profile.ModelingProfile.UseRndInteger = chkTS_RndInteger.Checked; Profile.ModelingProfile.IntegerMin = Convert.ToInt32(txtTS_IntegerMin.Text); Profile.ModelingProfile.IntegerMax = Convert.ToInt32(txtTS_IntegerMax.Text); Profile.ModelingProfile.UseRndDouble = chkTS_RndDouble.Checked; }
// // Update the UI controls Generations tab page private void UpdateUI_Generations(GPProjectProfile Profile) { chkGens_MaxNumber.Checked = Profile.m_useMaxNumber; udGens_MaxNumber.Value = Profile.m_maxNumber; chkGens_RawFitness0.Checked = Profile.m_useRawFitness0; chkGens_HitsMaxed.Checked = Profile.m_useHitsMaxed; }
// // Save the UI controls Generations tab page private void CollectUI_Generations(GPProjectProfile Profile) { Profile.m_useMaxNumber = chkGens_MaxNumber.Checked; Profile.m_maxNumber = (int)udGens_MaxNumber.Value; Profile.m_useRawFitness0 = chkGens_RawFitness0.Checked; Profile.m_useHitsMaxed = chkGens_HitsMaxed.Checked; }
// // Save the UI controls Program Structure section private void CollectUI_ProgramStructure(GPProjectProfile Profile) { Profile.ModelingProfile.ProbabilityReproduction = (short)udStructure_Reproduction.Value; Profile.ModelingProfile.ProbabilityMutation = (short)udStructure_Mutation.Value; Profile.ModelingProfile.ProbabilityCrossover = (short)udStructure_Crossover.Value; Profile.ModelingProfile.UseMemory = chkStructure_UseMemory.Checked; Profile.ModelingProfile.CountMemory = (short)udStructure_MemoryCount.Value; }
/// <summary> /// Constructor that passes in the various properties the modeler needs from /// the UI to manage the remote objects and to report back to the UI as things /// take place. /// </summary> public GPModeler(GPProjectProfile profile, int TrainingID, DEL_ValidatedServer delValidatedServer, DEL_ReportStatus delStatus, DEL_ReportFitness delFitness, DEL_GenerationComplete delGenerationComplete) { m_Profile = profile; m_TrainingID = TrainingID; m_DELValidatedServer = delValidatedServer; m_DELReportStatus = delStatus; m_DELReportFitness = delFitness; m_DELGenerationComplete = delGenerationComplete; }
public BatchProcess(GPProjectProfile Profile, int TrainingDataID, int ProjectID) { this.Profile = Profile; this.TrainingDataID = TrainingDataID; this.ProjectID = ProjectID; this.TimeAdded = DateTime.Now; this.IsStarted = false; this.Canceled = false; }
// // Grabs the current state of the UI and updates the profile // Training structure accordingly. private void CollectProfileUI(GPProjectProfile Profile) { CollectUI_ModelingType(Profile); CollectUI_ProgramStructure(Profile); CollectUI_PopulationStructure(Profile); CollectUI_PopulationDistributed(Profile); CollectUI_Generations(Profile); CollectUI_Fitness(Profile); CollectUI_FunctionSet(Profile); CollectUI_TerminalSet(Profile); }
// // Save the UI status for the Distributed Population Options private void CollectUI_PopulationDistributed(GPProjectProfile Profile) { Profile.ModelingProfile.DistributedTransferCount = (int)udDistributed_TransferCount.Value; if (rdDistributed_Topology_Ring.Checked) { Profile.ModelingProfile.DistributedTopology = GPEnums.DistributedTopology.Ring; } else if (rdDistributed_Topology_Star.Checked) { Profile.ModelingProfile.DistributedTopology = GPEnums.DistributedTopology.Star; } Profile.ModelingProfile.DistributedTopologyStarPercent = (int)udDistributed_Topology_StarPercent.Value; }
// // Save the UI controls Modeling Type section private void CollectUI_ModelingType(GPProjectProfile Profile) { if (rdModeling_Regression.Checked) { Profile.ModelType.Type = GPEnums.ModelType.Regression; } else if (rdModeling_TimeSeries.Checked) { Profile.ModelType.Type = GPEnums.ModelType.TimeSeries; Profile.ModelType.InputDimension = (short)udModeling_InputDimension.Value; Profile.ModelType.PredictionDistance = (short)udModeling_PredictionDistance.Value; } }
/// <summary> /// Sets all the UI controls according to this modeling profile. /// </summary> /// <param name="Profile">Profile to load into the UI</param> private void UpdateProfileUI(GPProjectProfile Profile) { m_LoadingProfile = true; UpdateUI_ModelingType(Profile); UpdateUI_ProgramStructure(Profile); UpdateUI_PopulationStructure(Profile); UpdateUI_PopulationDistributed(Profile); UpdateUI_Generations(Profile); UpdateUI_Fitness(Profile); UpdateUI_FunctionSet(Profile); UpdateUI_TerminalSet(Profile); m_LoadingProfile = false; }
// // Update the UI controls Modeling Type section private void UpdateUI_ModelingType(GPProjectProfile Profile) { switch (Profile.ModelType.Type) { case GPEnums.ModelType.Regression: rdModeling_Regression.Checked = true; break; case GPEnums.ModelType.TimeSeries: rdModeling_TimeSeries.Checked = true; udModeling_InputDimension.Value = Profile.ModelType.InputDimension; udModeling_PredictionDistance.Value = Profile.ModelType.PredictionDistance; break; } }
private void btnProfileAdd_Click(object sender, EventArgs e) { // // Ensure a training data set has been added if (m_Project.DataTrainingID == 0) { MessageBox.Show("Please select a training data set before adding a modeling profile", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK); return; } // // Disable the training data selection button btnDataTraining.Enabled = false; // // Create a new, default, modeling profile for the user m_Profile = new GPProjectProfile(); // // Update the controls with this profile UpdateProfileUI(m_Profile); int ModelProfileID = 0; m_Profile.CreateProfileInDB(ref ModelProfileID); // // Add the entry to the list of profiles ListViewItem lvNew = lvProfiles.Items.Add("New Profile"); lvNew.Tag = ModelProfileID; lvNew.ImageIndex = 0; lvProfilesModeling.Items.Add((ListViewItem)lvNew.Clone()); lvProfilesResults.Items.Add((ListViewItem)lvNew.Clone()); m_Project.ModelProfiles.Add(ModelProfileID); // // Save the project to the database m_Project.Save(); // // Set the profile label into edit mode - Before editing, select it // so that the after edit will end up working in the case this is // the first item lvNew.Selected = true; lvNew.BeginEdit(); }
// // Save the UI controls Function Set tab page private void CollectUI_FunctionSet(GPProjectProfile Profile) { // // Reset the function set Profile.FunctionSet.Clear(); // // Go through the list view and add back in the selected items foreach (ListViewItem item in lvFunctions.Items) { if (item.Checked) { Profile.FunctionSet.Add(item.Text); } } }
// // Update the UI controls for the Distributed Population Options private void UpdateUI_PopulationDistributed(GPProjectProfile Profile) { udDistributed_TransferCount.Value = Profile.ModelingProfile.DistributedTransferCount; switch (Profile.ModelingProfile.DistributedTopology) { case GPEnums.DistributedTopology.Ring: rdDistributed_Topology_Ring.Checked = true; break; case GPEnums.DistributedTopology.Star: rdDistributed_Topology_Star.Checked = true; break; } udDistributed_Topology_StarPercent.Value = Profile.ModelingProfile.DistributedTopologyStarPercent; }
private void tsModelBatch_Click(object sender, EventArgs e) { GPProjectProfile Profile = null; // // Validate we can move forward with processing if (!CanModel(ref Profile)) { return; } // // Add this to the Batch Processing Manager. This is a synchronous // function call to add the simulation. The batch processor will // place it into a queue and run the simulation asynchronously...in short, // this does not block. fmMain.BatchManager.AddSimulation(Profile, m_Project.DataTrainingID, m_Project.DBCode); }
// // Save the UI controls Fitness tab page /// <summary> /// Grab the UI control settings from the Fitness tab page /// </summary> /// <param name="Profile">Profile object to place the settings</param> private void CollectUI_Fitness(GPProjectProfile Profile) { // // Measurement of fitness - Find the checked item, there // will only be one. foreach (RadioButton btn in flowFitnessFunctions.Controls) { if (btn.Checked) { Profile.FitnessFunctionID = Convert.ToInt32(btn.Tag.ToString()); } } // // Adaptive parsimony Profile.ModelingProfile.AdaptiveParsimony = chkFitness_Parsimony.Checked; Profile.ModelingProfile.SPEA2MultiObjective = chkFitness_MultiObjective.Checked; }
/// <summary> /// Update the UI controls on the Fitness tab page /// </summary> /// <param name="Profile">Reference to the object containing the profile settings</param> private void UpdateUI_Fitness(GPProjectProfile Profile) { // // Measurement of fitness - Check the item with the correct // FitnessFunctionID value foreach (RadioButton btn in flowFitnessFunctions.Controls) { if (btn.Tag.ToString() == Profile.FitnessFunctionID.ToString()) { btn.Checked = true; } } // // Adaptive parsimiony setting chkFitness_Parsimony.Checked = Profile.ModelingProfile.AdaptiveParsimony; chkFitness_MultiObjective.Checked = Profile.ModelingProfile.SPEA2MultiObjective; }
// // Update the UI controls Function Set tab page private void UpdateUI_FunctionSet(GPProjectProfile Profile) { // // Reset all the items to be not checked foreach (ListViewItem item in lvFunctions.Items) { item.Checked = false; } // // Set which functions belong to this profile foreach (string Function in Profile.FunctionSet) { // // Check the item of the same name ListViewItem item = lvFunctions.FindItemWithText(Function); if (item != null) { item.Checked = true; } } }
// // Update the UI controls Program Structure section private void UpdateUI_ProgramStructure(GPProjectProfile Profile) { udStructure_Reproduction.Value = Profile.ModelingProfile.ProbabilityReproduction; udStructure_Mutation.Value = Profile.ModelingProfile.ProbabilityMutation; udStructure_Crossover.Value = Profile.ModelingProfile.ProbabilityCrossover; // // ADFs lvADF.Items.Clear(); foreach (byte adf in Profile.m_ADFSet) { ListViewItem lviADF = lvADF.Items.Add("ADF" + (lvADF.Items.Count)); lviADF.SubItems.Add(adf.ToString()); } // // ADLs lvADL.Items.Clear(); foreach (byte adl in Profile.m_ADLSet) { ListViewItem lviADL = lvADL.Items.Add("ADL" + (lvADL.Items.Count)); lviADL.SubItems.Add(adl.ToString()); } // // ADRs lvADR.Items.Clear(); foreach (byte adr in Profile.m_ADRSet) { ListViewItem lviADR = lvADR.Items.Add("ADR" + (lvADR.Items.Count)); lviADR.SubItems.Add(adr.ToString()); } chkStructure_UseMemory.Checked = Profile.ModelingProfile.UseMemory; udStructure_MemoryCount.Value = Profile.ModelingProfile.CountMemory; }
/// <summary> /// Validates whether or not the modeling should proceed. /// </summary> /// <param name="Profile">If the profile is valid, reference to the modeling profile</param> /// <returns>true/false depending on whether the model is validated for simulation</returns> private bool CanModel(ref GPProjectProfile Profile) { // // Ensure a profile is selected if (lvProfilesModeling.SelectedIndices.Count == 0) { MessageBox.Show("Please select a modeling profile", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } // // Download the profile from the database Profile = new GPProjectProfile(); Profile.LoadFromDB((int)lvProfilesModeling.SelectedItems[0].Tag); // // If the project doesn't have training data, don't start the modeling if (!(m_Project.DataTrainingID > 0)) { MessageBox.Show("Select a training data set before modeling", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK); return(false); } switch (Profile.ValidateForModeling()) { case GPProjectProfile.Validation.FunctionSet: MessageBox.Show("Please select functions for modeling", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK); return(false); case GPProjectProfile.Validation.Probability: MessageBox.Show("Ensure the Population Operators total 100", GPEnums.APPLICATON_NAME, MessageBoxButtons.OK); return(false); } return(true); }
private void lvProfiles_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { // // If the current profile is dirty, ask the user if they want to save it if (m_Profile != null && m_Profile.Dirty) { if (MessageBox.Show("Current profile has been modified, would you like to save it first?", GPEnums.APPLICATON_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { btnProfileSave_Click(sender, e); } // // Set the dirty flag to false even if the user didn't save, it prevents // the code from asking them again. m_Profile.Dirty = false; } // // If a modeling session is active, don't enable the Delete button if (!btnCancel.Enabled) { btnProfileDelete.Enabled = e.IsSelected; } btnProfileSave.Enabled = false; // Always disable upon new selection btnProfileCopy.Enabled = e.IsSelected; if (e.IsSelected) { // // Get the selected profile displayed int ProfileID = (int)e.Item.Tag; m_Profile = new GPProjectProfile(); m_Profile.LoadFromDB(ProfileID); UpdateProfileUI(m_Profile); // // If this profile is in use, then disable all the tab pages // so it can't be modified bool InUse = m_Profile.ProfileInUse; foreach (TabPage Page in tabProfile.TabPages) { foreach (Control Child in Page.Controls) { Child.Enabled = !InUse; } } // // Disable the delete buttons for the ADF, ADL and ADRs if (lvADF.SelectedItems.Count == 0) { btnADFDelete.Enabled = false; } if (lvADL.SelectedItems.Count == 0) { btnADLDelete.Enabled = false; } if (lvADR.SelectedItems.Count == 0) { btnADRDelete.Enabled = false; } } else { // // Disable the ability to edit the profile foreach (TabPage Page in tabProfile.TabPages) { foreach (Control Child in Page.Controls) { Child.Enabled = false; } } } }