Changeset 8093 for trunk/sources/HeuristicLab.Problems.LinearAssignment
- Timestamp:
- 06/24/12 17:57:51 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/Analyzers/BestLAPSolutionAnalyzer.cs
r8022 r8093 42 42 get { return (ILookupParameter<DoubleMatrix>)Parameters["Costs"]; } 43 43 } 44 public IValueLookupParameter<StringArray> RowNamesParameter { 45 get { return (IValueLookupParameter<StringArray>)Parameters["RowNames"]; } 46 } 47 public IValueLookupParameter<StringArray> ColumnNamesParameter { 48 get { return (IValueLookupParameter<StringArray>)Parameters["ColumnNames"]; } 49 } 44 50 public IScopeTreeLookupParameter<Permutation> AssignmentParameter { 45 51 get { return (IScopeTreeLookupParameter<Permutation>)Parameters["Assignment"]; } … … 71 77 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 72 78 Parameters.Add(new LookupParameter<DoubleMatrix>("Costs", LinearAssignmentProblem.CostsDescription)); 79 Parameters.Add(new ValueLookupParameter<StringArray>("RowNames", LinearAssignmentProblem.RowNamesDescription)); 80 Parameters.Add(new ValueLookupParameter<StringArray>("ColumnNames", LinearAssignmentProblem.ColumnNamesDescription)); 73 81 Parameters.Add(new ScopeTreeLookupParameter<Permutation>("Assignment", "The LAP solutions from which the best solution should be analyzed.")); 74 82 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the LAP solutions which should be analyzed.")); … … 86 94 public override IOperation Apply() { 87 95 var costs = CostsParameter.ActualValue; 96 var rowNames = RowNamesParameter.ActualValue; 97 var columnNames = ColumnNamesParameter.ActualValue; 88 98 var permutations = AssignmentParameter.ActualValue; 89 99 var qualities = QualityParameter.ActualValue; … … 122 132 LAPAssignment assignment = BestSolutionParameter.ActualValue; 123 133 if (assignment == null) { 124 assignment = new LAPAssignment(costs, (Permutation)permutations[i].Clone(), new DoubleValue(qualities[i].Value));134 assignment = new LAPAssignment(costs, rowNames, columnNames, (Permutation)permutations[i].Clone(), new DoubleValue(qualities[i].Value)); 125 135 BestSolutionParameter.ActualValue = assignment; 126 136 results.Add(new Result("Best LAP Solution", assignment)); … … 131 141 assignment.Assignment = (Permutation)permutations[i].Clone(); 132 142 assignment.Quality.Value = qualities[i].Value; 143 if (rowNames != null) 144 assignment.RowNames = rowNames; 145 else assignment.RowNames = null; 146 if (columnNames != null) 147 assignment.ColumnNames = columnNames; 148 else assignment.ColumnNames = null; 133 149 } 134 150 } -
trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/HungarianAlgorithm.cs
r8022 r8093 52 52 get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; } 53 53 } 54 55 54 #endregion 56 55 … … 69 68 private HungarianAlgorithm(HungarianAlgorithm original, Cloner cloner) 70 69 : base(original, cloner) { 71 // TODO: clone your private fields here72 70 AttachEventHandlers(); 73 71 } … … 86 84 UpdateAnalyzers(); 87 85 AttachEventHandlers(); 86 87 Problem = new LinearAssignmentProblem(); 88 88 } 89 89 -
trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LAPAssignment.cs
r8022 r8093 44 44 45 45 [Storable] 46 private StringArray rowNames; 47 public StringArray RowNames { 48 get { return rowNames; } 49 set { 50 bool changed = (rowNames != value); 51 rowNames = value; 52 if (changed) OnPropertyChanged("RowNames"); 53 } 54 } 55 56 [Storable] 57 private StringArray columnNames; 58 public StringArray ColumnNames { 59 get { return columnNames; } 60 set { 61 bool changed = (columnNames != value); 62 columnNames = value; 63 if (changed) OnPropertyChanged("ColumnNames"); 64 } 65 } 66 67 [Storable] 46 68 private Permutation assignment; 47 69 public Permutation Assignment { … … 81 103 this.quality = quality; 82 104 } 105 public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment) 106 : this(costs, assignment) { 107 this.rowNames = rowNames; 108 this.columnNames = columnNames; 109 } 110 public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment, DoubleValue quality) 111 : this(costs, rowNames, columnNames, assignment) { 112 this.quality = quality; 113 } 83 114 84 115 public override IDeepCloneable Clone(Cloner cloner) { -
trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs
r8022 r8093 38 38 public sealed class LinearAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<ILAPEvaluator, IPermutationCreator> { 39 39 public static readonly string CostsDescription = "The cost matrix that describes the assignment of rows to columns."; 40 public static readonly string RowNamesDescription = "The elements represented by the rows of the costs matrix."; 41 public static readonly string ColumnNamesDescription = "The elements represented by the columns of the costs matrix."; 40 42 41 43 public override Image ItemImage { … … 52 54 public IValueParameter<Permutation> BestKnownSolutionParameter { 53 55 get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; } 56 } 57 public IValueParameter<StringArray> RowNamesParameter { 58 get { return (IValueParameter<StringArray>)Parameters["RowNames"]; } 59 } 60 public IValueParameter<StringArray> ColumnNamesParameter { 61 get { return (IValueParameter<StringArray>)Parameters["ColumnNames"]; } 54 62 } 55 63 #endregion … … 59 67 get { return CostsParameter.Value; } 60 68 set { CostsParameter.Value = value; } 69 } 70 public StringArray RowNames { 71 get { return RowNamesParameter.Value; } 72 set { RowNamesParameter.Value = value; } 73 } 74 public StringArray ColumnNames { 75 get { return ColumnNamesParameter.Value; } 76 set { ColumnNamesParameter.Value = value; } 61 77 } 62 78 public ItemSet<Permutation> BestKnownSolutions { … … 85 101 Parameters.Add(new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null)); 86 102 Parameters.Add(new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null)); 87 103 Parameters.Add(new OptionalValueParameter<StringArray>("RowNames", RowNamesDescription)); 104 Parameters.Add(new OptionalValueParameter<StringArray>("ColumnNames", ColumnNamesDescription)); 105 88 106 ((ValueParameter<DoubleMatrix>)CostsParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 107 ((OptionalValueParameter<StringArray>)RowNamesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 108 ((OptionalValueParameter<StringArray>)ColumnNamesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false; 109 110 RowNames = new StringArray(new string[] { "Human", "Von Neumann machine", "Quantum computer" }); 111 ColumnNames = new StringArray(new string[] { "Find a person's e-mail address", "Compute first 1000 decimals of Pi", "Factorize large integers" }); 112 Costs[0, 0] = 1; Costs[0, 1] = 10; Costs[0, 2] = 100; 113 Costs[1, 0] = 10; Costs[1, 1] = 1; Costs[1, 2] = 100; 114 Costs[2, 0] = 100; Costs[2, 1] = 10; Costs[2, 1] = 1; 89 115 90 116 bestLAPSolutionAnalyzer = new BestLAPSolutionAnalyzer();
Note: See TracChangeset
for help on using the changeset viewer.