Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13373


Ignore:
Timestamp:
11/24/15 17:27:35 (9 years ago)
Author:
abeham
Message:

#2521: adapted templates, fixed missing reference in outdated plugin lawnmower

Location:
branches/ProblemRefactoring
Files:
1 added
5 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Problems.LawnMower.Views/3.3/HeuristicLab.Problems.LawnMower.Views-3.3.csproj

    r12899 r13373  
    167167      <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project>
    168168      <Name>HeuristicLab.MainForm-3.3</Name>
     169      <Private>False</Private>
     170    </ProjectReference>
     171    <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">
     172      <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project>
     173      <Name>HeuristicLab.Optimization-3.3</Name>
    169174      <Private>False</Private>
    170175    </ProjectReference>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj

    r13364 r13373  
    9797    <Compile Include="ProblemDefinitionScriptException.cs" />
    9898    <Compile Include="ProgrammableProblemInstances.cs" />
    99     <Content Include="Templates\CompiledSingleObjectiveProblemDefinition_Template.cs" />
    100     <Content Include="Templates\CompiledMultiObjectiveProblemDefinition_Template.cs">
    101       <SubType>Code</SubType>
    102     </Content>
     99    <Content Include="Templates\MultiObjectiveCombinedEncodingProblem_Template.cs" />
     100    <Content Include="Templates\MultiObjectiveProblem_Template.cs" />
    103101    <Compile Include="Templates\ScriptTemplates.Designer.cs">
    104102      <AutoGen>True</AutoGen>
     
    108106    <Compile Include="SingleObjectiveProgrammableProblem.cs" />
    109107    <Compile Include="SingleObjectiveProblemDefinitionScript.cs" />
     108    <Content Include="Templates\SingleObjectiveCombinedEncodingProblem_Template.cs" />
     109    <Content Include="Templates\SingleObjectiveProblem_Template.cs" />
    110110    <EmbeddedResource Include="Templates\ScriptTemplates.resx">
    111111      <Generator>PublicResXFileCodeGenerator</Generator>
     
    160160      <Private>False</Private>
    161161    </ProjectReference>
     162    <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
     163      <Project>{dbecb8b0-b166-4133-baf1-ed67c3fd7fca}</Project>
     164      <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
     165      <Private>False</Private>
     166    </ProjectReference>
    162167    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
    163168      <Project>{bb6d334a-4bb6-4674-9883-31a6ebb32cab}</Project>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r13350 r13373  
    4040    private MultiObjectiveProblemDefinitionScript(bool deserializing) : base(deserializing) { }
    4141    private MultiObjectiveProblemDefinitionScript(MultiObjectiveProblemDefinitionScript<TEncoding, TSolution> original, Cloner cloner) : base(original, cloner) { }
    42     public MultiObjectiveProblemDefinitionScript() : base(ScriptTemplates.CompiledMultiObjectiveProblemDefinition_Template) { }
     42    public MultiObjectiveProblemDefinitionScript(string codeTemplate) : base(codeTemplate) { }
     43    public MultiObjectiveProblemDefinitionScript() : base() { }
    4344
    4445    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProgrammableProblemInstances.cs

    r13364 r13373  
    2626using HeuristicLab.Encodings.BinaryVectorEncoding;
    2727using HeuristicLab.Encodings.IntegerVectorEncoding;
     28using HeuristicLab.Encodings.PermutationEncoding;
    2829using HeuristicLab.Encodings.RealVectorEncoding;
    2930using HeuristicLab.Optimization;
     
    3233namespace HeuristicLab.Problems.Programmable {
    3334  #region single-objective
    34   [Item("Binary Vector Programmable Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")]
     35  [Item("Binary Vector Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")]
    3536  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    3637  [StorableClass]
     
    4344    public SingleObjectiveBinaryVectorProgrammableProblem()
    4445      : base() {
    45       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     46      var codeTemplate = ScriptTemplates.SingleObjectiveProblem_Template;
    4647      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
    4748      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
     
    5657  }
    5758
    58   [Item("Multi Solution Programmable Problem (single-objective)", "Represents a multi solution single-objective problem that can be programmed with a script.")]
     59  [Item("Combined Encoding Problem (single-objective)", "Represents a combined encoding single-objective problem that can be programmed with a script.")]
    5960  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    6061  [StorableClass]
     
    6768    public SingleObjectiveMultiSolutionProgrammableProblem()
    6869      : base() {
    69       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
    70       codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
    71       codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
    72       codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "CombinedSolution");
    73       ProblemScript.Code = codeTemplate;
     70      ProblemScript.Code = ScriptTemplates.SingleObjectiveCombinedEncodingProblem_Template;
    7471    }
    7572
     
    8077  }
    8178
    82   [Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
     79  [Item("Integer Vector Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
    8380  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    8481  [StorableClass]
     
    9188    public SingleObjectiveIntegerVectorProgrammableProblem()
    9289      : base() {
    93       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     90      var codeTemplate = ScriptTemplates.SingleObjectiveProblem_Template;
    9491      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
    9592      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
     
    103100  }
    104101
    105   [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
     102  [Item("Real Vector Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
    106103  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    107104  [StorableClass]
     
    114111    public SingleObjectiveRealVectorProgrammableProblem()
    115112      : base() {
    116       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     113      var codeTemplate = ScriptTemplates.SingleObjectiveProblem_Template;
    117114      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
    118115      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
     
    126123  }
    127124
    128   //[Item("Permutation Programmable Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
    129   //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    130   //[StorableClass]
    131   //public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
    132 
    133   //  [StorableConstructor]
    134   //  private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
    135   //  private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    136   //  public SingleObjectivePermutationProgrammableProblem()
    137   //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
    138 
    139   //  public override IDeepCloneable Clone(Cloner cloner) {
    140   //    return new SingleObjectivePermutationProgrammableProblem(this, cloner);
    141   //  }
    142   //}
     125  [Item("Permutation Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
     126  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     127  [StorableClass]
     128  public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
     129
     130    [StorableConstructor]
     131    private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
     132    private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     133
     134    public SingleObjectivePermutationProgrammableProblem()
     135      : base() {
     136      var codeTemplate = ScriptTemplates.SingleObjectiveProblem_Template;
     137      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.PermutationEncoding");
     138      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "PermutationEncoding");
     139      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "Permutation");
     140      ProblemScript.Code = codeTemplate;
     141    }
     142
     143    public override IDeepCloneable Clone(Cloner cloner) {
     144      return new SingleObjectivePermutationProgrammableProblem(this, cloner);
     145    }
     146  }
    143147
    144148  //[Item("Symbolic Expression Tree Programmable Problem (single-objective)", "Represents a symbolic expression tree single-objective problem that can be programmed with a script.")]
     
    176180
    177181  #region multi-objective
    178   [Item("Binary Vector Programmable Problem (multi-objective)", "Represents a binary vector multi-objective problem that can be programmed with a script.")]
     182  [Item("Binary Vector Problem (multi-objective)", "Represents a binary vector multi-objective problem that can be programmed with a script.")]
    179183  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    180184  [StorableClass]
     
    187191    public MultiObjectiveBinaryVectorProgrammableProblem()
    188192      : base() {
    189       var codeTemplate = ScriptTemplates.CompiledMultiObjectiveProblemDefinition_Template;
     193      var codeTemplate = ScriptTemplates.MultiObjectiveProblem_Template;
    190194      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
    191195      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
     
    200204  }
    201205
    202   [Item("Multi Solution Programmable Problem (multi-objective)", "Represents a multi solution multi-objective problem that can be programmed with a script.")]
     206  [Item("Combined Encoding Problem (multi-objective)", "Represents a combined encoding multi-objective problem that can be programmed with a script.")]
    203207  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    204208  [StorableClass]
     
    211215    public MultiObjectiveMultiSolutionProgrammableProblem()
    212216      : base() {
    213       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
    214       codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
    215       codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
    216       codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "CombinedSolution");
    217       ProblemScript.Code = codeTemplate;
     217      ProblemScript.Code = ScriptTemplates.MultiObjectiveCombinedEncodingProblem_Template;
    218218    }
    219219
     
    224224  }
    225225
    226   [Item("Integer Vector Programmable Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
     226  [Item("Integer Vector Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
    227227  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    228228  [StorableClass]
     
    235235    public MultiObjectiveIntegerVectorProgrammableProblem()
    236236      : base() {
    237       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     237      var codeTemplate = ScriptTemplates.MultiObjectiveProblem_Template;
    238238      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.IntegerVectorEncoding");
    239239      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "IntegerVectorEncoding");
     
    247247  }
    248248
    249   [Item("Real Vector Programmable Problem (multi-objective)", "Represents a real vector multi-objective problem that can be programmed with a script.")]
     249  [Item("Real Vector Problem (multi-objective)", "Represents a real vector multi-objective problem that can be programmed with a script.")]
    250250  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    251251  [StorableClass]
     
    258258    public MultiObjectiveRealVectorProgrammableProblem()
    259259      : base() {
    260       var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     260      var codeTemplate = ScriptTemplates.MultiObjectiveProblem_Template;
    261261      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
    262262      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
     
    270270  }
    271271
    272   //[Item("Permutation Programmable Problem (multi-objective)", "Represents a permutation multi-objective problem that can be programmed with a script.")]
    273   //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    274   //[StorableClass]
    275   //public sealed class MultiObjectivePermutationProgrammableProblem : MultiObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
    276 
    277   //  [StorableConstructor]
    278   //  private MultiObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
    279   //  private MultiObjectivePermutationProgrammableProblem(MultiObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    280   //  public MultiObjectivePermutationProgrammableProblem()
    281   //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
    282 
    283   //  public override IDeepCloneable Clone(Cloner cloner) {
    284   //    return new MultiObjectivePermutationProgrammableProblem(this, cloner);
    285   //  }
    286   //}
     272  [Item("Permutation Problem (multi-objective)", "Represents a permutation multi-objective problem that can be programmed with a script.")]
     273  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     274  [StorableClass]
     275  public sealed class MultiObjectivePermutationProgrammableProblem : MultiObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
     276
     277    [StorableConstructor]
     278    private MultiObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
     279    private MultiObjectivePermutationProgrammableProblem(MultiObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     280    public MultiObjectivePermutationProgrammableProblem()
     281      : base() {
     282      var codeTemplate = ScriptTemplates.MultiObjectiveProblem_Template;
     283      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.PermutationEncoding");
     284      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "PermutationEncoding");
     285      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "Permutation");
     286      ProblemScript.Code = codeTemplate;
     287    }
     288
     289    public override IDeepCloneable Clone(Cloner cloner) {
     290      return new MultiObjectivePermutationProgrammableProblem(this, cloner);
     291    }
     292  }
    287293
    288294  //[Item("Symbolic Expression Tree Programmable Problem (multi-objective)", "Represents a symbolic expression tree multi-objective problem that can be programmed with a script.")]
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs

    r13363 r13373  
    55using HeuristicLab.Core;
    66using HeuristicLab.Data;
    7 using ENCODING_NAMESPACE;
    87using HeuristicLab.Optimization;
    98using HeuristicLab.Problems.Programmable;
     9//using HeuristicLab.Encodings.BinaryVectorEncoding;
     10//using HeuristicLab.Encodings.IntegerVectorEncoding;
     11//using HeuristicLab.Encodings.RealVectorEncoding;
     12//using HeuristicLab.Encodings.PermutationEncoding;
     13//using HeuristicLab.Encodings.LinearLinkageEncoding;
     14//using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    1015
    1116namespace HeuristicLab.Problems.Programmable {
    12   public class CompiledSingleObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> {
    13     public override bool[] Maximization { get { return new[] { false, false }; } }
     17  public class CompiledSingleObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<CombinedEncoding, CombinedSolution> {
     18    public override bool[] Maximization { get { return new[] { true, false }; } }
    1419
    1520    public override void Initialize() {
     
    1722      // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
    1823      // Add additional initialization code e.g. private variables that you need for evaluating
     24      //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
     25      //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } } });
     26      //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } } });
     27      //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });
     28      //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 });
     29      //Encoding.Add(new SymbolicExpressionTreeEncoding("tree") { ... });
    1930    }
    2031
    21     public override double[] Evaluate(SOLUTION_CLASS solution, IRandom random) {
     32    public override double[] Evaluate(CombinedSolution solution, IRandom random) {
    2233      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2334      var quality = new[] { 0.0, 0.0 };
     35      // var b = solution.GetSolution<BinaryVector>("b");
     36      // quality[0] = b.Count(x => x); // one max!
     37      // var r = solution.GetSolution<RealVector>("r");
     38      // quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere
     39
     40      // NOTE: Check the Maximization property above (true or false)!
    2441      return quality;
    2542    }
    2643
    27     public override void Analyze(SOLUTION_CLASS[] solution, double[][] qualities, ResultCollection results, IRandom random) {
     44    public override void Analyze(CombinedSolution[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
    2845      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2946      // Write or update results given the range of vectors and resulting qualities
    30       // Uncomment the following lines if you want to retrieve the best individual
    31 
    32       //var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
    33       //var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
    34 
    35       //if (!results.ContainsKey("Best Solution")) {
    36       //  results.Add(new Result("Best Solution", typeof(SOLUTION_CLASS)));
    37       //}
    38       //results["Best Solution"].Value = (IItem)best.Clone();
     47      // Uncomment the following lines if you want to retrieve the best solution
    3948    }
    4049
    41     public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS individual, IRandom random) {
     50    public override IEnumerable<CombinedSolution> GetNeighbors(CombinedSolution solution, IRandom random) {
    4251      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    4352      // Create new vectors, based on the given one that represent small changes
     
    4655        // Algorithm will draw only a finite amount of samples
    4756        // Change to a for-loop to return a concrete amount of neighbors
    48         var neighbor = (SOLUTION_CLASS)individual.Clone();
     57        var neighbor = (CombinedSolution)solution.Clone();
    4958        // modify the solution specified as neighbor
    5059        yield return neighbor;
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveProblem_Template.cs

    r13372 r13373  
    1616      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    1717      // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
     18      // Encoding.Length = 100;
    1819      // Add additional initialization code e.g. private variables that you need for evaluating
    1920    }
     
    2526    }
    2627
    27     public override void Analyze(SOLUTION_CLASS[] solution, double[][] qualities, ResultCollection results, IRandom random) {
     28    public override void Analyze(SOLUTION_CLASS[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
    2829      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2930      // Write or update results given the range of vectors and resulting qualities
    30       // Uncomment the following lines if you want to retrieve the best individual
    31 
    32       //var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
    33       //var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
    34 
    35       //if (!results.ContainsKey("Best Solution")) {
    36       //  results.Add(new Result("Best Solution", typeof(SOLUTION_CLASS)));
    37       //}
    38       //results["Best Solution"].Value = (IItem)best.Clone();
    3931    }
    4032
    41     public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS individual, IRandom random) {
     33    public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS solution, IRandom random) {
    4234      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    4335      // Create new vectors, based on the given one that represent small changes
     
    4638        // Algorithm will draw only a finite amount of samples
    4739        // Change to a for-loop to return a concrete amount of neighbors
    48         var neighbor = (SOLUTION_CLASS)individual.Clone();
     40        var neighbor = (SOLUTION_CLASS)solution.Clone();
    4941        // modify the solution specified as neighbor
    5042        yield return neighbor;
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/ScriptTemplates.resx

    r13348 r13373  
    119119  </resheader>
    120120  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    121   <data name="CompiledMultiObjectiveProblemDefinition_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
    122     <value>CompiledMultiObjectiveProblemDefinition_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     121  <data name="MultiObjectiveCombinedEncodingProblem_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
     122    <value>MultiObjectiveCombinedEncodingProblem_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    123123  </data>
    124   <data name="CompiledSingleObjectiveProblemDefinition_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
    125     <value>CompiledSingleObjectiveProblemDefinition_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     124  <data name="MultiObjectiveProblem_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
     125    <value>MultiObjectiveProblem_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     126  </data>
     127  <data name="SingleObjectiveCombinedEncodingProblem_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
     128    <value>SingleObjectiveCombinedEncodingProblem_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     129  </data>
     130  <data name="SingleObjectiveProblem_Template" type="System.Resources.ResXFileRef, System.Windows.Forms">
     131    <value>SingleObjectiveProblem_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    126132  </data>
    127133</root>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveCombinedEncodingProblem_Template.cs

    r13363 r13373  
    55using HeuristicLab.Core;
    66using HeuristicLab.Data;
    7 using ENCODING_NAMESPACE;
    87using HeuristicLab.Optimization;
    98using HeuristicLab.Problems.Programmable;
     9//using HeuristicLab.Encodings.BinaryVectorEncoding;
     10//using HeuristicLab.Encodings.IntegerVectorEncoding;
     11//using HeuristicLab.Encodings.RealVectorEncoding;
     12//using HeuristicLab.Encodings.PermutationEncoding;
     13//using HeuristicLab.Encodings.LinearLinkageEncoding;
     14//using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    1015
    1116namespace HeuristicLab.Problems.Programmable {
    12   public class CompiledSingleObjectiveProblemDefinition : CompiledSingleObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> {
    13     public override bool Maximization { get { return false; } }
     17  public class CompiledSingleObjectiveProblemDefinition : CompiledSingleObjectiveProblemDefinition<CombinedEncoding, CombinedSolution> {
     18    public override bool Maximization { get { return true; } }
    1419
    1520    public override void Initialize() {
     
    1722      // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
    1823      // Add additional initialization code e.g. private variables that you need for evaluating
     24      //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });
     25      //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new int[,] { { -100, 100 } } });
     26      //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new double[,] { { -100, 100 } } });
     27      //Encoding.Add(new PermutationEncoding("p") { Length = 20, PermutationType = PermutationTypes.Absolute });
     28      //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 });
     29      //Encoding.Add(new SymbolicExpressionTreeEncoding("tree") { ... });
    1930    }
    2031
    21     public override double Evaluate(SOLUTION_CLASS solution, IRandom random) {
     32    public override double Evaluate(CombinedSolution solution, IRandom random) {
    2233      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2334      var quality = 0.0;
     35      // var b = solution.GetSolution<BinaryVector>("b");
     36      // quality = b.Count(x => x); // one max!
     37      // var r = solution.GetSolution<RealVector>("r");
     38      // quality += r.Sum(x => -x * x); // sphere
     39
     40      // NOTE: Check the Maximization property above (true or false)!
    2441      return quality;
    2542    }
    2643
    27     public override void Analyze(SOLUTION_CLASS[] solution, double[] qualities, ResultCollection results, IRandom random) {
     44    public override void Analyze(CombinedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) {
    2845      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2946      // Write or update results given the range of vectors and resulting qualities
    30       // Uncomment the following lines if you want to retrieve the best individual
     47      // Uncomment the following lines if you want to retrieve the best solution
    3148
    32       //var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
    33       //var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
     49      //var orderedSolutions = solutions.Zip(qualities, (i, q) => new { Solution = i, Quality = q }).OrderBy(z => z.Quality);
     50      //var best = Maximization ? orderedSolutions.Last().Solution : orderedSolutions.First().Solution;
    3451
    3552      //if (!results.ContainsKey("Best Solution")) {
     
    3956    }
    4057
    41     public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS individual, IRandom random) {
     58    public override IEnumerable<CombinedSolution> GetNeighbors(CombinedSolution solution, IRandom random) {
    4259      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    4360      // Create new vectors, based on the given one that represent small changes
     
    4663        // Algorithm will draw only a finite amount of samples
    4764        // Change to a for-loop to return a concrete amount of neighbors
    48         var neighbor = (SOLUTION_CLASS)individual.Clone();
     65        var neighbor = (CombinedSolution)solution.Clone();
    4966        // modify the solution specified as neighbor
    5067        yield return neighbor;
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveProblem_Template.cs

    r13363 r13373  
    1616      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    1717      // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property
     18      // Encoding.Length = 100;
    1819      // Add additional initialization code e.g. private variables that you need for evaluating
    1920    }
     
    2526    }
    2627
    27     public override void Analyze(SOLUTION_CLASS[] solution, double[] qualities, ResultCollection results, IRandom random) {
     28    public override void Analyze(SOLUTION_CLASS[] solutions, double[] qualities, ResultCollection results, IRandom random) {
    2829      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2930      // Write or update results given the range of vectors and resulting qualities
    30       // Uncomment the following lines if you want to retrieve the best individual
     31      // Uncomment the following lines if you want to retrieve the best solution
    3132
    32       //var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
    33       //var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
     33      //var orderedSolutions = solutions.Zip(qualities, (i, q) => new { Solution = i, Quality = q }).OrderBy(z => z.Quality);
     34      //var best = Maximization ? orderedSolutions.Last().Solution : orderedSolutions.First().Solution;
    3435
    3536      //if (!results.ContainsKey("Best Solution")) {
     
    3940    }
    4041
    41     public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS individual, IRandom random) {
     42    public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS solution, IRandom random) {
    4243      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    4344      // Create new vectors, based on the given one that represent small changes
     
    4647        // Algorithm will draw only a finite amount of samples
    4748        // Change to a for-loop to return a concrete amount of neighbors
    48         var neighbor = (SOLUTION_CLASS)individual.Clone();
     49        var neighbor = (SOLUTION_CLASS)solution.Clone();
    4950        // modify the solution specified as neighbor
    5051        yield return neighbor;
Note: See TracChangeset for help on using the changeset viewer.