FAQ

General Questions

Assignment 5

  • Q, A: Note that the probabilistic selection equation (p. 6 task 10) starts from i=1
    (not i=0), and that individuals run from 1 to n.

  • Q: Should the program always provide the right answer?
    A: No. This is not a deterministic algorithm, such as sorting, where you know you always get a correct answer, and you even know how long the computation will take (about n*log(n) for quicksort, for example). Evolutionary algorithms are stochastic in nature. This means they use probabilistic operators and every run is different: some end up with a solution and some don't.

  • Q: My program sometimes/never produces the correct answer. It gets stuck with a best individual whose fitness is far from zero.
    A: This is known as convergence to a local minimum. Computer science students may take my course on evolutionary algorithms in their final year, where we'll talk about this phenomenon quite a lot… If your program never produces a correct answer (meaning with fitness 0), even though you've run it many times – then you have a bug. If your program produces a correct answer only sometimes – that's fine.

  • Q: How often should my program produce a correct answer?
    A: That's hard to say, given evolution's stochastic nature. You should run the program several times.

  • Q: I want to test my program on additional data sets.
    A: These can be created quite easily. Feel free to insert my little makeData procedure into RegressionIndividual.java. You can create random coefficients in the range [0,127] and call makeData to create a data array. Then, run evolution several times until a solution is found or until a maximal number of trials is reached.
    This means you have an external loop that goes from 1 to numProblems and an internal loop that creates a random problem (using makeData), and then runs evolution until a solution is found or until maxNumTrials is reached.
    Important: In the internal loop, which runs evolution several times for one problem (meaning one data array created from random coefficients), you must use the same data each iteration, but call the RegressionEvolution constructor every time (so that a new initial random population is created).
    To give you an idea, here is a file with my own results, using numProblems=100 and maxNumTrials=100. As you can see, all 100 problems were solved in 4.79 trials on average, where the number of trials ranged from 1 to 41.

  • Q: Can I change the mutation and crossover probabilities?
    A: Yes. The values I used for the 100-problem simulation are:
    double mutationProb = 0.5;
    double crossoverProb = 0.8;