cloudflight
2024-07-06 6fc98fca9a6e5883cdeaf5051cfdae5a101b5a43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Threading.Tasks;
 
namespace AForge.Genetic
{
    public abstract class ChromosomeBase : IChromosome, IComparable
    {
        public Guid ID;
        public double? fitness=null;
 
        public double Fitness
        {
            get
            {
                //while (fitness == null) ;
                
                if (fitness is double f)
                {
                    if(double.IsNaN(f)) return 999999;
                    else return f;
 
                }
                    //while (fitness == null) ;
                    //return fitness??0;
                    
                else
                    return 999999;
            }
            
        }
 
        public int CalcID;
 
        public double[] AttemptArray = null;
        public abstract void Generate();
 
        public abstract IChromosome CreateNew();
 
        public abstract IChromosome Clone();
 
        public abstract void Mutate();
 
        public abstract void Crossover(IChromosome pair);
 
 
        public int CompareTo(object o)
        {
            
            
            double num = ((ChromosomeBase)o).Fitness;
            if (fitness != num)
            {
                if (!(fitness < num))
                {
                    return -1;
                }
                return 1;
            }
            return 0;
        }
 
        public virtual bool isValid()
        {
            throw new NotImplementedException();
            return true;
        }
 
        public virtual bool _valid { get; set; } = false;
 
        public virtual void Evaluate(IFitnessFunction function)
        {
            throw new NotImplementedException();
 
            fitness = function.Evaluate(this);
        }
    }
}