[11635] | 1 | #region License Information
|
---|
[11956] | 2 |
|
---|
[11635] | 3 | /* HeuristicLab
|
---|
[11956] | 4 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[11635] | 5 | *
|
---|
| 6 | * This file is part of HeuristicLab.
|
---|
| 7 | *
|
---|
| 8 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 9 | * it under the terms of the GNU General Public License as published by
|
---|
| 10 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 11 | * (at your option) any later version.
|
---|
| 12 | *
|
---|
| 13 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 16 | * GNU General Public License for more details.
|
---|
| 17 | *
|
---|
| 18 | * You should have received a copy of the GNU General Public License
|
---|
| 19 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 20 | */
|
---|
[11956] | 21 |
|
---|
[11635] | 22 | #endregion
|
---|
| 23 |
|
---|
| 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 | using HeuristicLab.Data;
|
---|
[11987] | 27 | using HeuristicLab.Encodings.BinaryVectorEncoding;
|
---|
[11635] | 28 | using HeuristicLab.Optimization;
|
---|
| 29 | using HeuristicLab.Parameters;
|
---|
| 30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 31 |
|
---|
[11987] | 32 | namespace HeuristicLab.Problems.Binary {
|
---|
[11635] | 33 | [StorableClass]
|
---|
[11987] | 34 | public abstract class BinaryProblem : SingleObjectiveBasicProblem<BinaryVectorEncoding> {
|
---|
[11635] | 35 |
|
---|
[11987] | 36 | public virtual int Length {
|
---|
| 37 | get { return Encoding.Length; }
|
---|
| 38 | set { Encoding.Length = value; }
|
---|
[11635] | 39 | }
|
---|
| 40 |
|
---|
[11987] | 41 | [StorableConstructor]
|
---|
| 42 | protected BinaryProblem(bool deserializing) : base(deserializing) { }
|
---|
| 43 | protected BinaryProblem(BinaryProblem original, Cloner cloner) : base(original, cloner) { }
|
---|
| 44 | protected BinaryProblem() : base() { }
|
---|
[11635] | 45 |
|
---|
[11987] | 46 | public virtual bool IsBetter(double quality, double bestQuality) {
|
---|
[11640] | 47 | return (Maximization && quality > bestQuality || !Maximization && quality < bestQuality);
|
---|
| 48 | }
|
---|
[11635] | 49 |
|
---|
[11987] | 50 | public sealed override double Evaluate(Individual individual, IRandom random) {
|
---|
| 51 | return Evaluate(individual.BinaryVector(), random);
|
---|
[11635] | 52 | }
|
---|
| 53 |
|
---|
[11987] | 54 | public abstract double Evaluate(BinaryVector vector, IRandom random);
|
---|
[11635] | 55 | }
|
---|
| 56 | }
|
---|