- Timestamp:
- 11/25/14 13:05:14 (10 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/BinaryEncoding.cs
r11575 r11582 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Encodings.BinaryVectorEncoding; 29 using HeuristicLab.Optimization;30 29 using HeuristicLab.Parameters; 31 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 74 73 : base(name) { 75 74 lengthParameter = new FixedValueParameter<IntValue>(Name + "Length", new IntValue(length)); 75 RegisterParameterEvents(); 76 DiscoverOperators(); 77 SolutionCreator = Operators.OfType<RandomBinaryVectorCreator>().Single(); 76 78 } 77 79 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs
r11559 r11582 49 49 50 50 51 ISolutionCreator IEncoding.DefaultSolutionCreator { get { return DefaultSolutionCreator; } }52 public virtual T DefaultSolutionCreator {53 get { return null; }54 }55 56 57 51 ISolutionCreator IEncoding.SolutionCreator { 58 52 get { return SolutionCreator; } … … 65 59 public T SolutionCreator { 66 60 get { 67 if (solutionCreator == null) return DefaultSolutionCreator;68 61 return solutionCreator; 69 62 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
r11561 r11582 87 87 boundsParameter = cloner.Clone(original.boundsParameter); 88 88 RegisterParameterEvents(); 89 DiscoverOperators();90 89 } 91 90 public override IDeepCloneable Clone(Cloner cloner) { return new IntegerEncoding(this, cloner); } … … 102 101 RegisterParameterEvents(); 103 102 DiscoverOperators(); 103 SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single(); 104 104 } 105 105 public IntegerEncoding(string name, int length, IList<int> min, IList<int> max, IList<int> step = null) … … 118 118 RegisterParameterEvents(); 119 119 DiscoverOperators(); 120 SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single(); 120 121 } 121 122 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/PermutationEncoding.cs
r11575 r11582 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Encodings.PermutationEncoding; 29 using HeuristicLab.Encodings.RealVectorEncoding;30 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 30 using HeuristicLab.PluginInfrastructure; … … 96 95 RegisterParameterEvents(); 97 96 DiscoverOperators(); 97 SolutionCreator = Operators.OfType<RandomPermutationCreator>().Single(); 98 98 } 99 99 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/RealEncoding.cs
r11561 r11582 103 103 RegisterParameterEvents(); 104 104 DiscoverOperators(); 105 SolutionCreator = Operators.OfType<UniformRandomRealVectorCreator>().Single(); 105 106 } 106 107 … … 120 121 RegisterParameterEvents(); 121 122 DiscoverOperators(); 123 SolutionCreator = Operators.OfType<UniformRandomRealVectorCreator>().Single(); 122 124 } 123 125 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Interfaces/IEncoding.cs
r11559 r11582 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Dynamic;25 using System.Linq;26 using System.Text;27 23 using HeuristicLab.Core; 28 24 using HeuristicLab.Optimization; 29 25 30 26 namespace HeuristicLab.Problems.Programmable { 31 public interface IEncoding : INamedItem 32 { 33 34 ISolutionCreator DefaultSolutionCreator { get; } 27 public interface IEncoding : INamedItem { 35 28 ISolutionCreator SolutionCreator { get; set; } 36 37 29 38 30 IEnumerable<IValueParameter> Parameters { get; } … … 41 33 42 34 void ConfigureOperator(IOperator @operator); 43 void ConfigureOperators(IEnumerable<IOperator> operators); 35 void ConfigureOperators(IEnumerable<IOperator> operators); 44 36 } 45 37 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs
r11575 r11582 176 176 177 177 protected virtual ISolutionCreator ConfigureCreator(IEncoding encoding) { 178 #region Configure RealVector Creator179 var realEnc = encoding as RealEncoding;180 if (realEnc != null) {181 DynamicEncodingParameters.AddRange(realEnc.Parameters);182 return realEnc.DefaultSolutionCreator;183 }184 #endregion185 #region Configure BinaryVector Creator186 var binEnc = encoding as BinaryEncoding;187 if (binEnc != null) {188 DynamicEncodingParameters.AddRange(binEnc.Parameters);189 return binEnc.DefaultSolutionCreator;190 }191 #endregion192 #region Configure IntegerVector Creator193 var intEnc = encoding as IntegerEncoding;194 if (intEnc != null) {195 DynamicEncodingParameters.AddRange(intEnc.Parameters);196 return intEnc.DefaultSolutionCreator;197 }198 #endregion199 178 #region Configure MultiEncoding Creator 200 179 var multiEncoding = encoding as MultiEncoding; … … 208 187 } 209 188 #endregion 189 #region Configure RealVector Creator 190 var realEnc = encoding as RealEncoding; 191 if (realEnc != null) { 192 DynamicEncodingParameters.AddRange(realEnc.Parameters); 193 return realEnc.SolutionCreator; 194 } 195 #endregion 196 #region Configure BinaryVector Creator 197 var binEnc = encoding as BinaryEncoding; 198 if (binEnc != null) { 199 DynamicEncodingParameters.AddRange(binEnc.Parameters); 200 return binEnc.SolutionCreator; 201 } 202 #endregion 203 #region Configure IntegerVector Creator 204 var intEnc = encoding as IntegerEncoding; 205 if (intEnc != null) { 206 DynamicEncodingParameters.AddRange(intEnc.Parameters); 207 return intEnc.SolutionCreator; 208 } 209 #endregion 210 210 #region Configure Permutation Creator 211 211 var permEnc = encoding as PermutationEncoding; 212 212 if (permEnc != null) { 213 var l = new ValueParameter<IntValue>(permEnc.Name + "Length", new IntValue(permEnc.Length)); 214 DynamicEncodingParameters.Add(l); 215 216 var creator = new RandomPermutationCreator(); 217 creator.PermutationParameter.ActualName = permEnc.Name; 218 creator.LengthParameter.ActualName = l.Name; 219 creator.PermutationTypeParameter.Value = new PermutationType(permEnc.Type); 220 return creator; 213 DynamicEncodingParameters.AddRange(permEnc.Parameters); 214 return permEnc.SolutionCreator; 221 215 } 222 216 #endregion 217 218 223 219 throw new ArgumentException(string.Format("Encoding {0} is unknown.", encoding != null ? encoding.GetType().FullName : "(null)")); 224 220 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs
r11575 r11582 35 35 using HeuristicLab.Parameters; 36 36 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 37 using HeuristicLab.PluginInfrastructure;38 37 39 38 namespace HeuristicLab.Problems.Programmable { … … 187 186 188 187 protected virtual ISolutionCreator ConfigureCreator(IEncoding encoding) { 189 #region Configure RealVector Creator190 var realEnc = encoding as RealEncoding;191 if (realEnc != null) {192 DynamicEncodingParameters.AddRange(realEnc.Parameters);193 return realEnc.DefaultSolutionCreator;194 }195 #endregion196 #region Configure BinaryVector Creator197 var binEnc = encoding as BinaryEncoding;198 if (binEnc != null) {199 DynamicEncodingParameters.AddRange(binEnc.Parameters);200 return binEnc.DefaultSolutionCreator;201 }202 #endregion203 #region Configure IntegerVector Creator204 var intEnc = encoding as IntegerEncoding;205 if (intEnc != null) {206 DynamicEncodingParameters.AddRange(intEnc.Parameters);207 return intEnc.SolutionCreator;208 }209 #endregion210 #region Configure Permutation Creator211 var permEnc = encoding as PermutationEncoding;212 if (permEnc != null) {213 DynamicEncodingParameters.AddRange(permEnc.Parameters);214 return permEnc.SolutionCreator;215 }216 #endregion217 188 #region Configure MultiEncoding Creator 218 189 var multiEncoding = encoding as MultiEncoding; … … 224 195 } 225 196 return creator; 197 } 198 #endregion 199 200 #region Configure RealVector Creator 201 var realEnc = encoding as RealEncoding; 202 if (realEnc != null) { 203 DynamicEncodingParameters.AddRange(realEnc.Parameters); 204 return realEnc.SolutionCreator; 205 } 206 #endregion 207 #region Configure BinaryVector Creator 208 var binEnc = encoding as BinaryEncoding; 209 if (binEnc != null) { 210 DynamicEncodingParameters.AddRange(binEnc.Parameters); 211 return binEnc.SolutionCreator; 212 } 213 #endregion 214 #region Configure IntegerVector Creator 215 var intEnc = encoding as IntegerEncoding; 216 if (intEnc != null) { 217 DynamicEncodingParameters.AddRange(intEnc.Parameters); 218 return intEnc.SolutionCreator; 219 } 220 #endregion 221 #region Configure Permutation Creator 222 var permEnc = encoding as PermutationEncoding; 223 if (permEnc != null) { 224 DynamicEncodingParameters.AddRange(permEnc.Parameters); 225 return permEnc.SolutionCreator; 226 226 } 227 227 #endregion
Note: See TracChangeset
for help on using the changeset viewer.