Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/12 09:51:13 (12 years ago)
Author:
jkarder
Message:

#1331: merged r8086:8330 from trunk

Location:
branches/ScatterSearch (trunk integration)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)

  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/Analyzers/BestLAPSolutionAnalyzer.cs

    r8086 r8331  
    4242      get { return (ILookupParameter<DoubleMatrix>)Parameters["Costs"]; }
    4343    }
     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    }
    4450    public IScopeTreeLookupParameter<Permutation> AssignmentParameter {
    4551      get { return (IScopeTreeLookupParameter<Permutation>)Parameters["Assignment"]; }
     
    7177      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    7278      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));
    7381      Parameters.Add(new ScopeTreeLookupParameter<Permutation>("Assignment", "The LAP solutions from which the best solution should be analyzed."));
    7482      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the LAP solutions which should be analyzed."));
     
    8694    public override IOperation Apply() {
    8795      var costs = CostsParameter.ActualValue;
     96      var rowNames = RowNamesParameter.ActualValue;
     97      var columnNames = ColumnNamesParameter.ActualValue;
    8898      var permutations = AssignmentParameter.ActualValue;
    8999      var qualities = QualityParameter.ActualValue;
     
    122132      LAPAssignment assignment = BestSolutionParameter.ActualValue;
    123133      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));
    125135        BestSolutionParameter.ActualValue = assignment;
    126136        results.Add(new Result("Best LAP Solution", assignment));
     
    131141          assignment.Assignment = (Permutation)permutations[i].Clone();
    132142          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;
    133149        }
    134150      }
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/HungarianAlgorithm.cs

    r8086 r8331  
    3434  /// A genetic algorithm.
    3535  /// </summary>
    36   [Item("HungarianAlgorithm", "The Hungarian algorithm can be used to solve the linear assignment problem in O(n^3). It is also known as the Kuhn–Munkres algorithm or Munkres assignment algorithm.")]
     36  [Item("Hungarian Algorithm", "The Hungarian algorithm can be used to solve the linear assignment problem in O(n^3). It is also known as the Kuhn–Munkres algorithm or Munkres assignment algorithm.")]
    3737  [Creatable("Algorithms")]
    3838  [StorableClass]
    39   public sealed class HungarianAlgorithm : EngineAlgorithm {
     39  public sealed class HungarianAlgorithm : EngineAlgorithm, IStorableContent {
     40    public string Filename { get; set; }
     41
    4042    #region Problem Properties
    4143    public override Type ProblemType {
     
    5254      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
    5355    }
    54 
    5556    #endregion
    5657
     
    6970    private HungarianAlgorithm(HungarianAlgorithm original, Cloner cloner)
    7071      : base(original, cloner) {
    71       // TODO: clone your private fields here
    72       AttachEventHandlers();
     72      RegisterEventHandlers();
    7373    }
    7474    public HungarianAlgorithm()
     
    8585
    8686      UpdateAnalyzers();
    87       AttachEventHandlers();
     87      RegisterEventHandlers();
     88
     89      Problem = new LinearAssignmentProblem();
    8890    }
    8991
     
    121123    #region Helpers
    122124    [StorableHook(HookType.AfterDeserialization)]
    123     private void AttachEventHandlers() {
     125    private void AfterDeserialization() {
     126      RegisterEventHandlers();
     127    }
     128
     129    private void RegisterEventHandlers() {
    124130      if (Problem != null) {
    125131        Problem.SolutionCreatorChanged += new EventHandler(Problem_SolutionCreatorChanged);
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/LAPAssignment.cs

    r8086 r8331  
    3030  [Item("LAP Assignment", "Represents a solution to the LAP.")]
    3131  [StorableClass]
    32   public sealed class LAPAssignment : Item, INotifyPropertyChanged {
     32  public sealed class LAPAssignment : Item, INotifyPropertyChanged, IStorableContent {
     33    public string Filename { get; set; }
    3334
    3435    [Storable]
     
    4041        costs = value;
    4142        if (changed) OnPropertyChanged("Costs");
     43      }
     44    }
     45
     46    [Storable]
     47    private StringArray rowNames;
     48    public StringArray RowNames {
     49      get { return rowNames; }
     50      set {
     51        bool changed = (rowNames != value);
     52        rowNames = value;
     53        if (changed) OnPropertyChanged("RowNames");
     54      }
     55    }
     56
     57    [Storable]
     58    private StringArray columnNames;
     59    public StringArray ColumnNames {
     60      get { return columnNames; }
     61      set {
     62        bool changed = (columnNames != value);
     63        columnNames = value;
     64        if (changed) OnPropertyChanged("ColumnNames");
    4265      }
    4366    }
     
    7194      costs = cloner.Clone(original.costs);
    7295      assignment = cloner.Clone(original.assignment);
     96      rowNames = cloner.Clone(original.rowNames);
     97      columnNames = cloner.Clone(original.columnNames);
    7398      quality = cloner.Clone(original.quality);
    7499    }
     
    81106      this.quality = quality;
    82107    }
     108    public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment)
     109      : this(costs, assignment) {
     110      this.rowNames = rowNames;
     111      this.columnNames = columnNames;
     112    }
     113    public LAPAssignment(DoubleMatrix costs, StringArray rowNames, StringArray columnNames, Permutation assignment, DoubleValue quality)
     114      : this(costs, rowNames, columnNames, assignment) {
     115      this.quality = quality;
     116    }
    83117
    84118    public override IDeepCloneable Clone(Cloner cloner) {
    85119      return new LAPAssignment(this, cloner);
    86120    }
    87 
    88121
    89122    public event PropertyChangedEventHandler PropertyChanged;
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs

    r8086 r8331  
    3636  [Creatable("Problems")]
    3737  [StorableClass]
    38   public sealed class LinearAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<ILAPEvaluator, IPermutationCreator> {
     38  public sealed class LinearAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<ILAPEvaluator, IPermutationCreator>, IStorableContent {
    3939    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.";
     42
     43    public string Filename { get; set; }
    4044
    4145    public override Image ItemImage {
     
    5256    public IValueParameter<Permutation> BestKnownSolutionParameter {
    5357      get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; }
     58    }
     59    public IValueParameter<StringArray> RowNamesParameter {
     60      get { return (IValueParameter<StringArray>)Parameters["RowNames"]; }
     61    }
     62    public IValueParameter<StringArray> ColumnNamesParameter {
     63      get { return (IValueParameter<StringArray>)Parameters["ColumnNames"]; }
    5464    }
    5565    #endregion
     
    5969      get { return CostsParameter.Value; }
    6070      set { CostsParameter.Value = value; }
     71    }
     72    public StringArray RowNames {
     73      get { return RowNamesParameter.Value; }
     74      set { RowNamesParameter.Value = value; }
     75    }
     76    public StringArray ColumnNames {
     77      get { return ColumnNamesParameter.Value; }
     78      set { ColumnNamesParameter.Value = value; }
    6179    }
    6280    public ItemSet<Permutation> BestKnownSolutions {
     
    85103      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));
    86104      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      
     105      Parameters.Add(new OptionalValueParameter<StringArray>("RowNames", RowNamesDescription));
     106      Parameters.Add(new OptionalValueParameter<StringArray>("ColumnNames", ColumnNamesDescription));
     107
    88108      ((ValueParameter<DoubleMatrix>)CostsParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     109      ((OptionalValueParameter<StringArray>)RowNamesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     110      ((OptionalValueParameter<StringArray>)ColumnNamesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
     111
     112      RowNames = new StringArray(new string[] { "Eric", "Robert", "Allison" });
     113      ColumnNames = new StringArray(new string[] { "MRI", "Blood test", "Angiogram" });
     114      Costs[0, 0] = 4; Costs[0, 1] = 5; Costs[0, 2] = 3;
     115      Costs[1, 0] = 6; Costs[1, 1] = 6; Costs[1, 2] = 4;
     116      Costs[2, 0] = 5; Costs[2, 1] = 5; Costs[2, 2] = 1;
    89117
    90118      bestLAPSolutionAnalyzer = new BestLAPSolutionAnalyzer();
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/Plugin.cs.frame

    r8086 r8331  
    2323
    2424namespace HeuristicLab.Problems.LinearAssignment {
    25   [Plugin("HeuristicLab.Problems.LinearAssignment", "3.3.6.$WCREV$")]
     25  [Plugin("HeuristicLab.Problems.LinearAssignment", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.LinearAssignment-3.3.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.LinearAssignment/3.3/Properties/AssemblyInfo.cs.frame

    r8086 r8331  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     57[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.