public static void SetGlobalInProperties(ReflectionTools arct, ConsensusFunction aEnsembleAlg, Tree Tree, List <Structuring> aStrcs) { ClusterEnsemble.DataStructures.Property _Set = Tree.Value.Properties.First(p => p.Name == "Set"); _Set.Value = Enviroment.Set; ClusterEnsemble.DataStructures.Property _Structurings = Tree.Value.Properties.First(p => p.Name == "Structurings"); _Structurings.Value = aStrcs; arct.SetProperty(Tree.Value.FullName, aEnsembleAlg, _Set); arct.SetProperty(Tree.Value.FullName, aEnsembleAlg, _Structurings); }
private Structuring RunMethod(ConsensusFunction aConsensusFunction) { try { aConsensusFunction.IContainerProgressBar = IContainerProgressBar; //return aConsensusFunction.BuildStructuring(); return(aConsensusFunction.BuildStructuringWithReduction()); } catch (Exception _ex) { GeneralTools.Tools.WriteToLog(_ex); return(null); } }
private void RunFinish(Structuring aStructuring, ConsensusFunction aConsensusFunction) { try { ConsensusFunction _EnsembleAlg = aConsensusFunction; Structuring _structuring = aStructuring; if (_structuring != null) { TimeSpan ts = _EnsembleAlg.Time; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); PartitionInfo _partInfo = new PartitionInfo() { AlgorithmName = this.tb_SelectEnsembleAlg.Text, ConsensusFunction = _EnsembleAlg, Partition = _structuring, AlgorithmType = AlgorithmType.Ensemble, Time = elapsedTime, ElementCount = aConsensusFunction.ReductionElementCount, SearchSpace = ReductionFunction.BellNumber(aConsensusFunction.ReductionElementCount), Index = -1 }; this.uctrl_ListClusterAlgVisualizerEnsemble.AddPartitionInfo(_partInfo); this.tb_output.Text = _EnsembleAlg.Output; if (NewStructuringEventHandler != null) { NewStructuringEventHandler(this, new NewStructuringEventArgs(_partInfo)); } } } catch (Exception _ex) { GeneralTools.Tools.WriteToLog(_ex); } }
private void bt_Run_Click(object sender, RoutedEventArgs e) { try { if (HasSelectedAlgorithm) { string _Error = ""; if (!Enviroment.CanRunAlgorithm(out _Error, AlgorithmType.Ensemble)) { MessageBox.Show(_Error, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } ReflectionTools _rcet = new ReflectionTools(); ConsensusFunction _EnsembleAlg = ReflectionTools.GetInstance <ConsensusFunction>(Tree.Value.FullName); foreach (CEDS.Property _p in Tree.Value.InProperties) { _rcet.SetProperty(Tree.Value.FullName, _EnsembleAlg, _p); } List <Structuring> _structuringsParams = GetSelectedStructurings(); if (_structuringsParams == null || _structuringsParams.Count == 0) { MessageBox.Show("You must select at least one Structuring to apply an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } VisualUtils.SetGlobalInProperties(_rcet, _EnsembleAlg, Tree, _structuringsParams); #region OLD CODE //Structuring _structuring = _EnsembleAlg.BuildStructuring(); //PartitionInfo _partInfo = new PartitionInfo() //{ // AlgorithmName = this.tb_SelectEnsembleAlg.Text, // ConsensusFunction = _EnsembleAlg, // Partition = _structuring, // AlgorithmType = AlgorithmType.Ensemble, // Index = -1 //}; //this.uctrl_ListClusterAlgVisualizerEnsemble.AddPartitionInfo(_partInfo); //if (NewStructuringEventHandler != null) //{ // NewStructuringEventHandler(this, new NewStructuringEventArgs(_partInfo)); //} #endregion Run _run = RunMethod; _run.BeginInvoke(_EnsembleAlg, RunFinish, new DataThread() { ConsensusFunction = _EnsembleAlg, Run = _run }); } else { MessageBox.Show("You must first select an Ensemble algorithm.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception _ex) { GeneralTools.Tools.WriteToLog(_ex); } }