Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16532


Ignore:
Timestamp:
01/14/19 22:33:44 (5 years ago)
Author:
abeham
Message:

#2521: reverted r14429

Location:
branches/2521_ProblemRefactoring
Files:
14 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab 3.3.sln

    r14429 r16532  
    11
    22Microsoft Visual Studio Solution File, Format Version 12.00
    3 # Visual Studio 14
    4 VisualStudioVersion = 14.0.25420.1
     3# Visual Studio 2013
     4VisualStudioVersion = 12.0.31101.0
    55MinimumVisualStudioVersion = 10.0.40219.1
    66Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96396439-A764-4022-A8D2-BE021449B8D1}"
     
    451451EndProject
    452452Global
    453   GlobalSection(Performance) = preSolution
    454     HasPerformanceSessions = true
    455   EndGlobalSection
    456453  GlobalSection(SolutionConfigurationPlatforms) = preSolution
    457454    Debug|Any CPU = Debug|Any CPU
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/HeuristicLab.Algorithms.GeneticAlgorithm-3.3.csproj

    r14429 r16532  
    115115  </ItemGroup>
    116116  <ItemGroup>
    117     <Compile Include="BinaryCanonicalGeneticAlgorithm.cs" />
    118     <Compile Include="CanonicalGeneticAlgorithm.cs" />
    119     <Compile Include="EvolutionaryAlgorithmContext.cs" />
    120117    <Compile Include="GeneticAlgorithm.cs" />
    121118    <Compile Include="GeneticAlgorithmMainLoop.cs" />
     
    150147      <Name>HeuristicLab.Data-3.3</Name>
    151148      <Private>False</Private>
    152     </ProjectReference>
    153     <ProjectReference Include="..\..\HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj">
    154       <Project>{66D249C3-A01D-42A8-82A2-919BC8EC3D83}</Project>
    155       <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
    156149    </ProjectReference>
    157150    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.LocalSearch/3.3/HeuristicLab.Algorithms.LocalSearch-3.3.csproj

    r14429 r16532  
    114114  </ItemGroup>
    115115  <ItemGroup>
    116     <Compile Include="BinaryIteratedLocalSearch.cs" />
    117     <Compile Include="IteratedLocalSearch.cs" />
    118     <Compile Include="LocalSearchContext.cs" />
    119116    <Compile Include="LocalSearchImprovementOperator.cs" />
    120117    <Compile Include="LocalSearchMainLoop.cs" />
     
    153150      <Name>HeuristicLab.Data-3.3</Name>
    154151      <Private>False</Private>
    155     </ProjectReference>
    156     <ProjectReference Include="..\..\HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj">
    157       <Project>{66D249C3-A01D-42A8-82A2-919BC8EC3D83}</Project>
    158       <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
    159152    </ProjectReference>
    160153    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
  • branches/2521_ProblemRefactoring/HeuristicLab.Core/3.3/Attributes/ItemAttribute.cs

    r14429 r16532  
    3939      set { description = value == null ? string.Empty : value; }
    4040    }
    41     public bool ExcludeGenericTypeInfo { get; set; }
    4241
    43     public ItemAttribute() : this(string.Empty, string.Empty, false) { }
    44     public ItemAttribute(string name, string description) : this(name, description, false) { }
    45     public ItemAttribute(string name, string description, bool excludeGenericTypeInfo) {
     42    public ItemAttribute() {
     43      Name = string.Empty;
     44      Description = string.Empty;
     45    }
     46    public ItemAttribute(string name, string description) {
    4647      Name = name;
    4748      Description = description;
    48       ExcludeGenericTypeInfo = excludeGenericTypeInfo;
    4949    }
    5050
     
    5252      object[] attribs = type.GetCustomAttributes(typeof(ItemAttribute), false);
    5353      if (attribs.Length > 0) {
    54         var attribute = (ItemAttribute)attribs[0];
    55         string name = attribute.Name;
    56         if (!attribute.ExcludeGenericTypeInfo && type.IsGenericType) {
     54        string name = ((ItemAttribute)attribs[0]).Name;
     55        if (type.IsGenericType) {
    5756          name += "<";
    5857          Type[] typeParams = type.GetGenericArguments();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/NPointCrossover.cs

    r14429 r16532  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Data;
    27 using HeuristicLab.Optimization;
    2827using HeuristicLab.Parameters;
    2928using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    7170    /// <param name="n">Number of crossover points.</param>
    7271    /// <returns>The newly created binary vector, resulting from the N point crossover.</returns>
    73     public static BinaryVector Apply(IRandom random, BinaryVector parent1, BinaryVector parent2, int n) {
     72    public static BinaryVector Apply(IRandom random, BinaryVector parent1, BinaryVector parent2, IntValue n) {
    7473      if (parent1.Length != parent2.Length)
    7574        throw new ArgumentException("NPointCrossover: The parents are of different length.");
    7675
    77       if (n > parent1.Length)
     76      if (n.Value > parent1.Length)
    7877        throw new ArgumentException("NPointCrossover: There cannot be more breakpoints than the size of the parents.");
    7978
    80       if (n < 1)
     79      if (n.Value < 1)
    8180        throw new ArgumentException("NPointCrossover: N cannot be < 1.");
    8281
    8382      int length = parent1.Length;
    8483      bool[] result = new bool[length];
    85       int[] breakpoints = new int[n];
     84      int[] breakpoints = new int[n.Value];
    8685
    8786      //choose break points
     
    9190        breakpointPool.Add(i);
    9291
    93       for (int i = 0; i < n; i++) {
     92      for (int i = 0; i < n.Value; i++) {
    9493        int index = random.Next(breakpointPool.Count);
    9594        breakpoints[i] = breakpointPool[index];
     
    138137      if (NParameter.ActualValue == null) throw new InvalidOperationException("NPointCrossover: Parameter " + NParameter.ActualName + " could not be found.");
    139138
    140       return Apply(random, parents[0], parents[1], NParameter.ActualValue.Value);
    141     }
    142   }
    143 
    144   [Item("N-point Crossover", "", ExcludeGenericTypeInfo = true)]
    145   [StorableClass]
    146   public sealed class NPointCrossover<TContext> : ParameterizedNamedItem, IBinaryCrossover<TContext>
    147     where TContext : IMatingContext<BinaryVector>, IStochasticContext {
    148 
    149     [Storable]
    150     private IValueParameter<IntValue> nparameter;
    151     public int N {
    152       get { return nparameter.Value.Value; }
    153       set {
    154         if (value < 1) throw new ArgumentException("Cannot set N to less than 1.");
    155         nparameter.Value.Value = value;
    156       }
    157     }
    158 
    159     [StorableConstructor]
    160     private NPointCrossover(bool deserializing) : base(deserializing) { }
    161     private NPointCrossover(NPointCrossover<TContext> original, Cloner cloner)
    162       : base(original, cloner) {
    163       nparameter = cloner.Clone(original.nparameter);
    164     }
    165     public NPointCrossover() {
    166       Parameters.Add(nparameter = new ValueParameter<IntValue>("N", "The number of crossover points.", new IntValue(1)));
    167     }
    168 
    169 
    170     public override IDeepCloneable Clone(Cloner cloner) {
    171       return new NPointCrossover<TContext>(this, cloner);
    172     }
    173 
    174     public void Cross(TContext context) {
    175       context.Child.Solution = NPointCrossover.Apply(context.Random, context.Parents.Item1.Solution, context.Parents.Item2.Solution, N);
     139      return Apply(random, parents[0], parents[1], NParameter.ActualValue);
    176140    }
    177141  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Crossovers/SinglePointCrossover.cs

    r14429 r16532  
    5757      if (parents.Length != 2) throw new ArgumentException("ERROR in SinglePointCrossover: The number of parents is not equal to 2");
    5858
    59       return NPointCrossover.Apply(random, parents[0], parents[1], 1);
     59      return NPointCrossover.Apply(random, parents[0], parents[1], new IntValue(1));
    6060    }
    6161  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj

    r14429 r16532  
    126126    <Compile Include="Crossovers\NPointCrossover.cs" />
    127127    <Compile Include="BinaryVector.cs" />
    128     <Compile Include="Interfaces\IBinaryLocalSearch.cs" />
    129128    <Compile Include="Interfaces\IBinaryVectorMultiNeighborhoodShakingOperator.cs" />
    130129    <Compile Include="Interfaces\IBinaryVectorSolutionsOperator.cs" />
     
    140139    <Compile Include="BinaryVectorManipulator.cs" />
    141140    <Compile Include="Interfaces\IBinaryVectorMoveOperator.cs" />
    142     <Compile Include="LocalSearch\ExhaustiveBitflip.cs" />
    143     <Compile Include="Manipulators\MultiBitflipManipulator.cs" />
    144     <Compile Include="Manipulators\SingleBitflipManipulator.cs" />
    145     <Compile Include="Manipulators\BitflipManipulator.cs" />
    146141    <Compile Include="Manipulators\SomePositionsBitflipManipulator.cs" />
    147142    <Compile Include="Manipulators\SinglePositionBitflipManipulator.cs" />
     
    210205      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    211206      <Private>False</Private>
    212     </ProjectReference>
    213     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    214       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    215       <Name>HeuristicLab.Random-3.3</Name>
    216207    </ProjectReference>
    217208  </ItemGroup>
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/Interfaces/IBinaryVectorCrossover.cs

    r14429 r16532  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Optimization;
    24 using HeuristicLab.Optimization.Crossover;
    2524
    2625namespace HeuristicLab.Encodings.BinaryVectorEncoding {
     
    3231    ILookupParameter<BinaryVector> ChildParameter { get; }
    3332  }
    34 
    35   // TODO: probably unecessary
    36   public interface IBinaryCrossover<TContext> : ICrossover<TContext> { }
    3733}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs

    r14429 r16532  
    8181    }
    8282
    83     // TODO: There is no way to access the Operators collection other than through OperatorParameter.Value
     83
    8484    protected override IEnumerable<IItem> GetOperators() {
    8585      if (Encoding == null) return base.GetOperators();
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r14429 r16532  
    120120  </ItemGroup>
    121121  <ItemGroup>
    122     <Compile Include="Algorithms\SingleObjective\HeuristicAlgorithmContext.cs" />
    123122    <Compile Include="Algorithms\BasicAlgorithm.cs" />
    124     <Compile Include="Algorithms\SingleObjective\HeuristicAlgorithm.cs" />
    125     <Compile Include="Algorithms\AlgorithmContext.cs" />
    126     <Compile Include="Algorithms\SingleObjective\SingleObjectiveSolutionScope.cs" />
    127123    <Compile Include="BasicProblems\CombinedSolution.cs" />
    128124    <Compile Include="BasicProblems\Interfaces\IMultiEncodingOperator.cs" />
     
    174170    <Compile Include="MetaOptimizers\Experiment.cs" />
    175171    <Compile Include="MetaOptimizers\TimeLimitRun.cs" />
    176     <Compile Include="NewInfrastructure\Interfaces.cs" />
    177172    <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" />
    178173    <Compile Include="Plugin.cs" />
     
    317312      <Private>False</Private>
    318313    </ProjectReference>
    319     <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
    320       <Project>{F4539FB6-4708-40C9-BE64-0A1390AEA197}</Project>
    321       <Name>HeuristicLab.Random-3.3</Name>
    322     </ProjectReference>
    323314  </ItemGroup>
    324315  <ItemGroup>
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/Analyzers/BestKnapsackSolutionAnalyzer.cs

    r14429 r16532  
    6060    }
    6161    public ILookupParameter<KnapsackSolution> BestSolutionParameter {
    62       get { return (ILookupParameter<KnapsackSolution>)Parameters["BestKnapsackSolution"]; }
     62      get { return (ILookupParameter<KnapsackSolution>)Parameters["BestSolution"]; }
    6363    }
    6464    public IValueLookupParameter<ResultCollection> ResultsParameter {
     
    8484
    8585      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the Knapsack solutions which should be visualized."));
    86       Parameters.Add(new LookupParameter<KnapsackSolution>("BestKnapsackSolution", "The best Knapsack solution."));
     86      Parameters.Add(new LookupParameter<KnapsackSolution>("BestSolution", "The best Knapsack solution."));
    8787      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the knapsack solution should be stored."));
    8888      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution."));
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r14429 r16532  
    9191
    9292      InitializeRandomKnapsackInstance();
    93       Encoding.Length = Weights.Length;
    9493
    9594      InitializeOperators();
     
    9897
    9998    public override double Evaluate(BinaryVector solution, IRandom random) {
    100       var weights = Weights;
    101       var values = Values;
    10299      var totalWeight = 0.0;
    103100      var totalValue = 0.0;
    104101      for (var i = 0; i < solution.Length; i++) {
    105102        if (!solution[i]) continue;
    106         totalWeight += weights[i];
    107         totalValue += values[i];
     103        totalWeight += Weights[i];
     104        totalValue += Values[i];
    108105      }
    109106      return totalWeight > KnapsackCapacity ? KnapsackCapacity - totalWeight : totalValue;
     
    256253      var sysrand = new System.Random();
    257254
    258       var power = sysrand.Next(5, 11);
    259       var itemCount = (int)Math.Pow(2, power);
     255      var itemCount = sysrand.Next(10, 100);
    260256      Weights = new IntArray(itemCount);
    261257      Values = new IntArray(itemCount);
     
    264260
    265261      for (int i = 0; i < itemCount; i++) {
    266         var value = sysrand.Next(1, 30);
    267         var weight = sysrand.Next(1, 30);
     262        var value = sysrand.Next(1, 10);
     263        var weight = sysrand.Next(1, 10);
    268264
    269265        Values[i] = value;
     
    272268      }
    273269
    274       KnapsackCapacity = (int)Math.Round(0.5 * totalWeight);
     270      KnapsackCapacity = (int)Math.Round(0.7 * totalWeight);
    275271    }
    276272  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Selection/3.3/TournamentSelector.cs

    r14429 r16532  
    2727using HeuristicLab.Data;
    2828using HeuristicLab.Optimization;
    29 using HeuristicLab.Optimization.Selection;
    3029using HeuristicLab.Parameters;
    3130using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    9190    }
    9291  }
    93 
    94   [Item("Tournament Selector", "", ExcludeGenericTypeInfo = true)]
    95   [StorableClass]
    96   public sealed class TournamentSelector<TContext, TProblem, TEncoding, TSolution> : ParameterizedNamedItem, ISelector<TContext>
    97       where TContext : ISingleObjectivePopulationContext<TSolution>, IMatingpoolContext<TSolution>, IStochasticContext,
    98                        IProblemContext<TProblem, TEncoding, TSolution>
    99       where TProblem : class, ISingleObjectiveProblem<TEncoding, TSolution>, ISingleObjectiveProblemDefinition<TEncoding, TSolution>
    100       where TEncoding : class, IEncoding<TSolution>
    101       where TSolution : class, ISolution {
    102 
    103     [Storable]
    104     private IValueParameter<IntValue> groupSizeParameter;
    105     public int GroupSize {
    106       get { return groupSizeParameter.Value.Value; }
    107       set {
    108         if (value < 1) throw new ArgumentException("Cannot use a group size less than 1 in tournament selection.");
    109         groupSizeParameter.Value.Value = value;
    110       }
    111     }
    112    
    113     [StorableConstructor]
    114     private TournamentSelector(bool deserializing) : base(deserializing) { }
    115     private TournamentSelector(TournamentSelector<TContext, TProblem, TEncoding, TSolution> original, Cloner cloner)
    116       : base(original, cloner) {
    117       groupSizeParameter = cloner.Clone(groupSizeParameter);
    118     }
    119     public TournamentSelector() {
    120       Parameters.Add(groupSizeParameter = new ValueParameter<IntValue>("GroupSize", "The group size that competes in the tournament.", new IntValue(2)));
    121     }
    122 
    123     public override IDeepCloneable Clone(Cloner cloner) {
    124       return new TournamentSelector<TContext, TProblem, TEncoding, TSolution>(this, cloner);
    125     }
    126 
    127     public void Select(TContext context, int n, bool withRepetition) {
    128       context.MatingPool = Select(context.Random, context.Problem.IsBetter, context.Population, GroupSize, n, withRepetition);
    129     }
    130 
    131     public static IEnumerable<ISingleObjectiveSolutionScope<TSolution>> Select(IRandom random, Func<double, double, bool> isBetterFunc, IEnumerable<ISingleObjectiveSolutionScope<TSolution>> population, int groupSize, int n, bool withRepetition) {
    132       var pop = population.Where(x => !double.IsNaN(x.Fitness)).ToList();
    133 
    134       var i = n;
    135       while (i > 0 && pop.Count > 0) {
    136         var best = random.Next(pop.Count);
    137         for (var j = 1; j < groupSize; j++) {
    138           var index = random.Next(pop.Count);
    139           if (isBetterFunc(pop[index].Fitness, pop[best].Fitness)) {
    140             best = index;
    141           }
    142         }
    143 
    144         yield return pop[best];
    145         i--;
    146         if (!withRepetition) {
    147           pop.RemoveAt(i);
    148         }
    149       }
    150     }
    151   }
    15292}
Note: See TracChangeset for help on using the changeset viewer.