Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/10/17 22:11:10 (7 years ago)
Author:
abeham
Message:

#1614: refactored code

  • change problem to derive from basic problem
  • using a combined instance class instead of individual parameters
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs

    r7970 r15504  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Data;
    2625using HeuristicLab.Encodings.IntegerVectorEncoding;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3736      get { return assignment; }
    3837      set {
    39         bool changed = (assignment != value);
     38        if (assignment == value) return;
    4039        assignment = value;
    41         if (changed) OnPropertyChanged("Assignment");
     40        OnPropertyChanged(nameof(Assignment));
    4241      }
    4342    }
    4443
    4544    [Storable]
    46     private DoubleValue quality;
    47     public DoubleValue Quality {
    48       get { return quality; }
     45    private Evaluation evaluation;
     46    public Evaluation Evaluation {
     47      get { return evaluation; }
    4948      set {
    50         bool changed = (quality != value);
    51         quality = value;
    52         if (changed) OnPropertyChanged("Quality");
     49        if (evaluation == value) return;
     50        evaluation = value;
     51        OnPropertyChanged(nameof(Evaluation));
    5352      }
    5453    }
    5554
    5655    [Storable]
    57     private DoubleValue flowDistanceQuality;
    58     public DoubleValue FlowDistanceQuality {
    59       get { return flowDistanceQuality; }
     56    private GQAPInstance problemInstance;
     57    public GQAPInstance ProblemInstance {
     58      get { return problemInstance; }
    6059      set {
    61         bool changed = (flowDistanceQuality != value);
    62         flowDistanceQuality = value;
    63         if (changed) OnPropertyChanged("FlowDistanceQuality");
    64       }
    65     }
    66 
    67     [Storable]
    68     private DoubleValue installationQuality;
    69     public DoubleValue InstallationQuality {
    70       get { return installationQuality; }
    71       set {
    72         bool changed = (installationQuality != value);
    73         installationQuality = value;
    74         if (changed) OnPropertyChanged("InstallationQuality");
    75       }
    76     }
    77 
    78     [Storable]
    79     private DoubleValue overbookedCapacity;
    80     public DoubleValue OverbookedCapacity {
    81       get { return overbookedCapacity; }
    82       set {
    83         bool changed = (overbookedCapacity != value);
    84         overbookedCapacity = value;
    85         if (changed) OnPropertyChanged("OverbookedCapacity");
    86       }
    87     }
    88 
    89     [Storable]
    90     private StringArray equipmentNames;
    91     public StringArray EquipmentNames {
    92       get { return equipmentNames; }
    93       set {
    94         bool changed = (equipmentNames != value);
    95         equipmentNames = value;
    96         if (changed) OnPropertyChanged("EquipmentNames");
    97       }
    98     }
    99 
    100     [Storable]
    101     private StringArray locationNames;
    102     public StringArray LocationNames {
    103       get { return locationNames; }
    104       set {
    105         bool changed = (locationNames != value);
    106         locationNames = value;
    107         if (changed) OnPropertyChanged("LocationNames");
    108       }
    109     }
    110 
    111     [Storable]
    112     private DoubleMatrix distances;
    113     public DoubleMatrix Distances {
    114       get { return distances; }
    115       set {
    116         bool changed = (distances != value);
    117         distances = value;
    118         if (changed) OnPropertyChanged("Distances");
    119       }
    120     }
    121 
    122     [Storable]
    123     private DoubleMatrix weights;
    124     public DoubleMatrix Weights {
    125       get { return weights; }
    126       set {
    127         bool changed = (weights != value);
    128         weights = value;
    129         if (changed) OnPropertyChanged("Weights");
    130       }
    131     }
    132 
    133     [Storable]
    134     private DoubleMatrix installationCosts;
    135     public DoubleMatrix InstallationCosts {
    136       get { return installationCosts; }
    137       set {
    138         bool changed = (installationCosts != value);
    139         installationCosts = value;
    140         if (changed) OnPropertyChanged("InstallationCosts");
    141       }
    142     }
    143 
    144     [Storable]
    145     private DoubleArray demands;
    146     public DoubleArray Demands {
    147       get { return demands; }
    148       set {
    149         bool changed = (demands != value);
    150         demands = value;
    151         if (changed) OnPropertyChanged("Demands");
    152       }
    153     }
    154 
    155     [Storable]
    156     private DoubleArray capacities;
    157     public DoubleArray Capacities {
    158       get { return capacities; }
    159       set {
    160         bool changed = (capacities != value);
    161         capacities = value;
    162         if (changed) OnPropertyChanged("Capacities");
    163       }
    164     }
    165 
    166     [Storable]
    167     private DoubleValue transportationCosts;
    168     public DoubleValue TransportationCosts {
    169       get { return transportationCosts; }
    170       set {
    171         bool changed = (transportationCosts != value);
    172         transportationCosts = value;
    173         if (changed) OnPropertyChanged("TransportationCosts");
    174       }
    175     }
    176 
    177     [Storable]
    178     private DoubleValue expectedRandomQuality;
    179     public DoubleValue ExpectedRandomQuality {
    180       get { return expectedRandomQuality; }
    181       set {
    182         bool changed = (expectedRandomQuality != value);
    183         expectedRandomQuality = value;
    184         if (changed) OnPropertyChanged("ExpectedRandomQuality");
    185       }
    186     }
    187 
    188     [Storable]
    189     private IGQAPEvaluator evaluator;
    190     public IGQAPEvaluator Evaluator {
    191       get { return evaluator; }
    192       set {
    193         bool changed = (evaluator != value);
    194         evaluator = value;
    195         if (changed) OnPropertyChanged("Evaluator");
     60        if (problemInstance == value) return;
     61        problemInstance = value;
     62        OnPropertyChanged(nameof(ProblemInstance));
    19663      }
    19764    }
     
    20269      : base(original, cloner) {
    20370      assignment = cloner.Clone(original.assignment);
    204       quality = cloner.Clone(original.quality);
    205       flowDistanceQuality = cloner.Clone(original.flowDistanceQuality);
    206       installationQuality = cloner.Clone(original.installationQuality);
    207       overbookedCapacity = cloner.Clone(original.overbookedCapacity);
    208       equipmentNames = cloner.Clone(original.equipmentNames);
    209       locationNames = cloner.Clone(original.locationNames);
    210       distances = cloner.Clone(original.distances);
    211       weights = cloner.Clone(original.weights);
    212       installationCosts = cloner.Clone(original.installationCosts);
    213       demands = cloner.Clone(original.demands);
    214       capacities = cloner.Clone(original.capacities);
    215       transportationCosts = cloner.Clone(original.transportationCosts);
    216       expectedRandomQuality = cloner.Clone(original.expectedRandomQuality);
    217       evaluator = cloner.Clone(original.evaluator);
     71      evaluation = cloner.Clone(original.evaluation);
     72      problemInstance = cloner.Clone(original.problemInstance);
    21873    }
    219     public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue expectedRandomQuality, IGQAPEvaluator evaluator)
     74    public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance)
     75      : this(assignment, problemInstance, problemInstance.Evaluate(assignment)) { }
     76    public GQAPAssignment(IntegerVector assignment, GQAPInstance problemInstance, Evaluation evaluation)
    22077      : base() {
    22178      this.assignment = assignment;
    222       this.quality = quality;
    223       this.flowDistanceQuality = flowDistanceQuality;
    224       this.installationQuality = installationQuality;
    225       this.overbookedCapacity = overbookedCapacity;
    226       this.equipmentNames = equipmentNames;
    227       this.locationNames = locationNames;
    228       this.distances = distances;
    229       this.weights = weights;
    230       this.installationCosts = installationCosts;
    231       this.demands = demands;
    232       this.capacities = capacities;
    233       this.transportationCosts = transportationCosts;
    234       this.expectedRandomQuality = expectedRandomQuality;
    235       this.evaluator = evaluator;
     79      this.evaluation = evaluation;
     80      this.problemInstance = problemInstance;
    23681    }
    23782
Note: See TracChangeset for help on using the changeset viewer.