Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1614

  • Fixed a parameter type in the GQAP
  • Fixed loading of ICTAP instances (only the upper triangular matrix is required for the distances)
  • Fixed a bug in the reducer that causes the loss of diversity
File size: 25.0 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<GQAPAssignment>("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);
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          }
250
251        TransportationCosts.Value = 1;
252
253        if (instance.BestKnownAssignment != null) {
254          EvaluateAndLoadAssignment(instance.BestKnownAssignment);
255        } else {
256          BestKnownQuality = null;
257          BestKnownSolution = null;
258          BestKnownSolutions = null;
259        }
260      } catch {
261        return false;
262      }
263      return true;
264    }
265
266    public bool LoadFrom(ITSPInstance instance) {
267      try {
268        if (instance.Dimension > 1000) return false;
269
270        Name = instance.Name;
271        Description = instance.Description;
272
273        Capacities = new DoubleArray(instance.Dimension);
274        Demands = new DoubleArray(instance.Dimension);
275        for (int i = 0; i < instance.Dimension; i++) {
276          Capacities[i] = 1;
277          Demands[i] = 1;
278        }
279        InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
280        Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
281        for (int i = 0; i < instance.Dimension; i++)
282          Weights[i, (i + 1) % instance.Dimension] = 1;
283        Distances = new DoubleMatrix(instance.GetDistanceMatrix());
284
285        TransportationCosts.Value = 1;
286
287        if (instance.BestKnownTour != null) {
288          EvaluateAndLoadAssignment(instance.BestKnownTour);
289        } else {
290          BestKnownQuality = null;
291          BestKnownSolution = null;
292          BestKnownSolutions = null;
293        }
294      } catch {
295        return false;
296      }
297      return true;
298    }
299
300    public bool LoadFrom(IATSPInstance instance) {
301      try {
302        Name = instance.Name;
303        Description = instance.Description;
304
305        Capacities = new DoubleArray(instance.Dimension);
306        Demands = new DoubleArray(instance.Dimension);
307        for (int i = 0; i < instance.Dimension; i++) {
308          Capacities[i] = 1;
309          Demands[i] = 1;
310        }
311        InstallationCosts = new DoubleMatrix(instance.Dimension, instance.Dimension);
312        Weights = new DoubleMatrix(instance.Dimension, instance.Dimension);
313        for (int i = 0; i < instance.Dimension; i++)
314          Weights[i, (i + 1) % instance.Dimension] = 1;
315        Distances = new DoubleMatrix(instance.Distances);
316
317        TransportationCosts.Value = 1;
318
319        if (instance.BestKnownTour != null) {
320          EvaluateAndLoadAssignment(instance.BestKnownTour);
321        } else {
322          BestKnownQuality = null;
323          BestKnownSolution = null;
324          BestKnownSolutions = null;
325        }
326      } catch {
327        return false;
328      }
329      return true;
330    }
331
332    private void EvaluateAndLoadAssignment(int[] vector) {
333      EvaluateAndLoadAssignment(new IntegerVector(vector));
334    }
335    private void EvaluateAndLoadAssignment(IntegerVector assignment) {
336      if (!IsConfigurationValid()) return;
337      double flowDistanceQuality, installationQuality, overbookedCapacity;
338      GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
339        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
340      double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
341      BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
342        new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
343        new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
344        Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
345      BestKnownQuality = new DoubleValue(quality);
346      BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
347      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
348    }
349
350    #region Events
351    protected override void OnOperatorsChanged() {
352      base.OnOperatorsChanged();
353      Parameterize();
354    }
355    protected override void OnEvaluatorChanged() {
356      base.OnEvaluatorChanged();
357      Parameterize();
358      Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
359    }
360    protected override void OnSolutionCreatorChanged() {
361      base.OnSolutionCreatorChanged();
362      Parameterize();
363      SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
364    }
365
366    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
367      Parameterize();
368    }
369    private void SolutionCreator_IntegerVectorParameter_ActualNameChanged(object sender, EventArgs e) {
370      Parameterize();
371    }
372    #endregion
373
374    #region Helpers
375    [StorableHook(HookType.AfterDeserialization)]
376    private void AfterDeserialization() {
377      RegisterEventHandlers();
378    }
379
380    private void RegisterEventHandlers() {
381      Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
382      SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
383    }
384
385    private void InitializeOperators() {
386      Operators.Clear();
387      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPOperator>());
388      Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>());
389      Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
390      Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPMoveEvaluator>());
391      Parameterize();
392    }
393
394    private void Parameterize() {
395
396      var operators = Operators.Union(new IOperator[] { SolutionCreator, Evaluator }).ToArray();
397
398      foreach (var op in operators.OfType<IAssignmentAwareGQAPOperator>()) {
399        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
400      }
401      foreach (var op in operators.OfType<IAssignmentsAwareGQAPOperator>()) {
402        op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
403      }
404      foreach (var op in operators.OfType<IBestKnownQualityAwareGQAPOperator>()) {
405        op.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
406      }
407      foreach (var op in operators.OfType<IBestKnownSolutionAwareGQAPOperator>()) {
408        op.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
409      }
410      foreach (var op in operators.OfType<IBestKnownSolutionsAwareGQAPOperator>()) {
411        op.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
412      }
413      foreach (var op in operators.OfType<ICapacitiesAwareGQAPOperator>()) {
414        op.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
415      }
416      foreach (var op in operators.OfType<IDemandsAwareGQAPOperator>()) {
417        op.DemandsParameter.ActualName = DemandsParameter.Name;
418      }
419      foreach (var op in operators.OfType<IDistancesAwareGQAPOperator>()) {
420        op.DistancesParameter.ActualName = DistancesParameter.Name;
421      }
422      foreach (var op in operators.OfType<IEquipmentNamesAwareGQAPOperator>()) {
423        op.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name;
424      }
425      foreach (var op in operators.OfType<IGQAPCrossover>()) {
426        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
427        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
428      }
429      foreach (var op in operators.OfType<IInstallationCostsAwareGQAPOperator>()) {
430        op.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
431      }
432      foreach (var op in operators.OfType<ILocationNamesAwareGQAPOperator>()) {
433        op.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
434      }
435      var moveEvaluator = operators.OfType<IGQAPMoveEvaluator>().FirstOrDefault();
436      foreach (var op in operators.OfType<IGQAPMoveEvaluator>()) { // synchronize all move evaluators
437        if (moveEvaluator != null) {
438          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
439          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
440          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
441          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
442        }
443      }
444      foreach (var op in operators.OfType<IMoveQualityAwareGQAPOperator>()) {
445        if (moveEvaluator != null) {
446          op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
447          op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
448          op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
449          op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
450        }
451        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
452      }
453      foreach (var op in operators.OfType<IOverbookedCapacityPenaltyAwareGQAPOperator>()) {
454        op.OverbookedCapacityPenaltyParameter.ActualName = OverbookedCapacityPenaltyParameter.Name;
455      }
456      foreach (var op in operators.OfType<IQualitiesAwareGQAPOperator>()) {
457        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
458        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
459        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
460        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
461        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
462      }
463      foreach (var op in operators.OfType<IQualityAwareGQAPOperator>()) {
464        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
465        op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
466        op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
467        op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
468        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
469      }
470      foreach (var op in operators.OfType<ITransportationCostsAwareGQAPOperator>()) {
471        op.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
472      }
473      foreach (var op in operators.OfType<IWeightsAwareGQAPOperator>()) {
474        op.WeightsParameter.ActualName = WeightsParameter.Name;
475      }
476
477      foreach (var op in operators.OfType<IIntegerVectorCrossover>()) {
478        op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
479        op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
480      }
481      foreach (var op in operators.OfType<IIntegerVectorManipulator>()) {
482        op.IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
483      }
484    }
485    #endregion
486
487    private bool IsConfigurationValid() {
488      return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
489        && Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
490        && Distances.Rows == Distances.Columns && Distances.Rows == InstallationCosts.Columns
491        && Demands.Length == Weights.Rows && Capacities.Length == Distances.Rows;
492    }
493  }
494}
Note: See TracBrowser for help on using the repository browser.