Advertisement
Guest User

Untitled

a guest
May 30th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace msi_lab_7
  8. {
  9. public class Individual
  10. {
  11. private double _leftEnd;
  12. private double _rightEnd;
  13.  
  14. public List<bool> Chromosome { get; set; }
  15. public double Fitness { get; set; }
  16. public int Length
  17. {
  18. get
  19. {
  20. return Chromosome.Count;
  21. }
  22. }
  23.  
  24. public Individual()
  25. {
  26. Chromosome = new List<bool>();
  27. }
  28.  
  29. public Individual(Individual individual)
  30. {
  31. this.Chromosome = individual.Chromosome.Select(x=>x).ToList();
  32. this._leftEnd = individual._leftEnd;
  33. this._rightEnd = individual._rightEnd;
  34. }
  35.  
  36. public Individual(int n, double p, double leftEnd, double rightEnd)
  37. {
  38. Chromosome = new List<bool>();
  39. for(int i = 0; i <n; i++)
  40. {
  41. Chromosome.Add(RandomHelper.NextBitValue(p) == 1 ? true : false);
  42. }
  43. _leftEnd = leftEnd;
  44. _rightEnd = rightEnd;
  45. }
  46. }
  47.  
  48. class Program
  49. {
  50. static void Main(string[] args)
  51. {
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement