Changeset 14133
- Timestamp:
- 07/20/16 18:02:08 (8 years ago)
- Location:
- stable
- Files:
-
- 3 deleted
- 9 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 14037,14056-14057,14071,14100
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimization merged: 14071,14100
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Optimization.Views merged: 14071
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r13282 r14133 160 160 <DependentUpon>ExperimentListView.cs</DependentUpon> 161 161 </Compile> 162 <Compile Include="ResultParameterView.cs"> 163 <SubType>UserControl</SubType> 164 </Compile> 165 <Compile Include="ResultParameterView.Designer.cs"> 166 <DependentUpon>ResultParameterView.cs</DependentUpon> 167 </Compile> 162 168 <Compile Include="MultiEncodingView.cs"> 163 169 <SubType>UserControl</SubType> … … 399 405 <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project> 400 406 <Name>HeuristicLab.Optimization-3.3</Name> 407 <Private>False</Private> 408 </ProjectReference> 409 <ProjectReference Include="..\..\HeuristicLab.Parameters.Views\3.3\HeuristicLab.Parameters.Views-3.3.csproj"> 410 <Project>{ae5b1ce5-9862-4d6f-a700-d72cd9aea295}</Project> 411 <Name>HeuristicLab.Parameters.Views-3.3</Name> 412 <Private>False</Private> 413 </ProjectReference> 414 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 415 <Project>{56f9106a-079f-4c61-92f6-86a84c2d84b7}</Project> 416 <Name>HeuristicLab.Parameters-3.3</Name> 401 417 <Private>False</Private> 402 418 </ProjectReference> -
stable/HeuristicLab.Optimization.Views/3.3/Plugin.cs.frame
r13316 r14133 39 39 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 40 40 [PluginDependency("HeuristicLab.Optimization", "3.3")] 41 [PluginDependency("HeuristicLab.Parameters.Views", "3.3")] 41 42 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 42 43 [PluginDependency("HeuristicLab.Problems.Instances.Views", "3.3")] -
stable/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r13282 r14133 155 155 <Compile Include="Interfaces\ILocalImprovementAlgorithmOperator.cs" /> 156 156 <Compile Include="Interfaces\IMultiObjectiveOperator.cs" /> 157 <Compile Include="Results\IResultParameter.cs" /> 157 158 <Compile Include="Interfaces\ISingleObjectiveOperator.cs" /> 158 159 <Compile Include="Interfaces\ISingleObjectivePathRelinker.cs" /> … … 168 169 <Compile Include="MetaOptimizers\Experiment.cs" /> 169 170 <Compile Include="MetaOptimizers\TimeLimitRun.cs" /> 171 <Compile Include="Results\ResultParameter.cs" /> 170 172 <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" /> 171 173 <Compile Include="Plugin.cs" /> … … 229 231 <Compile Include="RunCollection.cs" /> 230 232 <Compile Include="Run.cs" /> 231 <Compile Include=" Interfaces\IResult.cs" />233 <Compile Include="Results\IResult.cs" /> 232 234 <Compile Include="Interfaces\IDiscreteDoubleValueModifier.cs" /> 233 235 <Compile Include="Interfaces\IExhaustiveMoveGenerator.cs" /> … … 253 255 <Compile Include="Interfaces\ITabuChecker.cs" /> 254 256 <Compile Include="Interfaces\ITabuMaker.cs" /> 255 <Compile Include="Result .cs" />257 <Compile Include="Results\Result.cs" /> 256 258 <Compile Include="Algorithms\UserDefinedAlgorithm.cs" /> 257 259 <Compile Include="Algorithms\EngineAlgorithm.cs" /> 258 260 <Compile Include="Properties\AssemblyInfo.cs" /> 259 <Compile Include="Result Collection.cs" />261 <Compile Include="Results\ResultCollection.cs" /> 260 262 <Compile Include="Problems\UserDefinedProblem.cs" /> 261 263 </ItemGroup> -
stable/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs
r14071 r14133 33 33 public sealed class ResultParameter<T> : LookupParameter<T>, IResultParameter<T> where T : class, IItem { 34 34 public override Image ItemImage { get { return VSImageLibrary.Exception; } } 35 public override bool CanChangeDescription { get { return true; } } 35 36 36 37 [Storable] … … 71 72 } 72 73 public ResultParameter() : this("Anonymous", string.Empty, "Results") { } 73 public ResultParameter(string name) : this(name, string.Empty, "Results") { }74 74 public ResultParameter(string name, string description) : this(name, description, "Results") { } 75 75 76 public ResultParameter(string name, string description, string resultCollectionName) 76 77 : base(name, description, string.Empty) { 77 78 if (string.IsNullOrEmpty(resultCollectionName)) throw new ArgumentException("resultCollectionName"); 78 79 this.resultCollectionName = resultCollectionName; 80 Hidden = false; 79 81 } 80 82 public ResultParameter(string name, string description, string resultCollectionName, T defaultValue) … … 84 86 this.resultCollectionName = resultCollectionName; 85 87 this.defaultValue = defaultValue; 88 Hidden = false; 86 89 } 87 90 … … 102 105 if (!results.TryGetValue(ActualName, out result)) { 103 106 if (DefaultValue == null) throw new InvalidOperationException("ResultParameter (" + ActualName + "): Result not found and no default value specified."); 104 result = new Result(ActualName, (T)DefaultValue.Clone());107 result = ItemDescription == Description ? new Result(ActualName, (T)DefaultValue.Clone()) : new Result(ActualName, Description, (T)DefaultValue.Clone()); 105 108 results.Add(result); 106 109 } … … 127 130 IResult result; 128 131 if (!results.TryGetValue(ActualName, out result)) { 129 result = new Result(ActualName, value);132 result = ItemDescription == Description ? new Result(ActualName, value) : new Result(ActualName, Description, value); 130 133 results.Add(result); 131 134 } else result.Value = value; -
stable/HeuristicLab.Parameters.Views/3.3/HeuristicLab.Parameters.Views-3.3.csproj
r11920 r14133 217 217 <Private>False</Private> 218 218 </ProjectReference> 219 <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">220 <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>221 <Name>HeuristicLab.Optimization.Views-3.3</Name>222 <Private>False</Private>223 </ProjectReference>224 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj">225 <Project>{14AB8D24-25BC-400C-A846-4627AA945192}</Project>226 <Name>HeuristicLab.Optimization-3.3</Name>227 <Private>False</Private>228 </ProjectReference>229 219 <ProjectReference Include="..\..\HeuristicLab.Parameters\3.3\HeuristicLab.Parameters-3.3.csproj"> 230 220 <Project>{56F9106A-079F-4C61-92F6-86A84C2D84B7}</Project> -
stable/HeuristicLab.Parameters/3.3/LookupParameter.cs
r12009 r14133 50 50 public string TranslatedName { 51 51 get { 52 string translatedName ;53 GetValueParameterAndTranslateName( outtranslatedName);52 string translatedName = Name; 53 GetValueParameterAndTranslateName(ExecutionContext, ref translatedName); 54 54 return translatedName; 55 55 } … … 61 61 62 62 private Lazy<ThreadLocal<IItem>> cachedActualValues; 63 pr ivateIItem CachedActualValue {63 protected IItem CachedActualValue { 64 64 get { return cachedActualValues.Value.Value; } 65 set { cachedActualValues.Value.Value = value; } 65 66 } 66 67 … … 128 129 } 129 130 130 pr ivate IValueParameter GetValueParameterAndTranslateName(out string actualName) {131 protected static IValueParameter GetValueParameterAndTranslateName(IExecutionContext executionContext, ref string translatedName) { 131 132 IValueParameter valueParam; 132 133 ILookupParameter lookupParam; 133 IExecutionContext currentExecutionContext = ExecutionContext; 134 135 actualName = Name; 134 IExecutionContext currentExecutionContext = executionContext; 135 136 136 while (currentExecutionContext != null) { 137 valueParam = currentExecutionContext.Parameters[actualName] as IValueParameter; 138 lookupParam = currentExecutionContext.Parameters[actualName] as ILookupParameter; 137 IParameter param = null; 138 while (currentExecutionContext != null && !currentExecutionContext.Parameters.TryGetValue(translatedName, out param)) 139 currentExecutionContext = currentExecutionContext.Parent; 140 if (currentExecutionContext == null) break; 141 142 valueParam = param as IValueParameter; 143 lookupParam = param as ILookupParameter; 139 144 140 145 if ((valueParam == null) && (lookupParam == null)) 141 146 throw new InvalidOperationException( 142 147 string.Format("Parameter look-up chain broken. Parameter \"{0}\" is not an \"{1}\" or an \"{2}\".", 143 actualName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName())148 translatedName, typeof(IValueParameter).GetPrettyName(), typeof(ILookupParameter).GetPrettyName()) 144 149 ); 145 150 … … 148 153 else if (lookupParam == null) return valueParam; 149 154 } 150 if (lookupParam != null) actualName = lookupParam.ActualName;155 translatedName = lookupParam.ActualName; 151 156 152 157 currentExecutionContext = currentExecutionContext.Parent; 153 while ((currentExecutionContext != null) && !currentExecutionContext.Parameters.ContainsKey(actualName))154 currentExecutionContext = currentExecutionContext.Parent;155 158 } 156 159 return null; 157 160 } 158 pr ivate IVariable LookupVariable(string name) {159 I Scope scope = ExecutionContext.Scope;160 while ( (scope != null) && !scope.Variables.ContainsKey(name))161 protected static IVariable LookupVariable(IScope scope, string name) { 162 IVariable variable = null; 163 while (scope != null && !scope.Variables.TryGetValue(name, out variable)) 161 164 scope = scope.Parent; 162 return scope != null ? scope.Variables[name] : null; 163 } 165 return scope != null ? variable : null; 166 } 167 164 168 protected override IItem GetActualValue() { 165 169 if (CachedActualValue != null) return CachedActualValue; 166 string name; 170 171 string translatedName = Name; 172 var value = GetValue(ExecutionContext, ref translatedName); 173 if (value != null && !(value is T)) 174 throw new InvalidOperationException( 175 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 176 translatedName, 177 typeof(T).GetPrettyName()) 178 ); 179 CachedActualValue = value; 180 return value; 181 } 182 183 protected static IItem GetValue(IExecutionContext executionContext, ref string name) { 167 184 // try to get value from context stack 168 IValueParameter param = GetValueParameterAndTranslateName( outname);185 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 169 186 if (param != null) return param.Value; 170 187 171 188 // try to get variable from scope 172 IVariable var = LookupVariable(name); 173 if (var != null) { 174 if (!(var.Value is T)) 175 throw new InvalidOperationException( 176 string.Format("Type mismatch. Variable \"{0}\" does not contain a \"{1}\".", 177 name, 178 typeof(T).GetPrettyName()) 179 ); 180 cachedActualValues.Value.Value = var.Value; 181 return var.Value; 182 } 183 return null; 184 } 189 IVariable var = LookupVariable(executionContext.Scope, name); 190 return var != null ? var.Value : null; 191 } 192 185 193 protected override void SetActualValue(IItem value) { 186 194 if (!(value is T)) … … 189 197 typeof(T).GetPrettyName()) 190 198 ); 191 cachedActualValues.Value.Value = value; 192 199 CachedActualValue = value; 200 201 string translatedName = Name; 202 SetValue(ExecutionContext, ref translatedName, value); 203 } 204 205 protected static void SetValue(IExecutionContext executionContext, ref string name, IItem value) { 193 206 // try to set value in context stack 194 string name; 195 IValueParameter param = GetValueParameterAndTranslateName(out name); 207 IValueParameter param = GetValueParameterAndTranslateName(executionContext, ref name); 196 208 if (param != null) { 197 209 param.Value = value; … … 200 212 201 213 // try to set value in scope 202 IVariable var = LookupVariable( name);214 IVariable var = LookupVariable(executionContext.Scope, name); 203 215 if (var != null) { 204 216 var.Value = value; … … 207 219 208 220 // create new variable 209 ExecutionContext.Scope.Variables.Add(new Variable(name, value));221 executionContext.Scope.Variables.Add(new Variable(name, value)); 210 222 } 211 223
Note: See TracChangeset
for help on using the changeset viewer.