- Timestamp:
- 11/23/15 15:15:27 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/BinaryProblem.cs
r12000 r13336 34 34 namespace HeuristicLab.Problems.Binary { 35 35 [StorableClass] 36 public abstract class BinaryProblem : SingleObjective BasicProblem<BinaryVectorEncoding> {36 public abstract class BinaryProblem : SingleObjectiveProblem<BinaryVector> { 37 37 public virtual int Length { 38 38 get { return Encoding.Length; } 39 39 set { Encoding.Length = value; } 40 } 41 42 public new BinaryVectorEncoding Encoding { 43 get { return (BinaryVectorEncoding)base.Encoding; } 44 set { base.Encoding = value; } 40 45 } 41 46 … … 60 65 var lengthParameter = new FixedValueParameter<IntValue>("Length", "The length of the BinaryVector.", new IntValue(10)); 61 66 Parameters.Add(lengthParameter); 67 Encoding = new BinaryVectorEncoding(); 62 68 Encoding.LengthParameter = lengthParameter; 63 69 RegisterEventHandlers(); 64 70 } 65 71 66 public virtual bool IsBetter(double quality, double bestQuality) { 67 return (Maximization && quality > bestQuality || !Maximization && quality < bestQuality); 68 } 69 70 public abstract double Evaluate(BinaryVector vector, IRandom random); 71 public sealed override double Evaluate(Individual individual, IRandom random) { 72 return Evaluate(individual.BinaryVector(), random); 73 } 74 75 public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) { 72 public override void Analyze(BinaryVector[] individuals, double[] qualities, ResultCollection results, IRandom random) { 76 73 base.Analyze(individuals, qualities, results, random); 77 74 var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality); … … 81 78 results.Add(new Result("Best Solution", typeof(BinaryVector))); 82 79 } 83 results["Best Solution"].Value = (IItem)best. BinaryVector().Clone();80 results["Best Solution"].Value = (IItem)best.Clone(); 84 81 } 85 82
Note: See TracChangeset
for help on using the changeset viewer.