Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13364 for branches


Ignore:
Timestamp:
11/24/15 16:42:09 (9 years ago)
Author:
mkommend
Message:

#2521: Refactored IntegerVectorEncoding, KnapsackProblem, and P3.

Location:
branches/ProblemRefactoring
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r13361 r13364  
    4343  public class ParameterlessPopulationPyramid : BasicAlgorithm {
    4444    public override Type ProblemType {
    45       get { return typeof(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>); }
     45      get { return typeof(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>); }
    4646    }
    4747    public new ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> Problem {
  • branches/ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVector.cs

    r12012 r13364  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Data;
     26using HeuristicLab.Optimization;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
     
    2930  [StorableClass]
    3031  [Item("IntegerVector", "Represents a vector of integer values.")]
    31   public class IntegerVector : IntArray {
     32  public class IntegerVector : IntArray, ISolution {
    3233    [StorableConstructor]
    3334    protected IntegerVector(bool deserializing) : base(deserializing) { }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs

    r12837 r13364  
    3434  [Item("IntegerVectorEncoding", "Describes an integer vector encoding.")]
    3535  [StorableClass]
    36   public sealed class IntegerVectorEncoding : Encoding<IIntegerVectorCreator> {
     36  public sealed class IntegerVectorEncoding : Encoding<IntegerVector> {
    3737    #region Encoding Parameters
    3838    [Storable]
     
    271271    #endregion
    272272  }
    273 
    274   public static class IndividualExtensionMethods {
    275     public static IntegerVector IntegerVector(this Individual individual) {
    276       var encoding = individual.GetEncoding<IntegerVectorEncoding>();
    277       return individual.IntegerVector(encoding.Name);
    278     }
    279     public static IntegerVector IntegerVector(this Individual individual, string name) {
    280       return (IntegerVector)individual[name];
    281     }
    282   }
    283273}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/Interfaces/IIntegerVectorCreator.cs

    r12012 r13364  
    2828  /// An interface which represents an operator for creating vectors of int-valued data.
    2929  /// </summary>
    30   public interface IIntegerVectorCreator : ISolutionCreator, IBoundedIntegerVectorOperator {
     30  public interface IIntegerVectorCreator : ISolutionCreator<IntegerVector>, IBoundedIntegerVectorOperator {
    3131    IValueLookupParameter<IntValue> LengthParameter { get; }
    3232    ILookupParameter<IntegerVector> IntegerVectorParameter { get; }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Knapsack.Views/3.3/HeuristicLab.Problems.Knapsack.Views-3.3.csproj

    r11623 r13364  
    165165      <Private>False</Private>
    166166    </ProjectReference>
     167    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     168      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
     169      <Name>HeuristicLab.Optimization-3.3</Name>
     170      <Private>False</Private>
     171    </ProjectReference>
    167172    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    168173      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r13173 r13364  
    3838  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 200)]
    3939  [StorableClass]
    40   public sealed class KnapsackProblem : SingleObjectiveHeuristicOptimizationProblem<IKnapsackEvaluator, IBinaryVectorCreator>, IStorableContent {
     40  public sealed class KnapsackProblem : SingleObjectiveHeuristicOptimizationProblem<IKnapsackEvaluator, IBinaryVectorCreator>,
     41    ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>, IStorableContent {
    4142    public string Filename { get; set; }
    4243
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj

    r13361 r13364  
    153153      <Project>{66d249c3-a01d-42a8-82a2-919bc8ec3d83}</Project>
    154154      <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
     155      <Private>False</Private>
     156    </ProjectReference>
     157    <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
     158      <Project>{ddfb14dd-2a85-493c-a52d-e69729bbaeb0}</Project>
     159      <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
     160      <Private>False</Private>
    155161    </ProjectReference>
    156162    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
    157163      <Project>{bb6d334a-4bb6-4674-9883-31a6ebb32cab}</Project>
    158164      <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
     165      <Private>False</Private>
    159166    </ProjectReference>
    160167    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProgrammableProblemInstances.cs

    r13361 r13364  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Encodings.BinaryVectorEncoding;
     27using HeuristicLab.Encodings.IntegerVectorEncoding;
    2728using HeuristicLab.Encodings.RealVectorEncoding;
    2829using HeuristicLab.Optimization;
     
    7980  }
    8081
    81   //[Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
    82   //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    83   //[StorableClass]
    84   //public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
    85 
    86   //  [StorableConstructor]
    87   //  private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
    88   //  private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    89   //  public SingleObjectiveIntegerVectorProgrammableProblem()
    90   //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
    91 
    92   //  public override IDeepCloneable Clone(Cloner cloner) {
    93   //    return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
    94   //  }
    95   //}
     82  [Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
     83  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     84  [StorableClass]
     85  public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
     86
     87    [StorableConstructor]
     88    private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     89    private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     90
     91    public SingleObjectiveIntegerVectorProgrammableProblem()
     92      : base() {
     93      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     94      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
     95      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
     96      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "IntegerVector");
     97      ProblemScript.Code = codeTemplate;
     98    }
     99
     100    public override IDeepCloneable Clone(Cloner cloner) {
     101      return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
     102    }
     103  }
    96104
    97105  [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
     
    216224  }
    217225
    218   //[Item("Integer Vector Programmable Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
    219   //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    220   //[StorableClass]
    221   //public sealed class MultiObjectiveIntegerVectorProgrammableProblem : MultiObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
    222 
    223   //  [StorableConstructor]
    224   //  private MultiObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
    225   //  private MultiObjectiveIntegerVectorProgrammableProblem(MultiObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    226   //  public MultiObjectiveIntegerVectorProgrammableProblem()
    227   //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
    228 
    229   //  public override IDeepCloneable Clone(Cloner cloner) {
    230   //    return new MultiObjectiveIntegerVectorProgrammableProblem(this, cloner);
    231   //  }
    232   //}
     226  [Item("Integer Vector Programmable Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
     227  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     228  [StorableClass]
     229  public sealed class MultiObjectiveIntegerVectorProgrammableProblem : MultiObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
     230
     231    [StorableConstructor]
     232    private MultiObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     233    private MultiObjectiveIntegerVectorProgrammableProblem(MultiObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     234
     235    public MultiObjectiveIntegerVectorProgrammableProblem()
     236      : base() {
     237      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     238      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
     239      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
     240      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "IntegerVector");
     241      ProblemScript.Code = codeTemplate;
     242    }
     243
     244    public override IDeepCloneable Clone(Cloner cloner) {
     245      return new MultiObjectiveIntegerVectorProgrammableProblem(this, cloner);
     246    }
     247  }
    233248
    234249  [Item("Real Vector Programmable Problem (multi-objective)", "Represents a real vector multi-objective problem that can be programmed with a script.")]
Note: See TracChangeset for help on using the changeset viewer.