Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6657


Ignore:
Timestamp:
08/12/11 17:31:18 (13 years ago)
Author:
abeham
Message:

#1614

  • updated problem
  • added equality comparer for integer vectors
Location:
branches/GeneralizedQAP
Files:
4 added
2 edited

Legend:

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

    r6651 r6657  
    2121
    2222using System.Drawing;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2829using HeuristicLab.Parameters;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     31using HeuristicLab.PluginInfrastructure;
    3032
    3133namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
     
    9193    #endregion
    9294
     95    [Storable]
     96    private BestGQAPSolutionAnalyzer bestSolutionAnalyzer;
     97    public BestGQAPSolutionAnalyzer BestSolutionAnalyzer {
     98      get { return bestSolutionAnalyzer; }
     99      set { bestSolutionAnalyzer = value; }
     100    }
     101
    93102    [StorableConstructor]
    94103    private GeneralizedQuadraticAssignmentProblem(bool deserializing) : base(deserializing) { }
    95104    private GeneralizedQuadraticAssignmentProblem(GeneralizedQuadraticAssignmentProblem original, Cloner cloner)
    96105      : base(original, cloner) {
     106      bestSolutionAnalyzer = cloner.Clone(original.bestSolutionAnalyzer);
    97107      AttachEventHandlers();
    98108    }
     
    107117      Parameters.Add(new OptionalValueParameter<IItem>("BestKnownSolution", "The best known solution (if available)", null));
    108118
    109       Wei
     119      Weights = new DoubleMatrix(5, 5);
     120      Weights[0, 0] = Weights[1, 1] = Weights[2, 2] = Weights[3, 3] = Weights[4, 4] = 0;
     121      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;
     122      Weights[1, 2] = Weights[2, 1] = Weights[1, 3] = Weights[3, 1] = Weights[1, 4] = Weights[4, 1] = 5;
     123      Weights[2, 3] = Weights[3, 2] = Weights[2, 4] = Weights[4, 2] = 7.5;
     124      Weights[3, 4] = Weights[4, 3] = 2.5;
     125
     126      Distances = new DoubleMatrix(3, 3);
     127      Distances[0, 0] = Distances[1, 1] = Distances[2, 2] = 0;
     128      Distances[0, 1] = Distances[1, 0] = Distances[1, 2] = Distances[2, 1] = 1;
     129      Distances[0, 2] = Distances[2, 0] = 2;
     130
     131      InstallationCosts = new DoubleMatrix(3, 3);
     132
     133      TransportationCosts = new DoubleValue(1);
     134
     135      Demands = new DoubleArray(5);
     136      Demands[0] = 2; Demands[1] = 1; Demands[2] = 3; Demands[3] = 1; Demands[4] = 1;
     137
     138      Capacities = new DoubleArray(3);
     139      Capacities[0] = 4; Capacities[1] = 1; Capacities[2] = 4;
    110140
    111141      ParameterizeSolutionCreator();
     
    135165
    136166    private void InitializeOperators() {
    137       // TODO: Add custom problem analyzer to the list
    138       // TODO: Add operators from the representation either by direct instantiation, or by using ApplicationManager.Manger.GetInstances<T>().Cast<IOperator>()
     167      Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>());
     168      Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
     169      Operators.Add(new BestGQAPSolutionAnalyzer());
     170      ParameterizeAnalyzers();
     171      ParameterizeOperators();
     172    }
     173    private void ParameterizeAnalyzers() {
     174      if (BestSolutionAnalyzer != null) {
     175        BestSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     176        BestSolutionAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name;
     177        BestSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name;
     178        BestSolutionAnalyzer.AssignmentParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     179        BestSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     180        BestSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     181        BestSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     182      }
     183    }
     184    private void ParameterizeOperators() {
     185      foreach (IIntegerVectorCrossover op in Operators.OfType<IIntegerVectorCrossover>()) {
     186        op.ParentsParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     187        op.ChildParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     188      }
     189      foreach (IIntegerVectorManipulator op in Operators.OfType<IIntegerVectorManipulator>()) {
     190        op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName;
     191      }
    139192    }
    140193    private void ParameterizeSolutionCreator() {
    141       // TODO: Set the parameters of the solution creator
     194      SolutionCreator.LengthParameter.Value = new IntValue(Demands.Length);
     195      SolutionCreator.MinimumParameter.Value = new IntValue(0);
     196      SolutionCreator.MaximumParameter.Value = new IntValue(Capacities.Length);
     197      SolutionCreator.IntegerVectorParameter.ActualName = "Assignment";
    142198    }
    143199    private void ParameterizeEvaluator() {
    144       // TODO: Set the parameters of the evaluator
     200      Evaluator.WeightsParameter.ActualName = WeightsParameter.Name;
     201      Evaluator.DistancesParameter.ActualName = DistancesParameter.Name;
     202      Evaluator.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
     203      Evaluator.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
     204      Evaluator.DemandsParameter.ActualName = DemandsParameter.Name;
     205      Evaluator.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
     206      Evaluator.AssignmentParameter.ActualName = "Assignment";
    145207    }
    146208    #endregion
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IGQAPEvaluator.cs

    r6650 r6657  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Data;
     24using HeuristicLab.Encodings.IntegerVectorEncoding;
    2425using HeuristicLab.Optimization;
    2526
     
    3233    ILookupParameter<DoubleArray> DemandsParameter { get; }
    3334    ILookupParameter<DoubleArray> CapacitiesParameter { get; }
     35    ILookupParameter<IntegerVector> AssignmentParameter { get; }
    3436  }
    3537}
Note: See TracChangeset for help on using the changeset viewer.