Changeset 17594
- Timestamp:
- 06/10/20 12:15:23 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 16 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs
r17517 r17594 31 31 using HeuristicLab.Encodings.BinaryVectorEncoding; 32 32 using HeuristicLab.Optimization; 33 33 34 using HeuristicLab.Parameters; 34 35 using HeuristicLab.Random; … … 47 48 48 49 [Storable] public IFixedValueParameter<IntValue> MaximumIterationsParameter { get; private set; } 49 [Storable] public IResultParameter<DoubleValue> BestQualityResultParameter { get; private set; } 50 [Storable] public IResultParameter<IntValue> IterationsResultParameter { get; private set; } 50 51 [Storable] public IResult<DoubleValue> BestQualityResult { get; private set; } 52 [Storable] public IResult<IntValue> IterationsResult { get; private set; } 51 53 52 54 public override Type ProblemType { … … 70 72 : base(original, cloner) { 71 73 MaximumIterationsParameter = cloner.Clone(original.MaximumIterationsParameter); 72 BestQualityResult Parameter = cloner.Clone(original.BestQualityResultParameter);73 IterationsResult Parameter = cloner.Clone(original.IterationsResultParameter);74 BestQualityResult = cloner.Clone(original.BestQualityResult); 75 IterationsResult = cloner.Clone(original.IterationsResult); 74 76 } 75 77 public override IDeepCloneable Clone(Cloner cloner) { … … 81 83 random = new MersenneTwister(); 82 84 Parameters.Add(MaximumIterationsParameter = new FixedValueParameter<IntValue>("Maximum Iterations", "", new IntValue(100))); 83 Parameters.Add(BestQualityResultParameter = new ResultParameter<DoubleValue>("Best Quality", "", "Results", new DoubleValue(double.NaN))); 84 Parameters.Add(IterationsResultParameter = new ResultParameter<IntValue>("Iterations", "", "Results", new IntValue(0))); 85 86 Results.Add(BestQualityResult = new Result<DoubleValue>("Best Quality")); 87 Results.Add(IterationsResult = new Result<IntValue>("Iterations")); 85 88 } 86 89 90 91 87 92 protected override void Run(CancellationToken cancellationToken) { 88 while (IterationsResultParameter.ActualValue.Value < MaximumIterations) { 93 IterationsResult.Value = new IntValue(); 94 BestQualityResult.Value = new DoubleValue(double.NaN); 95 96 while (IterationsResult.Value.Value < MaximumIterations) { 89 97 cancellationToken.ThrowIfCancellationRequested(); 90 98 … … 98 106 99 107 fitness = ImproveToLocalOptimum(Problem, solution, fitness, random); 100 var bestSoFar = BestQualityResult Parameter.ActualValue.Value;108 var bestSoFar = BestQualityResult.Value.Value; 101 109 if (double.IsNaN(bestSoFar) || Problem.IsBetter(fitness, bestSoFar)) { 102 BestQualityResult Parameter.ActualValue.Value = fitness;110 BestQualityResult.Value.Value = fitness; 103 111 } 104 112 105 IterationsResult Parameter.ActualValue.Value++;113 IterationsResult.Value.Value++; 106 114 } 107 115 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs
r17570 r17594 33 33 public abstract class BinaryVectorMultiObjectiveProblem : MultiObjectiveProblem<BinaryVectorEncoding, BinaryVector> { 34 34 [Storable] protected IResultParameter<ParetoFrontScatterPlot<BinaryVector>> BestResultParameter { get; private set; } 35 public IResultDefinition<ParetoFrontScatterPlot<BinaryVector>> BestResult { get { return BestResultParameter; }}35 //public IResultDefinition<ParetoFrontScatterPlot<BinaryVector>> BestResult { get { return BestResultParameter; }} 36 36 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 37 37 … … 73 73 var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); 74 74 var plot = new ParetoFrontScatterPlot<BinaryVector>(fronts, individuals, qualities, Objectives, BestKnownFront); 75 75 76 76 BestResultParameter.ActualValue = plot; 77 77 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
r17577 r17594 34 34 public abstract class BinaryVectorProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> { 35 35 [Storable] protected IResultParameter<ISingleObjectiveSolutionContext<BinaryVector>> BestResultParameter { get; private set; } 36 public IResultDefinition<ISingleObjectiveSolutionContext<BinaryVector>> BestResult => BestResultParameter;36 //public IResultDefinition<ISingleObjectiveSolutionContext<BinaryVector>> BestResult => BestResultParameter; 37 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 38 … … 75 75 var currentBest = BestResultParameter.ActualValue; 76 76 if (currentBest == null || IsBetter(best.EvaluationResult.Quality, currentBest.EvaluationResult.Quality)) 77 BestResultParameter.ActualValue = new SingleObjectiveSolutionContext<BinaryVector>( 78 (BinaryVector)best.EncodedSolution.Clone(), (ISingleObjectiveEvaluationResult)best.EvaluationResult.Clone()); 77 BestResultParameter.ActualValue = best.Clone() as SingleObjectiveSolutionContext<BinaryVector>; 79 78 } 80 79 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs
r17587 r17594 35 35 public abstract class IntegerVectorMultiObjectiveProblem : MultiObjectiveProblem<IntegerVectorEncoding, IntegerVector> { 36 36 [Storable] protected IResultParameter<ParetoFrontScatterPlot<IntegerVector>> BestResultParameter { get; private set; } 37 public IResultDefinition<ParetoFrontScatterPlot<IntegerVector>> BestResult { get { return BestResultParameter; } }37 //public IResultDefinition<ParetoFrontScatterPlot<IntegerVector>> BestResult { get { return BestResultParameter; } } 38 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 39 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs
r17587 r17594 36 36 public abstract class IntegerVectorProblem : SingleObjectiveProblem<IntegerVectorEncoding, IntegerVector> { 37 37 [Storable] protected IResultParameter<IntegerVector> BestResultParameter { get; private set; } 38 public IResultDefinition<IntegerVector> BestResult { get => BestResultParameter; }38 //public IResultDefinition<IntegerVector> BestResult { get => BestResultParameter; } 39 39 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 40 40 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Algorithms/Algorithm.cs
r17517 r17594 202 202 if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped)) 203 203 throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState)); 204 results.Clear(); 204 205 Results.Reset(); 205 206 } 206 207 public void Prepare(bool clearRuns) { -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj
r17587 r17594 181 181 <Compile Include="MetaOptimizers\Experiment.cs" /> 182 182 <Compile Include="MetaOptimizers\TimeLimitRun.cs" /> 183 <Compile Include="Results\ResultDefinition.cs" /> 183 184 <Compile Include="Results\ResultParameter.cs" /> 184 185 <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/IResult.cs
r17226 r17594 21 21 22 22 using System; 23 using HEAL.Attic; 23 24 using HeuristicLab.Core; 24 using HEAL.Attic;25 25 26 26 namespace HeuristicLab.Optimization { 27 [StorableType("62D2A0C2-52A0-4788-8666-E575790B29DA")] 28 /// <summary> 29 /// Represents the definition of a result with name, description and data type 30 /// </summary> 31 public interface IResultDefinition : INamedItem { 32 Type DataType { get; } 33 //TODO implement enabled property for deactivation of result calculation 34 //bool Enabled { get; set; } 35 } 36 27 37 [StorableType("e05050f3-5f92-4245-b733-7097d496e781")] 28 38 /// <summary> 29 39 /// Represents a result which has a name and a data type and holds an IItem. 30 40 /// </summary> 31 public interface IResult : INamedItem { 32 Type DataType { get; } 41 public interface IResult : IResultDefinition { 33 42 IItem Value { get; set; } 43 bool HasValue { get; } 34 44 35 /// <inheritdoc/>45 void Reset(); 36 46 event EventHandler ValueChanged; 37 47 } 48 49 [StorableType("3B7B9DF0-0BEB-4FF5-8430-A07749FF2EB4")] 50 /// <summary> 51 /// Represents a typed result which has a name and a data type. 52 /// </summary> 53 public interface IResult<T> : IResult { 54 new T Value { get; set; } 55 } 56 57 38 58 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/IResultParameter.cs
r17525 r17594 25 25 26 26 namespace HeuristicLab.Optimization { 27 [StorableType("986fa3d0-38f8-43aa-820e-e67d09a29025")]28 public interface IResultDefinition {29 string Name { get; set; }30 IItem Get(ResultCollection results);31 }27 //[StorableType("986fa3d0-38f8-43aa-820e-e67d09a29025")] 28 //public interface IResultDefinition { 29 // string Name { get; set; } 30 // IItem Get(ResultCollection results); 31 //} 32 32 33 [StorableType("4c0c854b-676d-4ccd-96c4-b06a3d7f2fa1")]34 public interface IResultDefinition<T> : IResultDefinition where T : class, IItem {35 new T Get(ResultCollection results);36 }33 //[StorableType("4c0c854b-676d-4ccd-96c4-b06a3d7f2fa1")] 34 //public interface IResultDefinition<T> : IResultDefinition where T : class, IItem { 35 // new T Get(ResultCollection results); 36 //} 37 37 38 38 [StorableType("af5d3f60-6f3a-4a44-a906-688ac8296fe3")] 39 public interface IResultParameter : ILookupParameter, IResultDefinition { 39 //public interface IResultParameter : ILookupParameter, IResultDefinition { 40 public interface IResultParameter : ILookupParameter { 40 41 string ResultCollectionName { get; set; } 41 42 ResultCollection ResultCollection { get; set; } … … 45 46 46 47 [StorableType("803e6ad6-dd9d-497a-ad1c-7cd3dc5b0d3c")] 47 public interface IResultParameter<T> : ILookupParameter<T>, IResultParameter, IResultDefinition<T> where T : class, IItem { 48 //public interface IResultParameter<T> : ILookupParameter<T>, IResultParameter, IResultDefinition<T> where T : class, IItem { 49 public interface IResultParameter<T> : ILookupParameter<T>, IResultParameter where T : class, IItem { 48 50 T DefaultValue { get; set; } 49 51 event EventHandler DefaultValueChanged; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/Result.cs
r17226 r17594 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core; 26 using HEAL.Attic;27 27 28 28 namespace HeuristicLab.Optimization { … … 31 31 /// </summary> 32 32 [Item("Result", "A result which has a name and a data type and holds an IItem.")] 33 [StorableType("219051C0-9D62-4CDE-9BA1-32233C81B678")] 34 public sealed class Result : NamedItem, IResult, IStorableContent { 33 public class Result : ResultDefinition, IResult, IStorableContent { 35 34 public string Filename { get; set; } 36 37 35 public override Image ItemImage { 38 36 get { … … 42 40 } 43 41 44 public override bool CanChangeName {45 get { return false; }46 }47 public override bool CanChangeDescription {48 get { return false; }49 }50 51 [Storable]52 private Type dataType;53 public Type DataType {54 get { return dataType; }55 }56 57 42 [Storable] 58 43 private IItem value; 59 44 public IItem Value { 60 get { return value; } 61 set { 62 if (this.value != value) { 63 if ((value != null) && (!dataType.IsInstanceOfType(value))) 64 throw new ArgumentException( 65 string.Format("Type mismatch. Value is not a \"{0}\".", 66 dataType.GetPrettyName()) 67 ); 68 69 DeregisterValueEvents(); 70 this.value = value; 71 RegisterValueEvents(); 72 OnValueChanged(); 73 } 74 } 45 get => value; 46 set => SetValue(value); 75 47 } 76 48 49 public bool HasValue => Value != null; 50 77 51 [StorableConstructor] 78 private Result(StorableConstructorFlag _) : base(_) { } 79 private Result(Result original, Cloner cloner) 80 : base(original, cloner) { 81 dataType = original.dataType; 82 value = cloner.Clone(original.value); 83 Initialize(); 84 } 85 public Result() 86 : base("Anonymous") { 87 this.dataType = typeof(IItem); 88 this.value = null; 89 } 90 public Result(string name, Type dataType) 91 : base(name) { 92 this.dataType = dataType; 93 this.value = null; 94 } 95 public Result(string name, string description, Type dataType) 96 : base(name, description) { 97 this.dataType = dataType; 98 this.value = null; 99 } 100 public Result(string name, IItem value) 101 : base(name) { 102 this.dataType = value == null ? typeof(IItem) : value.GetType(); 103 this.value = value; 104 Initialize(); 105 } 106 public Result(string name, string description, IItem value) 107 : base(name, description) { 108 this.dataType = value == null ? typeof(IItem) : value.GetType(); 109 this.value = value; 110 Initialize(); 52 protected Result(StorableConstructorFlag _) : base(_) { } 53 [StorableHook(HookType.AfterDeserialization)] 54 private void AfterDeserialization() { 55 RegisterValueEvents(); 111 56 } 112 57 113 [StorableHook(HookType.AfterDeserialization)] 114 private void AfterDeserialization() { 115 Initialize(); 58 protected Result(Result original, Cloner cloner) 59 : base(original, cloner) { 60 value = cloner.Clone(original.value); 61 RegisterValueEvents(); 116 62 } 117 118 63 public override IDeepCloneable Clone(Cloner cloner) { 119 64 return new Result(this, cloner); 120 65 } 121 66 122 private void Initialize() { 67 public Result(string name, Type dataType) : this(name, string.Empty, dataType) { } 68 public Result(string name, string description, Type dataType) : base(name, description, dataType) { 69 value = null; 70 } 71 72 public Result(string name, IItem value) : this(name, string.Empty, value.GetType(), value) { } 73 public Result(string name, string description, IItem value) : this(name, description, value.GetType(), value) { } 74 public Result(string name, string description, Type dataType, IItem value) : base(name, description, dataType) { 75 this.value = value; 123 76 RegisterValueEvents(); 124 77 } 125 78 79 private void SetValue(IItem newValue) { 80 if (value == newValue) return; 81 if (newValue == null) throw new ArgumentNullException(nameof(Value)); 82 if (!DataType.IsInstanceOfType(newValue)) 83 throw new ArgumentException(string.Format("Type mismatch. Value is not a \"{0}\".", DataType.GetPrettyName())); 84 85 DeregisterValueEvents(); 86 value = newValue; 87 RegisterValueEvents(); 88 OnValueChanged(); 89 } 90 91 public virtual void Reset() { 92 DeregisterValueEvents(); 93 value = null; 94 OnValueChanged(); 95 } 96 126 97 public override string ToString() { 127 return string.Format("{0}: {1}", Name, Value == null ? "null" : Value.ToString()); 98 if (value != null) 99 return string.Format("{0}: {1}", Name, value.ToString()); 100 101 return base.ToString(); 128 102 } 129 103 130 104 public event EventHandler ValueChanged; 131 105 private void OnValueChanged() { 132 var handler = ValueChanged; 133 if (handler != null) handler(this, EventArgs.Empty); 106 ValueChanged?.Invoke(this, EventArgs.Empty); 134 107 OnItemImageChanged(); 135 108 OnToStringChanged(); … … 137 110 138 111 private void RegisterValueEvents() { 139 if (value != null) {140 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 141 value.ToStringChanged += new EventHandler(Value_ToStringChanged);142 }112 if (value == null) return; 113 114 value.ItemImageChanged += Value_ItemImageChanged; 115 value.ToStringChanged += Value_ToStringChanged; 143 116 } 144 117 private void DeregisterValueEvents() { 145 if (value != null) {146 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 147 value.ToStringChanged -= new EventHandler(Value_ToStringChanged);148 }118 if (value == null) return; 119 120 value.ItemImageChanged -= Value_ItemImageChanged; 121 value.ToStringChanged -= Value_ToStringChanged; 149 122 } 150 123 private void Value_ItemImageChanged(object sender, EventArgs e) { … … 155 128 } 156 129 } 130 131 /// <summary> 132 /// Represents a result which has a name and a data type and holds an IItem. 133 /// </summary> 134 [Item("Result", "A typed result which has a name and a data type and holds a value of type T.")] 135 [StorableType("BA883E2F-1E0B-4F05-A31A-7A0973CB63A3")] 136 public sealed class Result<T> : Result, IResult<T>, IStorableContent 137 where T : IItem { 138 139 public new T Value { 140 get { return (T)base.Value; } 141 set { base.Value = value; } 142 } 143 144 [StorableConstructor] 145 private Result(StorableConstructorFlag _) : base(_) { } 146 private Result(Result<T> original, Cloner cloner) : base(original, cloner) { 147 } 148 public override IDeepCloneable Clone(Cloner cloner) { 149 return new Result<T>(this, cloner); 150 } 151 152 public Result(string name) : this(name, typeof(T)) { } 153 public Result(string name, Type dataType) : this(name, string.Empty, dataType) { } 154 public Result(string name, string description, Type dataType) : base(name, description, dataType) { } 155 156 public Result(string name, T value) : this(name, string.Empty, value.GetType(), value) { } 157 public Result(string name, string description, T value) : this(name, description, value.GetType(), value) { } 158 public Result(string name, string description, Type dataType, IItem value) : base(name, description, dataType, value) { } 159 } 157 160 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultCollection.cs
r17226 r17594 21 21 22 22 using System.Collections.Generic; 23 using HEAL.Attic; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 using HEAL.Attic;26 26 27 27 namespace HeuristicLab.Optimization { … … 82 82 } else res.Value = value; 83 83 } 84 85 public void Reset() { 86 ForEach(r => r.Reset()); 87 } 84 88 } 85 89 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultDefinition.cs
r17591 r17594 22 22 using System; 23 23 using System.Drawing; 24 using HEAL.Attic; 24 25 using HeuristicLab.Common; 26 using HeuristicLab.Common.Resources; 25 27 using HeuristicLab.Core; 26 using HEAL.Attic;27 28 28 29 namespace HeuristicLab.Optimization { … … 31 32 /// </summary> 32 33 [Item("Result", "A result which has a name and a data type and holds an IItem.")] 33 [StorableType("219051C0-9D62-4CDE-9BA1-32233C81B678")] 34 public sealed class Result : NamedItem, IResult, IStorableContent { 35 public string Filename { get; set; } 36 37 public override Image ItemImage { 38 get { 39 if (value != null) return value.ItemImage; 40 else return base.ItemImage; 41 } 42 } 43 44 public override bool CanChangeName { 45 get { return false; } 46 } 47 public override bool CanChangeDescription { 48 get { return false; } 49 } 34 [StorableType("7EA61D13-F1EB-4B39-A623-B945F92E633A")] 35 public class ResultDefinition : NamedItem, IResultDefinition { 36 public override Image ItemImage => VSImageLibrary.Exception; 37 public override bool CanChangeName => false; 38 public override bool CanChangeDescription => false; 50 39 51 40 [Storable] 52 private Type dataType;41 private readonly Type dataType; 53 42 public Type DataType { 54 43 get { return dataType; } 55 44 } 56 45 57 [Storable] 58 private IItem value; 59 public IItem Value { 60 get { return value; } 61 set { 62 if (this.value != value) { 63 if ((value != null) && (!dataType.IsInstanceOfType(value))) 64 throw new ArgumentException( 65 string.Format("Type mismatch. Value is not a \"{0}\".", 66 dataType.GetPrettyName()) 67 ); 68 69 DeregisterValueEvents(); 70 this.value = value; 71 RegisterValueEvents(); 72 OnValueChanged(); 73 } 74 } 46 [StorableConstructor] 47 protected ResultDefinition(StorableConstructorFlag _) : base(_) { } 48 protected ResultDefinition(ResultDefinition original, Cloner cloner) : base(original, cloner) { 49 dataType = original.dataType; 50 } 51 public override IDeepCloneable Clone(Cloner cloner) { 52 return new ResultDefinition(this, cloner); 75 53 } 76 54 77 [StorableConstructor] 78 private Result(StorableConstructorFlag _) : base(_) { } 79 private Result(Result original, Cloner cloner) 80 : base(original, cloner) { 81 dataType = original.dataType; 82 value = cloner.Clone(original.value); 83 Initialize(); 84 } 85 public Result() 86 : base("Anonymous") { 87 this.dataType = typeof(IItem); 88 this.value = null; 89 } 90 public Result(string name, Type dataType) 91 : base(name) { 55 public ResultDefinition(string name, Type dataType) : this(name, string.Empty, dataType) { } 56 public ResultDefinition(string name, string description, Type dataType) : base(name, description) { 92 57 this.dataType = dataType; 93 this.value = null;94 }95 public Result(string name, string description, Type dataType)96 : base(name, description) {97 this.dataType = dataType;98 this.value = null;99 }100 public Result(string name, IItem value)101 : base(name) {102 this.dataType = value == null ? typeof(IItem) : value.GetType();103 this.value = value;104 Initialize();105 }106 public Result(string name, string description, IItem value)107 : base(name, description) {108 this.dataType = value == null ? typeof(IItem) : value.GetType();109 this.value = value;110 Initialize();111 }112 113 [StorableHook(HookType.AfterDeserialization)]114 private void AfterDeserialization() {115 Initialize();116 }117 118 public override IDeepCloneable Clone(Cloner cloner) {119 return new Result(this, cloner);120 }121 122 private void Initialize() {123 RegisterValueEvents();124 }125 126 public override string ToString() {127 return string.Format("{0}: {1}", Name, Value == null ? "null" : Value.ToString());128 }129 130 public event EventHandler ValueChanged;131 private void OnValueChanged() {132 var handler = ValueChanged;133 if (handler != null) handler(this, EventArgs.Empty);134 OnItemImageChanged();135 OnToStringChanged();136 }137 138 private void RegisterValueEvents() {139 if (value != null) {140 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged);141 value.ToStringChanged += new EventHandler(Value_ToStringChanged);142 }143 }144 private void DeregisterValueEvents() {145 if (value != null) {146 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged);147 value.ToStringChanged -= new EventHandler(Value_ToStringChanged);148 }149 }150 private void Value_ItemImageChanged(object sender, EventArgs e) {151 OnItemImageChanged();152 }153 private void Value_ToStringChanged(object sender, EventArgs e) {154 OnToStringChanged();155 58 } 156 59 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Results/ResultParameter.cs
r17525 r17594 63 63 public ResultCollection ResultCollection { get; set; } 64 64 65 string IResultDefinition.Name { get => ActualName; set => ActualName = value; }66 T IResultDefinition<T>.Get(ResultCollection results) => ((IResultDefinition)this).Get(results) as T;67 IItem IResultDefinition.Get(ResultCollection results) => results[ActualName].Value;65 //string IResultDefinition.Name { get => ActualName; set => ActualName = value; } 66 //T IResultDefinition<T>.Get(ResultCollection results) => ((IResultDefinition)this).Get(results) as T; 67 //IItem IResultDefinition.Get(ResultCollection results) => results[ActualName].Value; 68 68 69 69 [StorableConstructor] … … 78 78 return new ResultParameter<T>(this, cloner); 79 79 } 80 public ResultParameter() : this("Anonymous", string.Empty, "Results") { } 80 81 81 public ResultParameter(string name, string description) : this(name, description, "Results") { } 82 83 82 public ResultParameter(string name, string description, string resultCollectionName) 84 83 : base(name, description, string.Empty) { … … 119 118 120 119 var resultValue = result.Value as T; 121 if (result Value == null)120 if (result.Value != null && resultValue == null) 122 121 throw new InvalidOperationException(string.Format("Type mismatch. Result \"{0}\" does not contain a \"{1}\".", ActualName, typeof(T).GetPrettyName())); 123 122 -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ReferenceParameter.cs
r17567 r17594 143 143 144 144 145 [Item("ReferenceParameter <T>", "ValueParameter<T> that forwards to another (referenced) ValueParameter<T>).")]145 [Item("ReferenceParameter", "ValueParameter<T> that forwards to another (referenced) ValueParameter<T>).")] 146 146 [StorableType("6DD59BE5-C618-4AD4-90FE-0FAAF15650C3")] 147 147 public sealed class ReferenceParameter<T> : ReferenceParameter, IValueParameter<T> … … 169 169 170 170 171 [Item("ReferenceParameter <T,U>", "ValueParameter<T> that forwards to another (referenced) ValueParameter<U>).")]171 [Item("ReferenceParameter", "ValueParameter<T> that forwards to another (referenced) ValueParameter<U>).")] 172 172 [StorableType("83FEA704-6AED-4D76-B25A-B469E0E9187A")] 173 173 public sealed class ReferenceParameter<T, U> : ReferenceParameter, IValueParameter<T> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.LinearAssignment/3.3/LinearAssignmentProblem.cs
r17544 r17594 67 67 get { return (IResultParameter<LAPAssignment>)Parameters["Best LAP Solution"]; } 68 68 } 69 public IResultDefinition<LAPAssignment> BestLAPSolution => BestLAPSolutionParameter;69 //public IResultDefinition<LAPAssignment> BestLAPSolution => BestLAPSolutionParameter; 70 70 #endregion 71 71 -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Orienteering/3.3/OrienteeringProblem.cs
r17544 r17594 47 47 [Storable] public OptionalValueParameter<OrienteeringSolution> BestKnownSolutionParameter { get; private set; } 48 48 [Storable] private IResultParameter<OrienteeringSolution> BestOrienteeringSolutionParameter { get; set; } 49 public IResultDefinition<OrienteeringSolution> BestOrienteeringSolution => BestOrienteeringSolutionParameter;49 //public IResultDefinition<OrienteeringSolution> BestOrienteeringSolution => BestOrienteeringSolutionParameter; 50 50 51 51 public IOrienteeringProblemData OrienteeringProblemData { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TravelingSalesman/3.3/TSP.cs
r17544 r17594 48 48 [Storable] public IValueParameter<ITSPSolution> BestKnownSolutionParameter { get; private set; } 49 49 [Storable] protected IResultParameter<ITSPSolution> BestTSPSolutionParameter { get; private set; } 50 public IResultDefinition<ITSPSolution> BestTSPSolution => BestTSPSolutionParameter;50 //public IResultDefinition<ITSPSolution> BestTSPSolution => BestTSPSolutionParameter; 51 51 52 52 public ITSPData TSPData { … … 74 74 Parameters.Add(BestKnownSolutionParameter = new OptionalValueParameter<ITSPSolution>("BestKnownSolution", "The best known solution.")); 75 75 Parameters.Add(BestTSPSolutionParameter = new ResultParameter<ITSPSolution>("Best TSP Solution", "The best so far solution found.")); 76 76 77 77 TSPData = new EuclideanTSPData(); 78 78 Dimension = TSPData.Cities;
Note: See TracChangeset
for help on using the changeset viewer.