Stuart

Stuart

  • NA
  • 1
  • 0

Possible deferencing - problems

Feb 25 2009 7:01 PM
I'm a new user to the C#/.NET language and framework but I've picked it up fairly easily due to my experience with Java. I'm currently working on my 3rd year project which is to develop a system to create the timetable for our department. I'm using a genetic algorithm approach to this problem but I seem to have hit a problem which I believe is related to re-assigning the slot to which an event is paired (this is from the mutation phase for those familiar with genetic algorithms). I had a similar problem earlier last week which I resolved by re-writing one section of code which I knew to be at fault but it was suggested to me that my problem was due to a variable being dereferenced somewhere. Being new to the language, I presume this could occur when I re-assign a variable? The problem is specifically that when getLunchSlots() is called from Chromosome.mutate(), not all of the slots are returned. There should be 8 in total; 1 for each day Monday-Friday excluding Wednesday (this is a half day at our university) and for each of the groups of which there are two at present. I have uploaded my project to http://www.2312.co.uk/GeneticAlgorithms.zip rather than trying to copy and paste the parts I believe to be relevant here. As you can see, I create a list of slots in Program.cs which is then referenced throughout the other classes. During my (lengthy!) debugging phase I tried to move this to the Chromosome.cs class and have a list of available slots which each chromosome would use separately but this caused the same problems as having the list in Program.cs. This issue has now been plaguing me for the past 2 days, I'm completely at a loss!

Answers (1)