Changeset 11899
- Timestamp:
- 02/05/15 09:33:22 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblem.cs
r11893 r11899 39 39 [StorableClass] 40 40 public sealed class ExternalEvaluationProblem : SingleObjectiveBasicProblem<IEncoding> { 41 private HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>();42 private object clientLock = new object();43 41 44 42 public static new Image StaticItemImage { … … 46 44 } 47 45 46 #region Parameters 48 47 public OptionalValueParameter<EvaluationCache> CacheParameter { 49 48 get { return (OptionalValueParameter<EvaluationCache>)Parameters["Cache"]; } … … 58 57 get { return (IFixedValueParameter<SingleObjectiveOptimizationSupportScript>)Parameters["SupportScript"]; } 59 58 } 59 #endregion 60 60 61 #region Properties 61 62 public EvaluationCache Cache { 62 63 get { return CacheParameter.Value; } … … 74 75 get { return SupportScriptParameter.Value; } 75 76 } 77 #endregion 76 78 77 79 [StorableConstructor] 78 80 private ExternalEvaluationProblem(bool deserializing) : base(deserializing) { } 79 80 81 private ExternalEvaluationProblem(ExternalEvaluationProblem original, Cloner cloner) 81 82 : 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(); 87 84 } 88 85 public override IDeepCloneable Clone(Cloner cloner) { … … 95 92 Parameters.Add(new ValueParameter<SolutionMessageBuilder>("MessageBuilder", "The message builder that converts from HeuristicLab objects to SolutionMessage representation.", new SolutionMessageBuilder())); 96 93 Parameters.Add(new FixedValueParameter<SingleObjectiveOptimizationSupportScript>("SupportScript", "A script that can provide neighborhood and analyze the results of the optimization.", new SingleObjectiveOptimizationSupportScript())); 94 CompileSupportScript(); 97 95 } 98 96 99 97 [StorableHook(HookType.AfterDeserialization)] 100 98 private void AfterDeserialization() { 99 CompileSupportScript(); 100 } 101 102 private void CompileSupportScript() { 101 103 try { 102 104 OptimizationSupportScript.Compile(); … … 106 108 } 107 109 110 #region Single Objective Problem Overrides 108 111 public override bool Maximization { 109 112 get { return Parameters.ContainsKey("Maximization") && ((IValueParameter<BoolValue>)Parameters["Maximization"]).Value.Value; } … … 122 125 return OptimizationSupport.GetNeighbors(individual, random); 123 126 } 127 #endregion 124 128 129 #region Evaluation Helpers 130 private HashSet<IEvaluationServiceClient> activeClients = new HashSet<IEvaluationServiceClient>(); 131 private object clientLock = new object(); 125 132 private QualityMessage EvaluateOnNextAvailableClient(SolutionMessage message) { 126 133 IEvaluationServiceClient client = null; … … 164 171 } 165 172 } 173 #endregion 166 174 } 167 175 }
Note: See TracChangeset
for help on using the changeset viewer.