Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/02/12 17:16:21 (12 years ago)
Author:
abeham
Message:

#1855:

  • Added IStorableContent to HungarianAlgorithm, LinearAssignmentProblem, and LAPAssignment (it was only storable, because the result is storable)
  • Added separate AfterDeserialization hook and renamed AttachEventHandlers to RegisterEventHandlers
  • Added cloning of rowNames and columnNames in LAPAssignment
  • Changed the default instance of the LinearAssignmentProblem
Location:
trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/HungarianAlgorithm.cs

    r8124 r8183  
    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 {
     
    6870    private HungarianAlgorithm(HungarianAlgorithm original, Cloner cloner)
    6971      : base(original, cloner) {
    70       AttachEventHandlers();
     72      RegisterEventHandlers();
    7173    }
    7274    public HungarianAlgorithm()
     
    8385
    8486      UpdateAnalyzers();
    85       AttachEventHandlers();
     87      RegisterEventHandlers();
    8688
    8789      Problem = new LinearAssignmentProblem();
     
    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);
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LAPAssignment.cs

    r8093 r8183  
    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]
     
    9394      costs = cloner.Clone(original.costs);
    9495      assignment = cloner.Clone(original.assignment);
     96      rowNames = cloner.Clone(original.rowNames);
     97      columnNames = cloner.Clone(original.columnNames);
    9598      quality = cloner.Clone(original.quality);
    9699    }
     
    117120    }
    118121
    119 
    120122    public event PropertyChangedEventHandler PropertyChanged;
    121123    private void OnPropertyChanged(string propertyName) {
  • trunk/sources/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs

    r8093 r8183  
    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.";
    4040    public static readonly string RowNamesDescription = "The elements represented by the rows of the costs matrix.";
    4141    public static readonly string ColumnNamesDescription = "The elements represented by the columns of the costs matrix.";
     42
     43    public string Filename { get; set; }
    4244
    4345    public override Image ItemImage {
     
    108110      ((OptionalValueParameter<StringArray>)ColumnNamesParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
    109111
    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;
     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;
    115117
    116118      bestLAPSolutionAnalyzer = new BestLAPSolutionAnalyzer();
Note: See TracChangeset for help on using the changeset viewer.