Changeset 16816


Ignore:
Timestamp:
04/18/19 14:06:00 (4 months ago)
Author:
abeham
Message:

#2521: Refactored external evaluation problem

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4
Files:
8 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/HeuristicLab.Problems.ExternalEvaluation-3.4.csproj

    r16723 r16816  
    137137    <Compile Include="Interfaces\IMultiObjectiveOptimizationSupport.cs" />
    138138    <Compile Include="MultiObjectiveExternalEvaluationProblem.cs" />
    139     <Compile Include="ExternalEvaluationProblem.cs" />
     139    <Compile Include="ExternalEvaluationProblemInstances.cs" />
     140    <Compile Include="SingleObjectiveExternalEvaluationProblem.cs" />
    140141    <Compile Include="Interfaces\IEvaluationServiceClient.cs" />
    141142    <Compile Include="Interfaces\IEvaluationChannel.cs" />
     
    144145    <Compile Include="Plugin.cs" />
    145146    <Compile Include="Programmable\CompiledOptimizationSupport.cs" />
    146     <Compile Include="Programmable\CompiledMultiObjectiveOptimizationSupport.cs" />
    147     <Compile Include="Programmable\CompiledSingleObjectiveOptimizationSupport.cs" />
    148     <Compile Include="Programmable\MultiObjectiveOptimizationSupportScript.cs" />
     147    <Content Include="Programmable\MultiObjective\CompiledMultiObjectiveOptimizationSupport.cs" />
     148    <Content Include="Programmable\SingleObjective\CompiledSingleObjectiveOptimizationSupport.cs" />
     149    <Compile Include="Programmable\MultiObjective\MultiObjectiveOptimizationSupportScript.cs" />
    149150    <Compile Include="Programmable\OptimizationSupportScript.cs" />
    150     <Compile Include="Programmable\SingleObjectiveOptimizationSupportScript.cs" />
     151    <Compile Include="Programmable\SingleObjective\SingleObjectiveOptimizationSupportScript.cs" />
    151152    <Compile Include="Programmable\OptimizationSupportScriptException.cs" />
    152153    <Compile Include="Programmable\Templates.Designer.cs">
     
    187188      <Generator>ResXFileCodeGenerator</Generator>
    188189      <LastGenOutput>Templates.Designer.cs</LastGenOutput>
     190      <SubType>Designer</SubType>
    189191    </EmbeddedResource>
    190192  </ItemGroup>
     
    218220      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
    219221      <Name>HeuristicLab.Data-3.3</Name>
     222      <Private>False</Private>
     223    </ProjectReference>
     224    <ProjectReference Include="..\..\HeuristicLab.Encodings.BinaryVectorEncoding\3.3\HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj">
     225      <Project>{66d249c3-a01d-42a8-82a2-919bc8ec3d83}</Project>
     226      <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
     227      <Private>False</Private>
     228    </ProjectReference>
     229    <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
     230      <Project>{ddfb14dd-2a85-493c-a52d-e69729bbaeb0}</Project>
     231      <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
     232      <Private>False</Private>
     233    </ProjectReference>
     234    <ProjectReference Include="..\..\HeuristicLab.Encodings.LinearLinkageEncoding\3.4\HeuristicLab.Encodings.LinearLinkageEncoding-3.4.csproj">
     235      <Project>{be698769-975a-429e-828c-72bb2b6182c8}</Project>
     236      <Name>HeuristicLab.Encodings.LinearLinkageEncoding-3.4</Name>
     237      <Private>False</Private>
     238    </ProjectReference>
     239    <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
     240      <Project>{dbecb8b0-b166-4133-baf1-ed67c3fd7fca}</Project>
     241      <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
     242      <Private>False</Private>
     243    </ProjectReference>
     244    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
     245      <Project>{bb6d334a-4bb6-4674-9883-31a6ebb32cab}</Project>
     246      <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
     247      <Private>False</Private>
     248    </ProjectReference>
     249    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
     250      <Project>{06d4a186-9319-48a0-bade-a2058d462eea}</Project>
     251      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
    220252      <Private>False</Private>
    221253    </ProjectReference>
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/IMultiObjectiveOptimizationSupport.cs

    r16751 r16816  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Optimization;
    24 using HEAL.Attic;
    2525
    2626namespace HeuristicLab.Problems.ExternalEvaluation {
    2727  [StorableType("f924ef9c-d824-40d2-89b2-6dd1220df98b")]
    28   public interface IMultiObjectiveOptimizationSupport {
    29     void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
     28  public interface IMultiObjectiveOptimizationSupport<TEncodedSolution> {
     29    void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
    3030  }
    3131}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/ISingleObjectiveOptimizationSupport.cs

    r16751 r16816  
    2121
    2222using System.Collections.Generic;
     23using HEAL.Attic;
     24using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.Optimization;
    25 using HEAL.Attic;
    2627
    2728namespace HeuristicLab.Problems.ExternalEvaluation {
    2829  [StorableType("09d522e0-c10f-474c-b7c0-7d7f98e63f44")]
    29   public interface ISingleObjectiveOptimizationSupport {
    30     void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
    31     IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random);
     30  public interface ISingleObjectiveOptimizationSupport<TEncodedSolution>
     31    where TEncodedSolution : IDeepCloneable {
     32
     33    void Analyze(TEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
     34    IEnumerable<TEncodedSolution> GetNeighbors(TEncodedSolution individual, IRandom random);
    3235  }
    3336}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs

    r16751 r16816  
    2626using System.Threading;
    2727using Google.ProtocolBuffers;
     28using HEAL.Attic;
    2829using HeuristicLab.Common;
    2930using HeuristicLab.Core;
     
    3132using HeuristicLab.Optimization;
    3233using HeuristicLab.Parameters;
    33 using HEAL.Attic;
    3434
    3535namespace HeuristicLab.Problems.ExternalEvaluation {
     
    3737  [Creatable(CreatableAttribute.Categories.ExternalEvaluationProblems, Priority = 200)]
    3838  [StorableType("CCA50199-A6AB-4C84-B4FA-0262CAF416EC")]
    39   public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<IEncodedSolution>, IEncodedSolution>, IExternalEvaluationProblem {
     39  public class MultiObjectiveExternalEvaluationProblem<TEncoding, TEncodedSolution> : MultiObjectiveProblem<TEncoding, TEncodedSolution>, IExternalEvaluationProblem
     40    where TEncoding : class, IEncoding<TEncodedSolution>
     41    where TEncodedSolution : class, IEncodedSolution {
    4042
    4143    public static new Image StaticItemImage {
     
    5355      get { return (IValueParameter<SolutionMessageBuilder>)Parameters["MessageBuilder"]; }
    5456    }
    55     public IFixedValueParameter<MultiObjectiveOptimizationSupportScript> SupportScriptParameter {
    56       get { return (IFixedValueParameter<MultiObjectiveOptimizationSupportScript>)Parameters["SupportScript"]; }
    57     }
    58 
    59     private IFixedValueParameter<BoolArray> MaximizationParameter {
    60       get { return (IFixedValueParameter<BoolArray>)Parameters["Maximization"]; }
     57    public IFixedValueParameter<MultiObjectiveOptimizationSupportScript<TEncodedSolution>> SupportScriptParameter {
     58      get { return (IFixedValueParameter<MultiObjectiveOptimizationSupportScript<TEncodedSolution>>)Parameters["SupportScript"]; }
    6159    }
    6260    #endregion
    6361
    6462    #region Properties
    65     public new IEncoding<IEncodedSolution> Encoding {
     63    public new TEncoding Encoding {
    6664      get { return base.Encoding; }
    6765      set { base.Encoding = value; }
     
    7674      get { return MessageBuilderParameter.Value; }
    7775    }
    78     public MultiObjectiveOptimizationSupportScript OptimizationSupportScript {
     76    public MultiObjectiveOptimizationSupportScript<TEncodedSolution> OptimizationSupportScript {
    7977      get { return SupportScriptParameter.Value; }
    8078    }
    81     private IMultiObjectiveOptimizationSupport OptimizationSupport {
     79    private IMultiObjectiveOptimizationSupport<TEncodedSolution> OptimizationSupport {
    8280      get { return SupportScriptParameter.Value; }
    8381    }
     
    8684    [StorableConstructor]
    8785    protected MultiObjectiveExternalEvaluationProblem(StorableConstructorFlag _) : base(_) { }
    88     protected MultiObjectiveExternalEvaluationProblem(MultiObjectiveExternalEvaluationProblem original, Cloner cloner) : base(original, cloner) { }
     86    protected MultiObjectiveExternalEvaluationProblem(MultiObjectiveExternalEvaluationProblem<TEncoding, TEncodedSolution> original, Cloner cloner) : base(original, cloner) { }
    8987    public override IDeepCloneable Clone(Cloner cloner) {
    90       return new MultiObjectiveExternalEvaluationProblem(this, cloner);
     88      return new MultiObjectiveExternalEvaluationProblem<TEncoding, TEncodedSolution>(this, cloner);
    9189    }
    92     public MultiObjectiveExternalEvaluationProblem()
    93       : base() {
     90    public MultiObjectiveExternalEvaluationProblem(TEncoding encoding)
     91      : base(encoding) {
    9492      Parameters.Remove("Maximization"); // readonly in base class
    9593      Parameters.Add(new FixedValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", new BoolArray()));
     
    9795      Parameters.Add(new ValueParameter<CheckedItemCollection<IEvaluationServiceClient>>("Clients", "The clients that are used to communicate with the external application.", new CheckedItemCollection<IEvaluationServiceClient>() { new EvaluationServiceClient() }));
    9896      Parameters.Add(new ValueParameter<SolutionMessageBuilder>("MessageBuilder", "The message builder that converts from HeuristicLab objects to SolutionMessage representation.", new SolutionMessageBuilder()) { Hidden = true });
    99       Parameters.Add(new FixedValueParameter<MultiObjectiveOptimizationSupportScript>("SupportScript", "A script that can analyze the results of the optimization.", new MultiObjectiveOptimizationSupportScript()));
     97      Parameters.Add(new FixedValueParameter<MultiObjectiveOptimizationSupportScript<TEncodedSolution>>("SupportScript", "A script that can analyze the results of the optimization.", new MultiObjectiveOptimizationSupportScript<TEncodedSolution>()));
    10098    }
    10199
     
    114112    }
    115113
    116     public override double[] Evaluate(IEncodedSolution individual, IRandom random) {
     114    public override double[] Evaluate(TEncodedSolution individual, IRandom random) {
    117115      var qualityMessage = Evaluate(BuildSolutionMessage(individual));
    118116      if (!qualityMessage.HasExtension(MultiObjectiveQualityMessage.QualityMessage_))
     
    126124    }
    127125
    128     public override void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     126    public override void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    129127      OptimizationSupport.Analyze(individuals, qualities, results, random);
    130128    }
     
    164162    }
    165163
    166     private SolutionMessage BuildSolutionMessage(IEncodedSolution solution, int solutionId = 0) {
     164    private SolutionMessage BuildSolutionMessage(TEncodedSolution solution, int solutionId = 0) {
    167165      lock (clientLock) {
    168166        SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Plugin.cs.frame

    r16723 r16816  
    3232  [PluginDependency("HeuristicLab.Core", "3.3")]
    3333  [PluginDependency("HeuristicLab.Data", "3.3")]
     34  [PluginDependency("HeuristicLab.Encodings.RealVectorEncoding", "3.3")]
    3435  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    3536  [PluginDependency("HeuristicLab.Parameters", "3.3")]
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/Templates.Designer.cs

    r13183 r16816  
    2020    // To add or remove a member, edit your .ResX file then rerun ResGen
    2121    // with the /str option, or rebuild your VS project.
    22     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
     22    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
    2323    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    2424    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
     
    6262       
    6363        /// <summary>
    64         ///   Looks up a localized string similar to using System;
    65         ///using System.Linq;
    66         ///using System.Collections.Generic;
    67         ///using HeuristicLab.Common;
    68         ///using HeuristicLab.Core;
    69         ///using HeuristicLab.Data;
     64        ///   Looks up a localized string similar to using HeuristicLab.Core;
    7065        ///using HeuristicLab.Optimization;
     66        ///using ENCODING_NAMESPACE;
    7167        ///
    7268        ///namespace HeuristicLab.Problems.ExternalEvaluation {
    73         ///  public class CompiledMultiObjectiveOptimizationSupport : CompiledOptimizationSupport, IMultiObjectiveOptimizationSupport {
     69        ///  public class CompiledMultiObjectiveOptimizationSupport : CompiledOptimizationSupport, IMultiObjectiveOptimizationSupport&lt;SOLUTION_CLASS&gt; {
    7470        ///
    75         ///    public void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    76         ///      // Use vars.yourVaria [rest of string was truncated]&quot;;.
     71        ///    public void Analyze(SOLUTION_CLASS[] solutions, double[][] qualities, ResultCollection results, IRandom random) {
     72        ///      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
     73        ///      // Write [rest of string was truncated]&quot;;.
    7774        /// </summary>
    7875        internal static string CompiledMultiObjectiveOptimizationSupport {
     
    8380       
    8481        /// <summary>
    85         ///   Looks up a localized string similar to using System;
    86         ///using System.Linq;
    87         ///using System.Collections.Generic;
     82        ///   Looks up a localized string similar to using System.Collections.Generic;
    8883        ///using HeuristicLab.Common;
    8984        ///using HeuristicLab.Core;
    90         ///using HeuristicLab.Data;
    9185        ///using HeuristicLab.Optimization;
     86        ///using ENCODING_NAMESPACE;
    9287        ///
    9388        ///namespace HeuristicLab.Problems.ExternalEvaluation {
    94         ///  public class CompiledSingleObjectiveOptimizationSupport : CompiledOptimizationSupport, ISingleObjectiveOptimizationSupport {
     89        ///  public class CompiledSingleObjectiveOptimizationSupport : CompiledOptimizationSupport, ISingleObjectiveOptimizationSupport&lt;SOLUTION_CLASS&gt; {
    9590        ///
    96         ///    public void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
    97         ///      // Use vars.yourVaria [rest of string was truncated]&quot;;.
     91        ///    public void Analyze(SOLUTION_CLASS[] solutions, double[] qualities, ResultCollection results, IRandom random) {
     92        ///      // Use vars.yourVariable to access va [rest of string was truncated]&quot;;.
    9893        /// </summary>
    9994        internal static string CompiledSingleObjectiveOptimizationSupport {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/Templates.resx

    r13183 r16816  
    120120  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    121121  <data name="CompiledMultiObjectiveOptimizationSupport" type="System.Resources.ResXFileRef, System.Windows.Forms">
    122     <value>compiledmultiobjectiveoptimizationsupport.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     122    <value>MultiObjective\CompiledMultiObjectiveOptimizationSupport.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    123123  </data>
    124124  <data name="CompiledSingleObjectiveOptimizationSupport" type="System.Resources.ResXFileRef, System.Windows.Forms">
    125     <value>CompiledSingleObjectiveOptimizationSupport.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
     125    <value>SingleObjective\CompiledSingleObjectiveOptimizationSupport.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    126126  </data>
    127127</root>
Note: See TracChangeset for help on using the changeset viewer.