Changeset 11151 for stable/HeuristicLab.Problems.ExternalEvaluation.Scilab/3.3/ScilabParameterVectorEvaluator.cs
- Timestamp:
- 07/08/14 20:02:59 (10 years ago)
- Location:
- stable
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
/trunk/sources merged: 10601-10607,10653,11075-11077,11080-11081
- Property svn:ignore
-
stable/HeuristicLab.Problems.ExternalEvaluation.Scilab/3.3/ScilabParameterVectorEvaluator.cs
r10605 r11151 35 35 [StorableClass] 36 36 public sealed class ScilabParameterVectorEvaluator : ParameterVectorEvaluator { 37 private const string MaximizationParameterName = "Maximization"; 37 38 private const string QualityVariableParameterName = "QualityVariableName"; 38 39 private const string ScilabEvaluationScriptParameterName = "ScilabEvaluationScript"; … … 40 41 41 42 #region parameters 43 public ILookupParameter<BoolValue> MaximizationParameter { 44 get { return (ILookupParameter<BoolValue>)Parameters[MaximizationParameterName]; } 45 } 42 46 public ILookupParameter<StringValue> QualityVariableParameter { 43 47 get { return (ILookupParameter<StringValue>)Parameters[QualityVariableParameterName]; } … … 62 66 public ScilabParameterVectorEvaluator() 63 67 : base() { 68 Parameters.Add(new LookupParameter<BoolValue>(MaximizationParameterName, "The flag which determines if this is a maximization problem.")); 64 69 Parameters.Add(new LookupParameter<StringValue>(QualityVariableParameterName, "The name of the quality variable of the Scilab script.")); 65 70 Parameters.Add(new LookupParameter<TextFileValue>(ScilabEvaluationScriptParameterName, "The path to the Scilab evaluation script.")); 66 Parameters.Add(new LookupParameter<TextFileValue>(ScilabInitializationScriptParameterName, "The path to a Scilab script th e should be execute before the evaluationstarts."));71 Parameters.Add(new LookupParameter<TextFileValue>(ScilabInitializationScriptParameterName, "The path to a Scilab script that should be executed once when the algorithm starts.")); 67 72 } 68 73 69 private readonly object locker = new object();74 private static readonly object locker = new object(); 70 75 private static ScilabConnector scilab = null; 71 76 private bool startedScilab = false; … … 80 85 81 86 int result; 82 //Scilab is used via a c++ wrapper that calls static methods. Hence it is not possible to parallelize the evaluation. 87 // Scilab is used via a c++ wrapper that calls static methods. Hence it is not possible to parallelize the evaluation. 88 // It is also not possible to run multiple algorithms solving separate Scilab optimization problems at the same time. 83 89 lock (locker) { 84 90 //initialize scilab and execute initialization script … … 96 102 var parameterVector = ParameterVectorParameter.ActualValue; 97 103 var parameterNames = ParameterNamesParameter.ActualValue; 98 if (parameterNames.Any(string.IsNullOrEmpty)) throw new ArgumentException("Not all parameter names are provided."); 104 if (parameterNames.Any(string.IsNullOrEmpty)) throw new ArgumentException("Not all parameter names are provided. Change the 'ParameterNames' parameter in the 'Problem' tab."); 105 if (ProblemSizeParameter.ActualValue.Value != parameterVector.Length || ProblemSizeParameter.ActualValue.Value != parameterNames.Length) 106 throw new ArgumentException("The size of the parameter vector or the parameter names vector does not match the problem size."); 99 107 100 108 for (int i = 0; i < ProblemSizeParameter.ActualValue.Value; i++) { … … 112 120 double quality = values[0]; 113 121 114 if (double.IsNaN(quality)) quality = double.MaxValue; 115 if (double.IsInfinity(quality)) quality = double.MaxValue; 122 var worstQualityValue = MaximizationParameter.ActualValue.Value ? double.MinValue : double.MaxValue; 123 if (double.IsNaN(quality)) quality = worstQualityValue; 124 if (double.IsInfinity(quality)) quality = worstQualityValue; 116 125 117 126 QualityParameter.ActualValue = new DoubleValue(quality);
Note: See TracChangeset
for help on using the changeset viewer.