Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/05/15 10:19:37 (10 years ago)
Author:
abeham
Message:

#2174:

  • Removed compilation calls from the problem (AfterDeserialization and in cloning constructor) and instead compile instance lazily when accessed
  • Compile support code in ExternalEvaluationProblem lazy
  • Fixed encoding class names in template code files (forgot to add vector)
Location:
branches/ProgrammableProblem/HeuristicLab.Problems.ExternalEvaluation/3.4
Files:
2 edited

Legend:

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

    r11899 r11900  
    7979    [StorableConstructor]
    8080    private ExternalEvaluationProblem(bool deserializing) : base(deserializing) { }
    81     private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner)
    82       : base(original, cloner) {
    83       CompileSupportScript();
    84     }
     81    private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner) : base(original, cloner) { }
    8582    public override IDeepCloneable Clone(Cloner cloner) {
    8683      return new ExternalEvaluationProblem(this, cloner);
     
    9289      Parameters.Add(new ValueParameter<SolutionMessageBuilder>("MessageBuilder", "The message builder that converts from HeuristicLab objects to SolutionMessage representation.", new SolutionMessageBuilder()));
    9390      Parameters.Add(new FixedValueParameter<SingleObjectiveOptimizationSupportScript>("SupportScript", "A script that can provide neighborhood and analyze the results of the optimization.", new SingleObjectiveOptimizationSupportScript()));
    94       CompileSupportScript();
    95     }
    96 
    97     [StorableHook(HookType.AfterDeserialization)]
    98     private void AfterDeserialization() {
    99       CompileSupportScript();
    100     }
    101 
    102     private void CompileSupportScript() {
    103       try {
    104         OptimizationSupportScript.Compile();
    105       } catch (SingleObjectiveOptimizationSupportException ex) {
    106         PluginInfrastructure.ErrorHandling.ShowErrorDialog("Support script doesn't compile.", ex);
    107       }
    10891    }
    10992
  • branches/ProgrammableProblem/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/SingleObjectiveOptimizationSupportScript.cs

    r11893 r11900  
    6262    }
    6363
     64    private readonly object compileLock = new object();
    6465    private volatile ISingleObjectiveOptimizationSupport compiledInstance;
    6566    private ISingleObjectiveOptimizationSupport CompiledInstance {
    6667      get {
    67         if (compiledInstance == null) throw new InvalidOperationException("The problem definition script is not compiled and cannot be used.");
     68        if (compiledInstance == null) {
     69          lock (compileLock) {
     70            if (compiledInstance == null) {
     71              Compile();
     72            }
     73          }
     74        }
    6875        return compiledInstance;
    6976      }
Note: See TracChangeset for help on using the changeset viewer.