Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/18/15 17:23:48 (9 years ago)
Author:
ascheibe
Message:

#1674 merged r13180,r13183,r13203,r13212,r13257 into stable

Location:
stable
Files:
1 deleted
5 edited
4 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledMultiObjectiveOptimizationSupport.cs

    r13183 r13259  
    1 using System;
    2 using System.Linq;
    3 using System.Collections.Generic;
    4 using HeuristicLab.Common;
    5 using HeuristicLab.Core;
    6 using HeuristicLab.Data;
     1using HeuristicLab.Core;
    72using HeuristicLab.Optimization;
    83
     
    138      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    149      // Write or update results given the range of vectors and resulting qualities
    15       // Uncomment the following lines if you want to retrieve the best individual
    16       //var bestIndex = Maximization ?
    17       //         qualities.Select((v, i) => Tuple.Create(i, v)).OrderByDescending(x => x.Item2).First().Item1
    18       //       : qualities.Select((v, i) => Tuple.Create(i, v)).OrderBy(x => x.Item2).First().Item1;
    19       //var best = individuals[bestIndex];
    2010    }
    2111
  • stable/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledSingleObjectiveOptimizationSupport.cs

    r11961 r13259  
    1 using System;
    2 using System.Linq;
    3 using System.Collections.Generic;
    4 using HeuristicLab.Common;
     1using System.Collections.Generic;
    52using HeuristicLab.Core;
    6 using HeuristicLab.Data;
    73using HeuristicLab.Optimization;
    84
     
    1410      // Write or update results given the range of vectors and resulting qualities
    1511      // Uncomment the following lines if you want to retrieve the best individual
    16       //var bestIndex = Maximization ?
    17       //         qualities.Select((v, i) => Tuple.Create(i, v)).OrderByDescending(x => x.Item2).First().Item1
    18       //       : qualities.Select((v, i) => Tuple.Create(i, v)).OrderBy(x => x.Item2).First().Item1;
    19       //var best = individuals[bestIndex];
     12      // Maximization:
     13      // var bestIndex = qualities.Select((v, i) => Tuple.Create(i, v)).OrderByDescending(x => x.Item2).First().Item1;
     14      // Minimization:
     15      // var bestIndex = qualities.Select((v, i) => Tuple.Create(i, v)).OrderBy(x => x.Item2).First().Item1;
     16      // var best = individuals[bestIndex];
    2017    }
    2118
     
    3835  }
    3936}
    40 
  • stable/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/SingleObjectiveOptimizationSupportScript.cs

    r12009 r13259  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Reflection;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    2926using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3027using HeuristicLab.Problems.ExternalEvaluation.Programmable;
    31 using HeuristicLab.Scripting;
    3228
    3329namespace HeuristicLab.Problems.ExternalEvaluation {
    3430  [Item("ProblemDefinitionScript", "Script that defines the parameter vector and evaluates the solution for a programmable problem.")]
    3531  [StorableClass]
    36   public sealed class SingleObjectiveOptimizationSupportScript : Script, ISingleObjectiveOptimizationSupport {
    37 
    38     [Storable]
    39     private VariableStore variableStore;
    40     public VariableStore VariableStore {
    41       get { return variableStore; }
    42     }
     32  public sealed class SingleObjectiveOptimizationSupportScript : OptimizationSupportScript<ISingleObjectiveOptimizationSupport>, ISingleObjectiveOptimizationSupport {
    4333
    4434    protected override string CodeTemplate {
     
    4838    [StorableConstructor]
    4939    private SingleObjectiveOptimizationSupportScript(bool deserializing) : base(deserializing) { }
    50     private SingleObjectiveOptimizationSupportScript(SingleObjectiveOptimizationSupportScript original, Cloner cloner)
    51       : base(original, cloner) {
    52       variableStore = cloner.Clone(original.variableStore);
    53     }
    54     public SingleObjectiveOptimizationSupportScript()
    55       : base() {
    56       variableStore = new VariableStore();
    57     }
     40    private SingleObjectiveOptimizationSupportScript(SingleObjectiveOptimizationSupportScript original, Cloner cloner) : base(original, cloner) { }
     41    public SingleObjectiveOptimizationSupportScript() : base() { }
    5842
    5943    public override IDeepCloneable Clone(Cloner cloner) {
    6044      return new SingleObjectiveOptimizationSupportScript(this, cloner);
    61     }
    62 
    63     private readonly object compileLock = new object();
    64     private volatile ISingleObjectiveOptimizationSupport compiledInstance;
    65     private ISingleObjectiveOptimizationSupport CompiledInstance {
    66       get {
    67         if (compiledInstance == null) {
    68           lock (compileLock) {
    69             if (compiledInstance == null) {
    70               Compile();
    71             }
    72           }
    73         }
    74         return compiledInstance;
    75       }
    76       set { compiledInstance = value; }
    77     }
    78 
    79     public override Assembly Compile() {
    80       var assembly = base.Compile();
    81       var types = assembly.GetTypes();
    82       if (!types.Any(x => typeof(CompiledOptimizationSupport).IsAssignableFrom(x)))
    83         throw new SingleObjectiveOptimizationSupportException("The compiled code doesn't contain an optimization support." + Environment.NewLine + "The support class must be a subclass of CompiledOptimizationSupport.");
    84       if (types.Count(x => typeof(CompiledOptimizationSupport).IsAssignableFrom(x)) > 1)
    85         throw new SingleObjectiveOptimizationSupportException("The compiled code contains multiple support classes." + Environment.NewLine + "Only one subclass of CompiledOptimizationSupport is allowed.");
    86 
    87       CompiledOptimizationSupport inst;
    88       try {
    89         inst = (CompiledOptimizationSupport)Activator.CreateInstance(types.Single(x => typeof(CompiledOptimizationSupport).IsAssignableFrom(x)));
    90         inst.vars = new Variables(VariableStore);
    91       } catch (Exception e) {
    92         compiledInstance = null;
    93         throw new SingleObjectiveOptimizationSupportException("Instantiating the optimization support class failed." + Environment.NewLine + "Check your default constructor.", e);
    94       }
    95 
    96       var soInst = inst as ISingleObjectiveOptimizationSupport;
    97       if (soInst == null)
    98         throw new SingleObjectiveOptimizationSupportException("The optimization support class does not implement ISingleObjectiveOptimizationSupport." + Environment.NewLine + "Please implement that interface in the subclass of CompiledOptimizationSupport.");
    99 
    100       CompiledInstance = soInst;
    101 
    102       return assembly;
    103     }
    104 
    105     protected override void OnCodeChanged() {
    106       base.OnCodeChanged();
    107       compiledInstance = null;
    10845    }
    10946
  • stable/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/Templates.Designer.cs

    r11893 r13259  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:4.0.30319.34209
     4//     Runtime Version:4.0.30319.42000
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    6868        ///using HeuristicLab.Core;
    6969        ///using HeuristicLab.Data;
    70         ///using HeuristicLab.Encodings.PermutationEncoding;
    7170        ///using HeuristicLab.Optimization;
    72         ///using HeuristicLab.Problems.Programmable;
    7371        ///
    74         ///namespace HeuristicLab.Problems.Programmable {
    75         ///  public class CompiledSingleObjectiveProblemDefinition : CompiledProblemDefinition, ISingleObjectiveProblemDefinition {
    76         ///    public bool Maximization { get { return false; } }
     72        ///namespace HeuristicLab.Problems.ExternalEvaluation {
     73        ///  public class CompiledMultiObjectiveOptimizationSupport : CompiledOptimizationSupport, IMultiObjectiveOptimizationSupport {
    7774        ///
    78         ///     [rest of string was truncated]&quot;;.
     75        ///    public void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
     76        ///      // Use vars.yourVaria [rest of string was truncated]&quot;;.
     77        /// </summary>
     78        internal static string CompiledMultiObjectiveOptimizationSupport {
     79            get {
     80                return ResourceManager.GetString("CompiledMultiObjectiveOptimizationSupport", resourceCulture);
     81            }
     82        }
     83       
     84        /// <summary>
     85        ///   Looks up a localized string similar to using System;
     86        ///using System.Linq;
     87        ///using System.Collections.Generic;
     88        ///using HeuristicLab.Common;
     89        ///using HeuristicLab.Core;
     90        ///using HeuristicLab.Data;
     91        ///using HeuristicLab.Optimization;
     92        ///
     93        ///namespace HeuristicLab.Problems.ExternalEvaluation {
     94        ///  public class CompiledSingleObjectiveOptimizationSupport : CompiledOptimizationSupport, ISingleObjectiveOptimizationSupport {
     95        ///
     96        ///    public void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     97        ///      // Use vars.yourVaria [rest of string was truncated]&quot;;.
    7998        /// </summary>
    8099        internal static string CompiledSingleObjectiveOptimizationSupport {
  • stable/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/Templates.resx

    r11893 r13259  
    119119  </resheader>
    120120  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     121  <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>
     123  </data>
    121124  <data name="CompiledSingleObjectiveOptimizationSupport" type="System.Resources.ResXFileRef, System.Windows.Forms">
    122125    <value>CompiledSingleObjectiveOptimizationSupport.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
Note: See TracChangeset for help on using the changeset viewer.