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
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentArchiveView.Designer.cs

    r7438 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.
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentArchiveView.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.
     
    8585          if (Content == null) return;
    8686          foreach (var solution in Content.Solutions) {
    87             if (solution.OverbookedCapacity.Value <= 0.0) {
    88               paretoFrontChart.Series[0].Points.AddXY(solution.FlowDistanceQuality.Value, solution.InstallationQuality.Value);
     87            if (solution.Evaluation.ExcessDemand <= 0.0) {
     88              paretoFrontChart.Series[0].Points.AddXY(solution.Evaluation.FlowCosts, solution.Evaluation.InstallationCosts);
    8989              paretoFrontChart.Series[0].Points.Last().Tag = solution;
    9090            }
     
    101101      if (h.ChartElementType == ChartElementType.DataPoint) {
    102102        var solution = (GQAPSolution)((DataPoint)h.Object).Tag;
    103         var assignment = new GQAPAssignment(solution.Assignment, solution.Quality, solution.FlowDistanceQuality, solution.InstallationQuality, solution.OverbookedCapacity, Content.EquipmentNames, Content.LocationNames, Content.Distances, Content.Weights, Content.InstallationCosts, Content.Demands, Content.Capacities, Content.TransportationCosts, Content.ExpectedRandomQuality, Content.Evaluator);
     103        var assignment = new GQAPAssignment(solution.Assignment, Content.ProblemInstance, solution.Evaluation);
    104104
    105105        var view = MainFormManager.MainForm.ShowContent(assignment);
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.Designer.cs

    r7471 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.
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.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.
     
    2828using HeuristicLab.Common.Resources;
    2929using HeuristicLab.Core.Views;
    30 using HeuristicLab.Data;
    3130using HeuristicLab.Encodings.IntegerVectorEncoding;
    3231using HeuristicLab.MainForm;
     
    131130          qualityLabel.Text = "-";
    132131        } else {
    133           qualityLabel.Text = Content.Quality.ToString();
     132          qualityLabel.Text = Content.ProblemInstance.ToSingleObjective(Content.Evaluation).ToString();
    134133        }
    135134      }
     
    139138      if (InvokeRequired) Invoke((Action)UpdateFlowDistanceQuality);
    140139      else {
    141         if (Content == null || Content.FlowDistanceQuality == null) {
     140        if (Content == null || Content.Evaluation == null) {
    142141          flowDistanceQualityLabel.Text = "-";
    143142        } else {
    144           flowDistanceQualityLabel.Text = Content.FlowDistanceQuality.ToString();
     143          flowDistanceQualityLabel.Text = Content.Evaluation.FlowCosts.ToString();
    145144        }
    146145      }
     
    150149      if (InvokeRequired) Invoke((Action)UpdateInstallationQuality);
    151150      else {
    152         if (Content == null || Content.InstallationQuality == null) {
     151        if (Content == null || Content.Evaluation == null) {
    153152          installationQualityLabel.Text = "-";
    154153        } else {
    155           installationQualityLabel.Text = Content.InstallationQuality.ToString();
     154          installationQualityLabel.Text = Content.Evaluation.InstallationCosts.ToString();
    156155        }
    157156      }
     
    161160      if (InvokeRequired) Invoke((Action)UpdateOverbookedCapacity);
    162161      else {
    163         if (Content == null || Content.OverbookedCapacity == null) {
     162        if (Content == null || Content.Evaluation == null) {
    164163          overbookedCapacityLabel.Text = "-";
    165164        } else {
    166           overbookedCapacityLabel.Text = Content.OverbookedCapacity.ToString();
     165          overbookedCapacityLabel.Text = Content.Evaluation.ExcessDemand.ToString();
    167166        }
    168167      }
     
    179178            if (!locationNodes.ContainsKey(assignment[i])) {
    180179              string locationName = assignment[i].ToString();
    181               if (Content.LocationNames != null && Content.LocationNames.Length > assignment[i])
    182                 locationName = Content.LocationNames[assignment[i]];
     180              if (Content.ProblemInstance.LocationNames != null && Content.ProblemInstance.LocationNames.Length > assignment[i])
     181                locationName = Content.ProblemInstance.LocationNames[assignment[i]];
    183182              locationNodes.Add(assignment[i], new LocationNode(assignment[i], locationName));
    184183            }
    185184            string equipmentName = i.ToString();
    186             if (Content.EquipmentNames != null && Content.EquipmentNames.Length > i)
    187               equipmentName = Content.EquipmentNames[i];
     185            if (Content.ProblemInstance.EquipmentNames != null && Content.ProblemInstance.EquipmentNames.Length > i)
     186              equipmentName = Content.ProblemInstance.EquipmentNames[i];
    188187            locationNodes[assignment[i]].Nodes.Add(new EquipmentNode(i, equipmentName));
    189188          }
     
    205204      foreach (var node in GetAllSubNodes(assignmentTreeView.Nodes).OfType<EquipmentNode>()) {
    206205        int location = Content.Assignment[node.Equipment];
    207         installationCosts[node] = Content.InstallationCosts[node.Equipment, location];
     206        installationCosts[node] = Content.ProblemInstance.InstallationCosts[node.Equipment, location];
    208207      }
    209208      double max = installationCosts.Values.Max();
     
    224223      int equipment = selectedNode.Equipment;
    225224      double rowSum = 0, colSum = 0;
    226       for (int i = 0; i < Content.Weights.Columns; i++)
    227         if (i != equipment) rowSum += Content.Weights[equipment, i];
    228       for (int i = 0; i < Content.Weights.Rows; i++)
    229         if (i != equipment) colSum += Content.Weights[i, equipment];
     225      for (int i = 0; i < Content.ProblemInstance.Weights.Columns; i++)
     226        if (i != equipment) rowSum += Content.ProblemInstance.Weights[equipment, i];
     227      for (int i = 0; i < Content.ProblemInstance.Weights.Rows; i++)
     228        if (i != equipment) colSum += Content.ProblemInstance.Weights[i, equipment];
    230229
    231230      var otherEquipments = GetAllSubNodes(assignmentTreeView.Nodes)
     
    240239          other.ForeColor = assignmentTreeView.ForeColor;
    241240        } else {
    242           double rowInvProportion = rowSum == 0 ? 1.0 : (rowSum - Content.Weights[equipment, other.Equipment]) / rowSum;
    243           double colInvProportion = colSum == 0 ? 1.0 : (colSum - Content.Weights[other.Equipment, equipment]) / colSum;
     241          double rowInvProportion = rowSum == 0 ? 1.0 : (rowSum - Content.ProblemInstance.Weights[equipment, other.Equipment]) / rowSum;
     242          double colInvProportion = colSum == 0 ? 1.0 : (colSum - Content.ProblemInstance.Weights[other.Equipment, equipment]) / colSum;
    244243          int colorComponent = (int)(255 * Math.Pow(Math.Min(rowInvProportion, colInvProportion), 2));
    245244          other.BackColor = Color.FromArgb(colorComponent, 255, colorComponent);
     
    258257        rowSums[e] = 0;
    259258        colSums[e] = 0;
    260         for (int i = 0; i < Content.Weights.Columns; i++) {
    261           if (!equipments.Contains(i)) rowSums[e] += Content.Weights[e, i];
    262           if (!equipments.Contains(i)) colSums[e] += Content.Weights[i, e];
     259        for (int i = 0; i < Content.ProblemInstance.Weights.Columns; i++) {
     260          if (!equipments.Contains(i)) rowSums[e] += Content.ProblemInstance.Weights[e, i];
     261          if (!equipments.Contains(i)) colSums[e] += Content.ProblemInstance.Weights[i, e];
    263262        }
    264263      }
     
    272271          other.ForeColor = assignmentTreeView.ForeColor;
    273272        } else {
    274           double rowInvProportion = relevantEquipments.Min(x => rowSums[x] == 0 ? 1.0 : (rowSums[x] - Content.Weights[x, other.Equipment]) / rowSums[x]);
    275           double colInvProportion = relevantEquipments.Min(x => colSums[x] == 0 ? 1.0 : (colSums[x] - Content.Weights[other.Equipment, x]) / colSums[x]);
     273          double rowInvProportion = relevantEquipments.Min(x => rowSums[x] == 0 ? 1.0 : (rowSums[x] - Content.ProblemInstance.Weights[x, other.Equipment]) / rowSums[x]);
     274          double colInvProportion = relevantEquipments.Min(x => colSums[x] == 0 ? 1.0 : (colSums[x] - Content.ProblemInstance.Weights[other.Equipment, x]) / colSums[x]);
    276275          int colorComponent = (int)(255 * Math.Pow(Math.Min(rowInvProportion, colInvProportion), 2));
    277276          other.BackColor = Color.FromArgb(colorComponent, 255, colorComponent);
     
    314313
    315314    private void recalculateButton_Click(object sender, EventArgs e) {
    316       double fdq, iq, oc;
    317       Content.Evaluator.Evaluate(Content.Assignment, Content.Weights,
    318         Content.Distances, Content.InstallationCosts, Content.Demands,
    319         Content.Capacities, out fdq, out iq, out oc);
    320       Content.FlowDistanceQuality = new DoubleValue(fdq);
    321       Content.InstallationQuality = new DoubleValue(iq);
    322       Content.OverbookedCapacity = new DoubleValue(oc);
    323       Content.Quality = new DoubleValue(
    324         Content.Evaluator.GetFitness(fdq, iq, oc,
    325         Content.TransportationCosts.Value, Content.ExpectedRandomQuality.Value));
     315      Content.Evaluation = Content.ProblemInstance.Evaluate(Content.Assignment);
    326316    }
    327317  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/Properties/AssemblyInfo.cs.frame

    r7345 r15504  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 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.
     
    3131[assembly: AssemblyCompany("HEAL")]
    3232[assembly: AssemblyProduct("HeuristicLab")]
    33 [assembly: AssemblyCopyright("(c) 2002-2011 HEAL")]
     33[assembly: AssemblyCopyright("(c) 2002-2017 HEAL")]
    3434[assembly: AssemblyTrademark("")]
    3535[assembly: AssemblyCulture("")]
     
    5454// [assembly: AssemblyVersion("1.0.*")]
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     56[assembly: AssemblyFileVersion("3.3.14.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.