Line | |
---|
1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.Data;
|
---|
4 | using HeuristicLab.Optimization.Model2;
|
---|
5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Algorithms.GeneticAlgorithm.Model2 {
|
---|
8 | [Item("GA Solution Scope", "")]
|
---|
9 | [StorableClass]
|
---|
10 | public class SolutionScope : Scope, ISolutionScope {
|
---|
11 |
|
---|
12 | [Storable]
|
---|
13 | private Variable fitness;
|
---|
14 | public double Fitness {
|
---|
15 | get { return ((DoubleValue)fitness.Value).Value; }
|
---|
16 | set { ((DoubleValue)fitness.Value).Value = value; }
|
---|
17 | }
|
---|
18 |
|
---|
19 | [StorableConstructor]
|
---|
20 | protected SolutionScope(bool deserializing) : base(deserializing) { }
|
---|
21 | protected SolutionScope(SolutionScope original, Cloner cloner)
|
---|
22 | : base(original, cloner) {
|
---|
23 | fitness = cloner.Clone(original.fitness);
|
---|
24 | }
|
---|
25 | public SolutionScope(string fitnessName) : this(fitnessName, double.NaN) { }
|
---|
26 | public SolutionScope(string fitnessName, double fitness) {
|
---|
27 | this.fitness = new Variable(fitnessName, new DoubleValue(fitness));
|
---|
28 | Variables.Add(this.fitness);
|
---|
29 | }
|
---|
30 |
|
---|
31 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
32 | return new SolutionScope(this, cloner);
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.