Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/07/16 10:18:05 (9 years ago)
Author:
ascheibe
Message:

#2582 created branch for Hive Web Job Manager

Location:
branches/WebJobManager
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/WebJobManager/HeuristicLab.Problems.ExternalEvaluation/3.4/EvaluationCache.cs

    r13203 r13656  
    3232using Google.ProtocolBuffers;
    3333using HeuristicLab.Common;
    34 using HeuristicLab.Common.Resources;
    3534using HeuristicLab.Core;
    3635using HeuristicLab.Data;
     
    5453      private object lockObject = new object();
    5554
    56       public byte[] RawMessage {
     55      public byte[] RawMessage
     56      {
    5757        get { return rawMessage; }
    58         set {
     58        set
     59        {
    5960          lock (lockObject) {
    6061            rawMessage = value;
     
    130131
    131132    #region Properties
    132     public static new System.Drawing.Image StaticItemImage {
    133       get { return VSImageLibrary.Database; }
    134     }
     133
    135134    public int Size { get { lock (cacheLock) return index.Count; } }
    136135    public int ActiveEvaluations { get { lock (cacheLock) return activeEvaluations.Count; } }
     
    151150
    152151    #region Parameters
    153     public FixedValueParameter<IntValue> CapacityParameter {
     152    public FixedValueParameter<IntValue> CapacityParameter
     153    {
    154154      get { return (FixedValueParameter<IntValue>)Parameters["Capacity"]; }
    155155    }
    156     public FixedValueParameter<BoolValue> PersistentCacheParameter {
     156    public FixedValueParameter<BoolValue> PersistentCacheParameter
     157    {
    157158      get { return (FixedValueParameter<BoolValue>)Parameters["PersistentCache"]; }
    158159    }
     
    160161
    161162    #region Parameter Values
    162     public int Capacity {
     163    public int Capacity
     164    {
    163165      get { return CapacityParameter.Value.Value; }
    164166      set { CapacityParameter.Value.Value = value; }
    165167    }
    166     public bool IsPersistent {
     168    public bool IsPersistent
     169    {
    167170      get { return PersistentCacheParameter.Value.Value; }
    168171    }
     
    172175    #region BackwardsCompatibility3.4
    173176    [Storable(Name = "Cache")]
    174     private IEnumerable<KeyValuePair<string, double>> Cache_Persistence_backwardscompatability {
     177    private IEnumerable<KeyValuePair<string, double>> Cache_Persistence_backwardscompatability
     178    {
    175179      get { return Enumerable.Empty<KeyValuePair<string, double>>(); }
    176       set {
     180      set
     181      {
    177182        var rawMessages = value.ToDictionary(kvp => kvp.Key,
    178183          kvp => QualityMessage.CreateBuilder()
     
    187192    #endregion
    188193    [Storable(Name = "CacheNew")]
    189     private IEnumerable<KeyValuePair<string, byte[]>> Cache_Persistence {
     194    private IEnumerable<KeyValuePair<string, byte[]>> Cache_Persistence
     195    {
    190196      get { return IsPersistent ? GetCacheValues() : Enumerable.Empty<KeyValuePair<string, byte[]>>(); }
    191197      set { SetCacheValues(value); }
     
    273279                index[entry] = list.AddLast(entry);
    274280                Trim();
    275               } finally {
     281              }
     282              finally {
    276283                if (!lockTaken)
    277284                  Monitor.Enter(cacheLock, ref lockTaken);
     
    286293          }
    287294        }
    288       } finally {
     295      }
     296      finally {
    289297        if (lockTaken)
    290298          Monitor.Exit(cacheLock);
  • branches/WebJobManager/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblem.cs

    r13500 r13656  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using System.Threading;
     
    4241  public class ExternalEvaluationProblem : SingleObjectiveBasicProblem<IEncoding>, IExternalEvaluationProblem {
    4342
    44     public static new Image StaticItemImage {
    45       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    46     }
     43
    4744
    4845    #region Parameters
    49     public OptionalValueParameter<EvaluationCache> CacheParameter {
     46    public OptionalValueParameter<EvaluationCache> CacheParameter
     47    {
    5048      get { return (OptionalValueParameter<EvaluationCache>)Parameters["Cache"]; }
    5149    }
    52     public IValueParameter<CheckedItemCollection<IEvaluationServiceClient>> ClientsParameter {
     50    public IValueParameter<CheckedItemCollection<IEvaluationServiceClient>> ClientsParameter
     51    {
    5352      get { return (IValueParameter<CheckedItemCollection<IEvaluationServiceClient>>)Parameters["Clients"]; }
    5453    }
    55     public IValueParameter<SolutionMessageBuilder> MessageBuilderParameter {
     54    public IValueParameter<SolutionMessageBuilder> MessageBuilderParameter
     55    {
    5656      get { return (IValueParameter<SolutionMessageBuilder>)Parameters["MessageBuilder"]; }
    5757    }
    58     public IFixedValueParameter<SingleObjectiveOptimizationSupportScript> SupportScriptParameter {
     58    public IFixedValueParameter<SingleObjectiveOptimizationSupportScript> SupportScriptParameter
     59    {
    5960      get { return (IFixedValueParameter<SingleObjectiveOptimizationSupportScript>)Parameters["SupportScript"]; }
    6061    }
    6162
    62     private IFixedValueParameter<BoolValue> MaximizationParameter {
     63    private IFixedValueParameter<BoolValue> MaximizationParameter
     64    {
    6365      get { return (IFixedValueParameter<BoolValue>)Parameters["Maximization"]; }
    6466    }
     
    6668
    6769    #region Properties
    68     public new IEncoding Encoding {
     70    public new IEncoding Encoding
     71    {
    6972      get { return base.Encoding; }
    7073      set { base.Encoding = value; }
    7174    }
    72     public EvaluationCache Cache {
     75    public EvaluationCache Cache
     76    {
    7377      get { return CacheParameter.Value; }
    7478    }
    75     public CheckedItemCollection<IEvaluationServiceClient> Clients {
     79    public CheckedItemCollection<IEvaluationServiceClient> Clients
     80    {
    7681      get { return ClientsParameter.Value; }
    7782    }
    78     public SolutionMessageBuilder MessageBuilder {
     83    public SolutionMessageBuilder MessageBuilder
     84    {
    7985      get { return MessageBuilderParameter.Value; }
    8086    }
    81     public SingleObjectiveOptimizationSupportScript OptimizationSupportScript {
     87    public SingleObjectiveOptimizationSupportScript OptimizationSupportScript
     88    {
    8289      get { return SupportScriptParameter.Value; }
    8390    }
    84     private ISingleObjectiveOptimizationSupport OptimizationSupport {
     91    private ISingleObjectiveOptimizationSupport OptimizationSupport
     92    {
    8593      get { return SupportScriptParameter.Value; }
    8694    }
     
    106114
    107115    #region Single Objective Problem Overrides
    108     public override bool Maximization {
     116    public override bool Maximization
     117    {
    109118      get { return Parameters.ContainsKey("Maximization") && ((IValueParameter<BoolValue>)Parameters["Maximization"]).Value.Value; }
    110119    }
     
    158167      try {
    159168        return client.Evaluate(message, GetQualityMessageExtensions());
    160       } finally {
     169      }
     170      finally {
    161171        lock (clientLock) {
    162172          activeClients.Remove(client);
     
    175185          try {
    176186            MessageBuilder.AddToMessage(variable.Value, variable.Name, protobufBuilder);
    177           } catch (ArgumentException ex) {
     187          }
     188          catch (ArgumentException ex) {
    178189            throw new InvalidOperationException(string.Format("ERROR while building solution message: Parameter {0} cannot be added to the message", Name), ex);
    179190          }
  • branches/WebJobManager/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs

    r13500 r13656  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Linq;
    2625using System.Threading;
     
    3938  public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveBasicProblem<IEncoding>, IExternalEvaluationProblem {
    4039
    41     public static new Image StaticItemImage {
    42       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    43     }
     40
    4441
    4542    #region Parameters
    46     public OptionalValueParameter<EvaluationCache> CacheParameter {
     43    public OptionalValueParameter<EvaluationCache> CacheParameter
     44    {
    4745      get { return (OptionalValueParameter<EvaluationCache>)Parameters["Cache"]; }
    4846    }
    49     public IValueParameter<CheckedItemCollection<IEvaluationServiceClient>> ClientsParameter {
     47    public IValueParameter<CheckedItemCollection<IEvaluationServiceClient>> ClientsParameter
     48    {
    5049      get { return (IValueParameter<CheckedItemCollection<IEvaluationServiceClient>>)Parameters["Clients"]; }
    5150    }
    52     public IValueParameter<SolutionMessageBuilder> MessageBuilderParameter {
     51    public IValueParameter<SolutionMessageBuilder> MessageBuilderParameter
     52    {
    5353      get { return (IValueParameter<SolutionMessageBuilder>)Parameters["MessageBuilder"]; }
    5454    }
    55     public IFixedValueParameter<MultiObjectiveOptimizationSupportScript> SupportScriptParameter {
     55    public IFixedValueParameter<MultiObjectiveOptimizationSupportScript> SupportScriptParameter
     56    {
    5657      get { return (IFixedValueParameter<MultiObjectiveOptimizationSupportScript>)Parameters["SupportScript"]; }
    5758    }
    5859
    59     private IFixedValueParameter<BoolArray> MaximizationParameter {
     60    private IFixedValueParameter<BoolArray> MaximizationParameter
     61    {
    6062      get { return (IFixedValueParameter<BoolArray>)Parameters["Maximization"]; }
    6163    }
     
    6365
    6466    #region Properties
    65     public new IEncoding Encoding {
     67    public new IEncoding Encoding
     68    {
    6669      get { return base.Encoding; }
    6770      set { base.Encoding = value; }
    6871    }
    69     public EvaluationCache Cache {
     72    public EvaluationCache Cache
     73    {
    7074      get { return CacheParameter.Value; }
    7175    }
    72     public CheckedItemCollection<IEvaluationServiceClient> Clients {
     76    public CheckedItemCollection<IEvaluationServiceClient> Clients
     77    {
    7378      get { return ClientsParameter.Value; }
    7479    }
    75     public SolutionMessageBuilder MessageBuilder {
     80    public SolutionMessageBuilder MessageBuilder
     81    {
    7682      get { return MessageBuilderParameter.Value; }
    7783    }
    78     public MultiObjectiveOptimizationSupportScript OptimizationSupportScript {
     84    public MultiObjectiveOptimizationSupportScript OptimizationSupportScript
     85    {
    7986      get { return SupportScriptParameter.Value; }
    8087    }
    81     private IMultiObjectiveOptimizationSupport OptimizationSupport {
     88    private IMultiObjectiveOptimizationSupport OptimizationSupport
     89    {
    8290      get { return SupportScriptParameter.Value; }
    8391    }
     
    101109
    102110    #region Multi Objective Problem Overrides
    103     public override bool[] Maximization {
    104       get {
     111    public override bool[] Maximization
     112    {
     113      get
     114      {
    105115        return Parameters.ContainsKey("Maximization") ? ((IValueParameter<BoolArray>)Parameters["Maximization"]).Value.ToArray() : new bool[0];
    106116      }
     
    155165      try {
    156166        return client.Evaluate(message, GetQualityMessageExtensions());
    157       } finally {
     167      }
     168      finally {
    158169        lock (clientLock) {
    159170          activeClients.Remove(client);
     
    172183          try {
    173184            MessageBuilder.AddToMessage(variable.Value, variable.Name, protobufBuilder);
    174           } catch (ArgumentException ex) {
     185          }
     186          catch (ArgumentException ex) {
    175187            throw new InvalidOperationException(string.Format("ERROR while building solution message: Parameter {0} cannot be added to the message", Name), ex);
    176188          }
Note: See TracChangeset for help on using the changeset viewer.