Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/12 10:01:37 (13 years ago)
Author:
abeham
Message:

#1614

  • worked on generic instance provider
  • added CTAP instances
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
Files:
3 edited

Legend:

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

    r7438 r7443  
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3232using HeuristicLab.PluginInfrastructure;
     33using HeuristicLab.Problems.Instances;
    3334
    3435namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
     
    8283      get { return (FixedValueParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
    8384    }
    84     public OptionalValueParameter<IItem> BestKnownSolutionParameter {
    85       get { return (OptionalValueParameter<IItem>)Parameters["BestKnownSolution"]; }
     85    public OptionalValueParameter<GQAPSolution> BestKnownSolutionParameter {
     86      get { return (OptionalValueParameter<GQAPSolution>)Parameters["BestKnownSolution"]; }
    8687    }
    8788    public OptionalValueParameter<GQAPAssignmentArchive> BestKnownSolutionsParameter {
     
    117118      set { CapacitiesParameter.Value = value; }
    118119    }
    119     public double TransportationCosts {
    120       get { return TransportationCostsParameter.Value.Value; }
    121       set { TransportationCostsParameter.Value.Value = value; }
    122     }
    123     public double OverbookedCapacityPenalty {
    124       get { return TransportationCostsParameter.Value.Value; }
    125       set { TransportationCostsParameter.Value.Value = value; }
     120    public DoubleValue TransportationCosts {
     121      get { return TransportationCostsParameter.Value; }
     122      set { TransportationCostsParameter.Value = value; }
     123    }
     124    public DoubleValue OverbookedCapacityPenalty {
     125      get { return TransportationCostsParameter.Value; }
     126      set { TransportationCostsParameter.Value = value; }
    126127    }
    127128    public StringArray EquipmentNames {
     
    132133      get { return LocationNamesParameter.Value; }
    133134      set { LocationNamesParameter.Value = value; }
     135    }
     136    public GQAPSolution BestKnownSolution {
     137      get { return BestKnownSolutionParameter.Value; }
     138      set { BestKnownSolutionParameter.Value = value; }
    134139    }
    135140    #endregion
     
    157162      Parameters.Add(new ValueParameter<DoubleArray>("Demands", DemandsDescription, new DoubleArray(), false));
    158163      Parameters.Add(new ValueParameter<DoubleArray>("Capacities", CapacitiesDescription, new DoubleArray(), false));
    159       Parameters.Add(new OptionalValueParameter<IItem>("BestKnownSolution", BestKnownSolutionDescription, null, false));
     164      Parameters.Add(new OptionalValueParameter<GQAPSolution>("BestKnownSolution", BestKnownSolutionDescription, null, false));
    160165      Parameters.Add(new OptionalValueParameter<GQAPAssignmentArchive>("BestKnownSolutions", BestKnownSolutionsDescription, null, false));
    161166      Parameters.Add(new OptionalValueParameter<StringArray>("EquipmentNames", EquipmentNamesDescription, null, false));
    162167      Parameters.Add(new OptionalValueParameter<StringArray>("LocationNames", LocationNamesDescription, null, false));
    163 
    164       BestKnownQualityParameter.Value = null;
    165168
    166169      WeightsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
     
    182185      InstallationCosts = new DoubleMatrix(5, 3);
    183186
    184       TransportationCosts = 1;
    185 
    186187      Demands = new DoubleArray(5);
    187188      Demands[0] = 2; Demands[1] = 1; Demands[2] = 3; Demands[3] = 1; Demands[4] = 1;
     
    198199    public override IDeepCloneable Clone(Cloner cloner) {
    199200      return new GeneralizedQuadraticAssignmentProblem(this, cloner);
     201    }
     202
     203    public void LoadFrom(IQAPInstance format) {
     204      Weights = new DoubleMatrix(format.Weights);
     205      Distances = new DoubleMatrix(format.Distances);
     206      InstallationCosts = new DoubleMatrix(Weights.Rows, Distances.Columns);
     207      Capacities = new DoubleArray(Enumerable.Range(0, Distances.Rows).Select(x => 1.0).ToArray());
     208      Demands = new DoubleArray(Enumerable.Range(0, Weights.Rows).Select(x => 1.0).ToArray());
     209
     210      if (format.BestKnownAssignment != null) {
     211        var assignment = new IntegerVector(format.BestKnownAssignment);
     212        double flowDistanceQuality, installationQuality, overbookedCapacity;
     213        GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
     214          out flowDistanceQuality, out installationQuality, out overbookedCapacity);
     215        double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
     216        BestKnownSolution = new GQAPSolution(assignment, new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity));
     217        BestKnownQuality = new DoubleValue(quality);
     218      }
    200219    }
    201220
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7438 r7443  
    166166      <Name>HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common-3.3</Name>
    167167    </ProjectReference>
     168    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
     169      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
     170      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     171    </ProjectReference>
    168172  </ItemGroup>
    169173  <ItemGroup />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IBestKnownSolutionAwareGQAPOperator.cs

    r7419 r7443  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Encodings.IntegerVectorEncoding;
    2423
    2524namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    2625  public interface IBestKnownSolutionAwareGQAPOperator : IGQAPOperator {
    27     ILookupParameter<IntegerVector> BestKnownSolutionParameter { get; }
     26    ILookupParameter<GQAPSolution> BestKnownSolutionParameter { get; }
    2827  }
    2928}
Note: See TracChangeset for help on using the changeset viewer.