Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs @ 7471

Last change on this file since 7471 was 7471, checked in by abeham, 12 years ago

#1614

  • Added a button to recalculate the quality
File size: 25.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Drawing;
24using System.Linq;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Encodings.IntegerVectorEncoding;
29using HeuristicLab.Optimization;
30using HeuristicLab.Parameters;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32using HeuristicLab.PluginInfrastructure;
33using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;
34using HeuristicLab.Problems.Instances;
35
36namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
37  [Item("Generalized Quadratic Assignment Problem", "The Generalized Quadratic Assignment Problem (GQAP) is a generalization of the QAP in that it allows to assign multiple facilities (here called equipment) to a single location. The problem is described in Lee, C.G., and Ma, Z. 2003. The Generalized Quadratic Assignment Problem. Technical Report M5S 3G8, University of Toronto, Canada.")]
38  [Creatable("Problems")]
39  [StorableClass]
40  public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem<IGQAPEvaluator, IGQAPSolutionCreator>, IStorableContent, IProblemInstanceConsumer<IQAPInstance>, IProblemInstanceConsumer<ICTAPInstance>, IProblemInstanceConsumer<ITSPInstance>, IProblemInstanceConsumer<IATSPInstance> {
41
42    public override Image ItemImage {
43      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
44    }
45
46    public string Filename { get; set; }
47
48    #region Parameter Descriptions
49    public static readonly string MaximizationDescription = "False if the fitness function should be minimized (default) or otherwise True if it should be maximized.";
50    public static readonly string WeightsDescription = "The weights matrix describes the flows between the equipments.";
51    public static readonly string DistancesDescription = "The distances matrix describes the distances between the locations at which the equipment can be installed.";
52    public static readonly string InstallationCostsDescription = "The installation costs matrix describes the installation costs of installing equipment i at location j";
53    public static readonly string DemandsDescription = "The demands vector describes the space requirements of the equipments.";
54    public static readonly string CapacitiesDescription = "The capacities vector describes the available space at the locations.";
55    public static readonly string TransportationCostsDescription = "The transportation cost represents the flow-unit per distance-unit cost factor. This value can also be set to 1 if these costs are factored into the weights matrix already.";
56    public static readonly string OverbookedCapacityPenaltyDescription = "The multiplier for the constraint violation when added to the quality.";
57    public static readonly string BestKnownQualityDescription = "The best known quality (if available).";
58    public static readonly string BestKnownSolutionDescription = "The best known solution (if available).";
59    public static readonly string BestKnownSolutionsDescription = "Contains an archive of best-known solutions regarding flow-distance quality and installation quality.";
60    public static readonly string EquipmentNamesDescription = "Optional: A list of names that describes the equipments.";
61    public static readonly string LocationNamesDescription = "Optional: A list of names that describes the locations.";
62    #endregion
63
64    #region Parameter Properties
65    public ValueParameter<DoubleMatrix> WeightsParameter {
66      get { return (ValueParameter<DoubleMatrix>)Parameters["Weights"]; }
67    }
68    public ValueParameter<DoubleMatrix> DistancesParameter {
69      get { return (ValueParameter<DoubleMatrix>)Parameters["Distances"]; }
70    }
71    public ValueParameter<DoubleMatrix> InstallationCostsParameter {
72      get { return (ValueParameter<DoubleMatrix>)Parameters["InstallationCosts"]; }
73    }
74    public ValueParameter<DoubleArray> DemandsParameter {
75      get { return (ValueParameter<DoubleArray>)Parameters["Demands"]; }
76    }
77    public ValueParameter<DoubleArray> CapacitiesParameter {
78      get { return (ValueParameter<DoubleArray>)Parameters["Capacities"]; }
79    }
80    public FixedValueParameter<DoubleValue> TransportationCostsParameter {
81      get { return (FixedValueParameter<DoubleValue>)Parameters["TransportationCosts"]; }
82    }
83    public FixedValueParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
84      get { return (FixedValueParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
85    }
86    public OptionalValueParameter<GQAPAssignment> BestKnownSolutionParameter {
87      get { return (OptionalValueParameter<GQAPAssignment>)Parameters["BestKnownSolution"]; }
88    }
89    public OptionalValueParameter<GQAPAssignmentArchive> BestKnownSolutionsParameter {
90      get { return (OptionalValueParameter<GQAPAssignmentArchive>)Parameters["BestKnownSolutions"]; }
91    }
92    public OptionalValueParameter<StringArray> EquipmentNamesParameter {
93      get { return (OptionalValueParameter<StringArray>)Parameters["EquipmentNames"]; }
94    }
95    public OptionalValueParameter<StringArray> LocationNamesParameter {
96      get { return (OptionalValueParameter<StringArray>)Parameters["LocationNames"]; }
97    }
98    #endregion
99
100    #region Properties
101    public DoubleMatrix Weights {
102      get { return WeightsParameter.Value; }
103      set { WeightsParameter.Value = value; }
104    }
105    public DoubleMatrix Distances {
106      get { return DistancesParameter.Value; }
107      set { DistancesParameter.Value = value; }
108    }
109    public DoubleMatrix InstallationCosts {
110      get { return InstallationCostsParameter.Value; }
111      set { InstallationCostsParameter.Value = value; }
112    }
113    public DoubleArray Demands {
114      get { return DemandsParameter.Value; }
115      set { DemandsParameter.Value = value; }
116    }
117    public DoubleArray Capacities {
118      get { return CapacitiesParameter.Value; }
119      set { CapacitiesParameter.Value = value; }
120    }
121    public DoubleValue TransportationCosts {
122      get { return TransportationCostsParameter.Value; }
123      set { TransportationCostsParameter.Value = value; }
124    }
125    public DoubleValue OverbookedCapacityPenalty {
126      get { return TransportationCostsParameter.Value; }
127      set { TransportationCostsParameter.Value = value; }
128    }
129    public StringArray EquipmentNames {
130      get { return EquipmentNamesParameter.Value; }
131      set { EquipmentNamesParameter.Value = value; }
132    }
133    public StringArray LocationNames {
134      get { return LocationNamesParameter.Value; }
135      set { LocationNamesParameter.Value = value; }
136    }
137    public GQAPAssignment BestKnownSolution {
138      get { return BestKnownSolutionParameter.Value; }
139      set { BestKnownSolutionParameter.Value = value; }
140    }
141    public GQAPAssignmentArchive BestKnownSolutions {
142      get { return BestKnownSolutionsParameter.Value; }
143      set { BestKnownSolutionsParameter.Value = value; }
144    }
145    #endregion
146
147    public BestGQAPSolutionAnalyzer BestSolutionAnalyzer {
148      get { return Operators.OfType<BestGQAPSolutionAnalyzer>().FirstOrDefault(); }
149    }
150    public GQAPSolutionArchiveAnalyzer SolutionArchiveAnalyzer {
151      get { return Operators.OfType<GQAPSolutionArchiveAnalyzer>().FirstOrDefault(); }
152    }
153
154    [StorableConstructor]
155    private GeneralizedQuadraticAssignmentProblem(bool deserializing) : base(deserializing) { }
156    private GeneralizedQuadraticAssignmentProblem(GeneralizedQuadraticAssignmentProblem original, Cloner cloner)
157      : base(original, cloner) {
158      RegisterEventHandlers();
159    }
160    public GeneralizedQuadraticAssignmentProblem()
161      : base(new GQAPEvaluator(), new RandomSolutionCreator()) {
162      Parameters.Add(new ValueParameter<DoubleMatrix>("Weights", WeightsDescription, new DoubleMatrix(), false));
163      Parameters.Add(new ValueParameter<DoubleMatrix>("Distances", DistancesDescription, new DoubleMatrix(), false));
164      Parameters.Add(new ValueParameter<DoubleMatrix>("InstallationCosts", InstallationCostsDescription, new DoubleMatrix(), false));
165      Parameters.Add(new FixedValueParameter<DoubleValue>("TransportationCosts", TransportationCostsDescription, new DoubleValue(1)));
166      Parameters.Add(new FixedValueParameter<DoubleValue>("OverbookedCapacityPenalty", OverbookedCapacityPenaltyDescription, new DoubleValue(1000)));
167      Parameters.Add(new ValueParameter<DoubleArray>("Demands", DemandsDescription, new DoubleArray(), false));
168      Parameters.Add(new ValueParameter<DoubleArray>("Capacities", CapacitiesDescription, new DoubleArray(), false));
169      Parameters.Add(new OptionalValueParameter<GQAPSolution>("BestKnownSolution", BestKnownSolutionDescription, null, false));
170      Parameters.Add(new OptionalValueParameter<GQAPAssignmentArchive>("BestKnownSolutions", BestKnownSolutionsDescription, null, false));
171      Parameters.Add(new OptionalValueParameter<StringArray>("EquipmentNames", EquipmentNamesDescription, null, false));
172      Parameters.Add(new OptionalValueParameter<StringArray>("LocationNames", LocationNamesDescription, null, false));
173
174      WeightsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
175      DistancesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
176      InstallationCostsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
177      DemandsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
178      CapacitiesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
179
180      Weights = new DoubleMatrix(5, 5);
181      Weights[0, 0] = Weights[1, 1] = Weights[2, 2] = Weights[3, 3] = Weights[4, 4] = 0;
182      Weights[0, 1] = Weights[1, 0] = Weights[0, 2] = Weights[2, 0] = Weights[0, 3] = Weights[3, 0] = Weights[0, 4] = Weights[4, 0] = 10;
183      Weights[1, 2] = Weights[2, 1] = Weights[1, 3] = Weights[3, 1] = Weights[1, 4] = Weights[4, 1] = 5;
184      Weights[2, 3] = Weights[3, 2] = Weights[2, 4] = Weights[4, 2] = 7.5;
185      Weights[3, 4] = Weights[4, 3] = 2.5;
186
187      Distances = new DoubleMatrix(3, 3);
188      Distances[0, 0] = Distances[1, 1] = Distances[2, 2] = 0;
189      Distances[0, 1] = Distances[1, 0] = Distances[1, 2] = Distances[2, 1] = 1;
190      Distances[0, 2] = Distances[2, 0] = 2;
191
192      InstallationCosts = new DoubleMatrix(5, 3);
193
194      Demands = new DoubleArray(5);
195      Demands[0] = 2; Demands[1] = 1; Demands[2] = 3; Demands[3] = 1; Demands[4] = 1;
196
197      Capacities = new DoubleArray(3);
198      Capacities[0] = 4; Capacities[1] = 1; Capacities[2] = 4;
199
200      SolutionCreator.AssignmentParameter.ActualName = "Assignment";
201
202      InitializeOperators();
203      RegisterEventHandlers();
204    }
205
206    public override IDeepCloneable Clone(Cloner cloner) {
207      return new GeneralizedQuadraticAssignmentProblem(this, cloner);
208    }
209
210    public bool LoadFrom(IQAPInstance instance) {
211      try {
212        Name = instance.Name;
213        Description = instance.Description;
214
215        Weights = new DoubleMatrix(instance.Weights);
216        Distances = new DoubleMatrix(instance.Distances);
217        InstallationCosts = new DoubleMatrix(Weights.Rows, Distances.Columns); // all zero
218        Capacities = new DoubleArray(Enumerable.Range(0, Distances.Rows).Select(x => 1.0).ToArray());
219        Demands = new DoubleArray(Enumerable.Range(0, Weights.Rows).Select(x => 1.0).ToArray());
220
221        TransportationCosts.Value = 1;
222
223        if (instance.BestKnownAssignment != null) {
224          EvaluateAndLoadAssignment(instance.BestKnownAssignment);
225        } else {
226          BestKnownQuality = null;
227          BestKnownSolution = null;
228          BestKnownSolutions = null;
229        }
230      } catch {
231        return false;
232      }
233      return true;
234    }
235
236    public bool LoadFrom(ICTAPInstance instance) {
237      try {
238        Name = instance.Name;
239        Description = instance.Description;
240
241        Capacities = new DoubleArray(instance.MemoryCapacities);
242        Demands = new DoubleArray(instance.MemoryRequirements);
243        Weights = new DoubleMatrix(instance.CommunicationCosts);
244        InstallationCosts = new DoubleMatrix(instance.ExecutionCosts.Transpose());
245        Distances = new DoubleMatrix(Capacities.Length, Capacities.Length); // all one, except diagonal
246        for (int i = 0; i < Capacities.Length - 1; i++)
247          for (int j = i + 1; j < Capacities.Length; j++) {
248            Distances[i, j] = 1;
249            Distances[j, i] = 1;
250          }
251
252        TransportationCosts.Value = 1;
253
254        if (instance.BestKnownAssignment != null) {
255          EvaluateAndLoadAssignment(instance.BestKnownAssignment);
256        } else {
257          BestKnownQuality = null;
258          BestKnownSolution = null;
259          BestKnownSolutions = null;
260        }
261      } catch {
262        return false;
263      }
264      return true;
265    }
266
267    public bool LoadFrom(ITSPInstance instance) {
268      try {
269        if (instance.Dimension > 1000) return false;
270
271        Name = instance.Name;
272        Description = instance.Description;
273
274        Capacities = new DoubleArray(instance.Dimension);
275        Demands = new DoubleArray(instance.Dimension);
276        for (int i = 0; i < instance.Dimension; i++) {
277          Capacities[i] = 1;
278          Demands[i] = 1;
279        }
280        InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
281        Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
282        for (int i = 0; i < instance.Dimension; i++)
283          Weights[i, (i + 1) % instance.Dimension] = 1;
284        Distances = new DoubleMatrix(instance.GetDistanceMatrix());
285
286        TransportationCosts.Value = 1;
287
288        if (instance.BestKnownTour != null) {
289          EvaluateAndLoadAssignment(instance.BestKnownTour);
290        } else {
291          BestKnownQuality = null;
292          BestKnownSolution = null;
293          BestKnownSolutions = null;
294        }
295      } catch {
296        return false;
297      }
298      return true;
299    }
300
301    public bool LoadFrom(IATSPInstance instance) {
302      try {
303        Name = instance.Name;
304        Description = instance.Description;
305
306        Capacities = new DoubleArray(instance.Dimension);
307        Demands = new DoubleArray(instance.Dimension);
308        for (int i = 0; i < instance.Dimension; i++) {
309          Capacities[i] = 1;
310          Demands[i] = 1;
311        }
312        InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
313        Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
314        for (int i = 0; i < instance.Dimension; i++)
315          Weights[i, (i + 1) % instance.Dimension] = 1;
316        Distances = new DoubleMatrix(instance.Distances);
317
318        TransportationCosts.Value = 1;
319
320        if (instance.BestKnownTour != null) {
321          EvaluateAndLoadAssignment(instance.BestKnownTour);
322        } else {
323          BestKnownQuality = null;
324          BestKnownSolution = null;
325          BestKnownSolutions = null;
326        }
327      } catch {
328        return false;
329      }
330      return true;
331    }
332
333    private void EvaluateAndLoadAssignment(int[] vector) {
334      EvaluateAndLoadAssignment(new IntegerVector(vector));
335    }
336    private void EvaluateAndLoadAssignment(IntegerVector assignment) {
337      if (!IsConfigurationValid()) return;
338      double flowDistanceQuality, installationQuality, overbookedCapacity;
339      GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
340        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
341      double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
342      BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
343        new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
344        new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
345        Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
346      BestKnownQuality = new DoubleValue(quality);
347      BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
348      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
349    }
350
351    #region Events
352    protected override void OnOperatorsChanged() {
353      base.OnOperatorsChanged();
354      Parameterize();
355    }
356    protected override void OnEvaluatorChanged() {
357      base.OnEvaluatorChanged();
358      Parameterize();
359      Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
360    }
361    protected override void OnSolutionCreatorChanged() {
362      base.OnSolutionCreatorChanged();
363      Parameterize();
364      SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
365    }
366
367    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
368      Parameterize();
369    }
370    private void SolutionCreator_IntegerVectorParameter_ActualNameChanged(object sender, EventArgs e) {
371      Parameterize();
372    }
373    #endregion
374
375    #region Helpers
376    [StorableHook(HookType.AfterDeserialization)]
377    private void AfterDeserialization() {
378      RegisterEventHandlers();
379    }
380
381    private void RegisterEventHandlers() {
382      Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
383      SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
384    }
385
386    private void InitializeOperators() {
387      Operators.Clear();
388      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPOperator>());
389      Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>());
390      Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
391      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPMoveEvaluator>());
392      Parameterize();
393    }
394
395    private void Parameterize() {
396
397      var operators = Operators.Union(new IOperator[] { SolutionCreator, Evaluator }).ToArray();
398
399      foreach (var op in operators.OfType<IAssignmentAwareGQAPOperator>()) {
400        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
401      }
402      foreach (var op in operators.OfType<IAssignmentsAwareGQAPOperator>()) {
403        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
404      }
405      foreach (var op in operators.OfType<IBestKnownQualityAwareGQAPOperator>()) {
406        op.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
407      }
408      foreach (var op in operators.OfType<IBestKnownSolutionAwareGQAPOperator>()) {
409        op.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
410      }
411      foreach (var op in operators.OfType<IBestKnownSolutionsAwareGQAPOperator>()) {
412        op.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
413      }
414      foreach (var op in operators.OfType<ICapacitiesAwareGQAPOperator>()) {
415        op.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
416      }
417      foreach (var op in operators.OfType<IDemandsAwareGQAPOperator>()) {
418        op.DemandsParameter.ActualName = DemandsParameter.Name;
419      }
420      foreach (var op in operators.OfType<IDistancesAwareGQAPOperator>()) {
421        op.DistancesParameter.ActualName = DistancesParameter.Name;
422      }
423      foreach (var op in operators.OfType<IEquipmentNamesAwareGQAPOperator>()) {
424        op.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name;
425      }
426      foreach (var op in operators.OfType<IGQAPCrossover>()) {
427        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
428        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
429      }
430      foreach (var op in operators.OfType<IInstallationCostsAwareGQAPOperator>()) {
431        op.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
432      }
433      foreach (var op in operators.OfType<ILocationNamesAwareGQAPOperator>()) {
434        op.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
435      }
436      var moveEvaluator = operators.OfType<IGQAPMoveEvaluator>().FirstOrDefault();
437      foreach (var op in operators.OfType<IGQAPMoveEvaluator>()) { // synchronize all move evaluators
438        if (moveEvaluator != null) {
439          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
440          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
441          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
442          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
443        }
444      }
445      foreach (var op in operators.OfType<IMoveQualityAwareGQAPOperator>()) {
446        if (moveEvaluator != null) {
447          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
448          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
449          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
450          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
451        }
452        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
453      }
454      foreach (var op in operators.OfType<IOverbookedCapacityPenaltyAwareGQAPOperator>()) {
455        op.OverbookedCapacityPenaltyParameter.ActualName = OverbookedCapacityPenaltyParameter.Name;
456      }
457      foreach (var op in operators.OfType<IQualitiesAwareGQAPOperator>()) {
458        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
459        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
460        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
461        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
462        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
463      }
464      foreach (var op in operators.OfType<IQualityAwareGQAPOperator>()) {
465        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
466        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
467        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
468        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
469        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
470      }
471      foreach (var op in operators.OfType<ITransportationCostsAwareGQAPOperator>()) {
472        op.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
473      }
474      foreach (var op in operators.OfType<IWeightsAwareGQAPOperator>()) {
475        op.WeightsParameter.ActualName = WeightsParameter.Name;
476      }
477
478      foreach (var op in operators.OfType<IIntegerVectorCrossover>()) {
479        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
480        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
481      }
482      foreach (var op in operators.OfType<IIntegerVectorManipulator>()) {
483        op.IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
484      }
485    }
486    #endregion
487
488    private bool IsConfigurationValid() {
489      return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
490        && Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
491        && Distances.Rows == Distances.Columns && Distances.Rows == InstallationCosts.Columns
492        && Demands.Length == Weights.Rows && Capacities.Length == Distances.Rows;
493    }
494  }
495}
Note: See TracBrowser for help on using the repository browser.