public void Approximation(List<AttributeDefinition> attributeDefinitions, long previousDecisionTableHistoryId) { var previousDTHistory = DecisionTableHistoryRepository.GetList().FirstOrDefault(p => p.Id == previousDecisionTableHistoryId); if (previousDTHistory == null) return; var ds = GetDecisionSystem(attributeDefinitions, previousDTHistory.DecisionTable.TableName); previousDTHistory = GetReductResult().FirstOrDefault(p => p.Id == previousDecisionTableHistoryId); ds.ConditionAttributes = previousDTHistory.Reducts.Select(p => p.AttributeIndex + 1).ToArray(); var indRel = IndiscernibilityRelation.Equivalence(ds.ConditionAttributes); ApproximationSpace aprSpace = new ApproximationSpace(ds, indRel, RoughInclusion.Standard); var objectIdClasses = aprSpace.IndiscernibilityClasses().Select(c => c.Select(o => (long)o[0])); var dtHistory = new DecisionTableHistory { Action = EDTHistoryAction.Approximation, ParentId = previousDTHistory.Id, DecisionTableId = previousDTHistory.DecisionTableId, CreatedDate = DateTime.Now.ToNormalDateTimeString(), DecisionTable = previousDTHistory.DecisionTable, Decription = string.Format("Run Approximation on Table \"{0}\"", previousDTHistory.DecisionTable.TableName) }; DecisionTableHistoryRepository.Create(dtHistory); ApproximationRepository.CreateIndiscernibilityClass(dtHistory.Id, objectIdClasses); }
public QuickReductResultForm(DecisionTableHistory dtHistory, IEnumerable<Reduct> reducts) { InitializeComponent(); this.dgvReductResults.AutoGenerateColumns = false; this.DTHistory = dtHistory; this.Reducts = reducts; this.Digitizer = new Business.Digitizer(dtHistory.DecisionTable); txtQuickRedultDescription.Text = this.DTHistory.Decription; }
public static long Create(DecisionTableHistory model) { long id = 0; using (var con = EstablishConnection()) { con.Open(); con.Execute(@" INSERT INTO DecisionTableHistories(DecisionTableId, Action, Decription, CreatedDate, ParentId) VALUES(@DecisionTableId, @Action, @Decription, @CreatedDate, @ParentId); ", model); id = con.Query<long>("SELECT last_insert_rowid();").First(); model.Id = id; con.Close(); } return id; }
public void SaveQuickReductResult(DecisionTableHistory dtHistory, IEnumerable<Reduct> reducts) { dtHistory.Decription = string.Format( "Run Quick Reduct on Table \"{0}\" with reduct attributes: {1}", dtHistory.DecisionTable.TableName, string.Join(", ", (new Digitizer(dtHistory.DecisionTable)).Translate( reducts.Select(p => p.AttributeIndex) )) ); DecisionTableHistoryRepository.Create(dtHistory); foreach (var reduct in reducts) { reduct.DecisionTableHistoryId = dtHistory.Id; } ReductRepository.Create(reducts); }
public Tuple<DecisionTableHistory, IEnumerable<Reduct>> QuickReduct(List<AttributeDefinition> attributeDefinitions, long previousDecisionTableHistoryId) { var previousDTHistory = DecisionTableHistoryRepository.GetList().FirstOrDefault(p => p.Id == previousDecisionTableHistoryId); if (previousDTHistory == null) return null; var ds = GetDecisionSystem(attributeDefinitions, previousDTHistory.DecisionTable.TableName); QuickReductProcessor processor = new QuickReductProcessor(ds); var dtHistory = new DecisionTableHistory { Action = EDTHistoryAction.QuickReduct, ParentId = previousDTHistory.Id, DecisionTableId = previousDTHistory.DecisionTableId, CreatedDate = DateTime.Now.ToNormalDateTimeString(), DecisionTable = previousDTHistory.DecisionTable, Decription = string.Format("Run Quick Reduct on Table \"{0}\"", previousDTHistory.DecisionTable.TableName) }; //DecisionTableHistoryRepository.Create(dtHistory); var reducts = new List<Reduct>(); // Show results // Console.WriteLine("\nAll reducts: "); for (int i = 0; i < processor.Results.Count; i++) { var rs = processor.Results[i]; foreach (var attributeIndex in rs) { reducts.Add(new Reduct { ResultIndex = i, DecisionTableHistoryId = dtHistory.Id, AttributeIndex = attributeIndex, ReductType = EReductType.Normal }); } //Console.WriteLine((i + 1).ToString() + ". {" + string.Join(",", rs.OrderBy(x => x)) + "}"); } //Console.WriteLine("\nMinimal reducts: "); var miRd = processor.MinimalReducts.ToArray(); for (int i = 0; i < miRd.Length; i++) { var rs = miRd[i]; foreach (var attributeIndex in rs) { reducts.Add(new Reduct { ResultIndex = i, DecisionTableHistoryId = dtHistory.Id, AttributeIndex = attributeIndex, ReductType = EReductType.Minimal, }); } //Console.WriteLine((i + 1).ToString() + ". {" + string.Join(",", rs.OrderBy(x => x)) + "}"); } foreach (var attributeIndex in processor.CoreAttrs) { reducts.Add(new Reduct { ResultIndex = 0, DecisionTableHistoryId = dtHistory.Id, AttributeIndex = attributeIndex, ReductType = EReductType.Core }); } //Console.WriteLine("\nCore attributes: " + string.Join(",", processor.CoreAttrs)); //ReductRepository.Create(reducts); return new Tuple<DecisionTableHistory, IEnumerable<Reduct>>(dtHistory, reducts); }