Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11899


Ignore:
Timestamp:
02/05/15 09:33:22 (8 years ago)
Author:
abeham
Message:

#2174:

  • Added regions to structure code
  • Added compile call to the default creator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProgrammableProblem/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblem.cs

    r11893 r11899  
    3939  [StorableClass]
    4040  public sealed class ExternalEvaluationProblem : SingleObjectiveBasicProblem<IEncoding> {
    41     private HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>();
    42     private object clientLock = new object();
    4341
    4442    public static new Image StaticItemImage {
     
    4644    }
    4745
     46    #region Parameters
    4847    public OptionalValueParameter<EvaluationCache> CacheParameter {
    4948      get { return (OptionalValueParameter<EvaluationCache>)Parameters["Cache"]; }
     
    5857      get { return (IFixedValueParameter<SingleObjectiveOptimizationSupportScript>)Parameters["SupportScript"]; }
    5958    }
     59    #endregion
    6060
     61    #region Properties
    6162    public EvaluationCache Cache {
    6263      get { return CacheParameter.Value; }
     
    7475      get { return SupportScriptParameter.Value; }
    7576    }
     77    #endregion
    7678
    7779    [StorableConstructor]
    7880    private ExternalEvaluationProblem(bool deserializing) : base(deserializing) { }
    79 
    8081    private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner)
    8182      : base(original, cloner) {
    82       try {
    83         OptimizationSupportScript.Compile();
    84       } catch (SingleObjectiveOptimizationSupportException ex) {
    85         PluginInfrastructure.ErrorHandling.ShowErrorDialog("Support script doesn't compile.", ex);
    86       }
     83      CompileSupportScript();
    8784    }
    8885    public override IDeepCloneable Clone(Cloner cloner) {
     
    9592      Parameters.Add(new ValueParameter<SolutionMessageBuilder>("MessageBuilder", "The message builder that converts from HeuristicLab objects to SolutionMessage representation.", new SolutionMessageBuilder()));
    9693      Parameters.Add(new FixedValueParameter<SingleObjectiveOptimizationSupportScript>("SupportScript", "A script that can provide neighborhood and analyze the results of the optimization.", new SingleObjectiveOptimizationSupportScript()));
     94      CompileSupportScript();
    9795    }
    9896
    9997    [StorableHook(HookType.AfterDeserialization)]
    10098    private void AfterDeserialization() {
     99      CompileSupportScript();
     100    }
     101
     102    private void CompileSupportScript() {
    101103      try {
    102104        OptimizationSupportScript.Compile();
     
    106108    }
    107109
     110    #region Single Objective Problem Overrides
    108111    public override bool Maximization {
    109112      get { return Parameters.ContainsKey("Maximization") && ((IValueParameter<BoolValue>)Parameters["Maximization"]).Value.Value; }
     
    122125      return OptimizationSupport.GetNeighbors(individual, random);
    123126    }
     127    #endregion
    124128
     129    #region Evaluation Helpers
     130    private HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>();
     131    private object clientLock = new object();
    125132    private QualityMessage EvaluateOnNextAvailableClient(SolutionMessage message) {
    126133      IEvaluationServiceClient client = null;
     
    164171      }
    165172    }
     173    #endregion
    166174  }
    167175}
Note: See TracChangeset for help on using the changeset viewer.