Changeset 9748 for branches/HeuristicLab.ExternalEvaluation Scientific/HeuristicLab.Problems.ExternalEvaluation.Matlab/3.3/MatlabParameterVectorEvaluator.cs
- Timestamp:
- 07/24/13 14:53:19 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.ExternalEvaluation Scientific/HeuristicLab.Problems.ExternalEvaluation.Matlab/3.3/MatlabParameterVectorEvaluator.cs
r9715 r9748 30 30 31 31 namespace HeuristicLab.Problems.ExternalEvaluation.Matlab { 32 [Item("M atLabParameterVectorEvaluator", "An evaluator which takes a parameter vector and returns a quality value, calculated by a Scilab script.")]32 [Item("MATLABParameterVectorEvaluator", "An evaluator which takes a parameter vector and returns a quality value, calculated by a Scilab script.")] 33 33 [StorableClass] 34 34 public sealed class MatlabParameterVectorEvaluator : ParameterVectorEvaluator { 35 35 private const string QualityVariableParameterName = "QualityVariableName"; 36 private const string MatlabEvaluationScriptParameterName = "M atlabEvaluationScript";36 private const string MatlabEvaluationScriptParameterName = "MATLABEvaluationScript"; 37 37 private const string InitializationScriptParameterName = "InitializationScript"; 38 38 … … 64 64 public MatlabParameterVectorEvaluator() 65 65 : base() { 66 Parameters.Add(new LookupParameter<StringValue>(QualityVariableParameterName, "The name of the quality variable of the Matlab script.")); 67 Parameters.Add(new LookupParameter<TextFileValue>(MatlabEvaluationScriptParameterName, "The path to the Matlab evaluation script.")); 68 Parameters.Add(new FixedValueParameter<TextFileValue>(InitializationScriptParameterName, "The path to a Matlab script the should be execute before the evaluation starts.", new TextFileValue())); 69 } 70 71 [StorableHook(HookType.AfterDeserialization)] 72 private void AfterDeserialization() { 73 InitializeState(); 66 Parameters.Add(new LookupParameter<StringValue>(QualityVariableParameterName, "The name of the quality variable calculated in the MATLAB script.")); 67 Parameters.Add(new LookupParameter<TextFileValue>(MatlabEvaluationScriptParameterName, "The path to the MATLAB evaluation script.")); 68 Parameters.Add(new FixedValueParameter<TextFileValue>(InitializationScriptParameterName, "The path to a MATLAB script the should be execute before the evaluation starts.", new TextFileValue())); 74 69 } 75 70 … … 89 84 90 85 string initScript = InitializationScript.Value; 91 string result = matLabConnector.Execute("cd " + Path.GetDirectoryName(initScript)); 86 var directoryName = Path.GetDirectoryName(initScript); 87 string result = matLabConnector.Execute(string.Format("cd '{0}'", directoryName)); 92 88 if (!string.IsNullOrEmpty(result)) throw new InvalidOperationException(result); 93 89 … … 110 106 111 107 lock (locker) { 108 if (matLabConnector == null) InitializeState(); 109 112 110 string result; 113 111 string script = evaluationScript.Value; 114 112 115 113 if (!changedDirectory) { 116 result = matLabConnector.Execute("cd " + Path.GetDirectoryName(script)); 114 var directoryName = Path.GetDirectoryName(script); 115 result = matLabConnector.Execute(string.Format("cd '{0}'", directoryName)); 117 116 if (!string.IsNullOrEmpty(result)) throw new InvalidOperationException(result); 118 117 changedDirectory = true;
Note: See TracChangeset
for help on using the changeset viewer.