Closed gwd closed 6 years ago
Hey,
The minimum fitness you're seeing is not the best obtained fitness. It's the minimum fitness inside the population. The HallOfFame
property will give you the best obtained solutions, along with their
However, it is a bit weird that the populations fitness is going up. If you can share the code I can look into why this is happening. To be totally honest I haven't battle-tested gago.ModMutationOnly
so it might have a bug.
Thanks for the quick response!
Yes, I understand that HallOfFame
is where to look for the "best seen so far"; but what I'm finding is that the "best seen so far" in this case is always one of the initial, randomly-chosen populations: further evolution with ModMutationOnly
never results in any better results. And when I looked into it, the reason was pretty obvious -- the actual population keeps getting worse instead of better! :-)
I don't see this effect with ModGenerational
or ModDownToSize
, but for some reason the results are still not very good -- I wrote an alternate search function that literally just generates random solutions, and it usually outperforms the genetic search, which is why I started exploring other options, and noticed this effect. (I think one of the other ones I tried had a similar effect -- maybe ModSteadyState
.)
Regarding code, it's hard to share less than the whole thing in this case. I made a branch that reproduces this problem. The main repo is http://github.com/gwd/session-scheduler , and the branch name is out/ModMutationOnly-repro/v1
. Once you've built it, run the following commands:
mkdir data
./session-scheduler -count=-500 testpopulate
./session-scheduler testinterest
That will generate a bunch of random users, a bunch of random discussion sessions, and set the "interest" of users in attending various sessions between 0 and 100. At that point, we just need to generate a schedule that maximizes happiness, as calculated by the sum of 'interest' when a user is able to attend the sessions they want to.
To run the genetic algorithm scheduler, just run:
./session-scheduler schedule
This will run the search for 30s, and compare the results to to a "heuristic" scheduler (greedy first-fit), and choose the best one. If you want more data about what's going on, add the -sched-debug
flag (before the schedule
command). (You probably want to pipe to a file in that case.) You can try various things I've tried: -searchalgo=random
will use the completely random method I mentioned above; -crossover=false
will cause the crossover function to return without doing anything, and so on. All the actual scheduling happens in schedule.go
.
I realize this is a lot, so if you don't have time to dig into this, don't worry; my 'random' scheduler will do well enough for the time being. I mainly just wanted to let you know there might be a bug (and/or see if I'm doing something obviously wrong, like using arbitrarily large negative scores).
Okay cheers for linking the code. I'm a bit busy at the moment but I should be able to free some time over the weekend. Hang tight!
Hey,
I went through the code and noticed that the mutants would replace the initial individual if the fitness was higher, which is not the intended behaviour. I've corrected this and pushed the fix to GitHub.
Can you try it again and tell me if it works?
That seemed to do the trick. Thanks!
Awesome! Closing this. Tell me if you have any other questions!
I'm trying to use your library, but I'm getting some really strange results sometimes. For certain models, the population seems to be getting worse (fitness function going up) as time goes on rather than better.
Here's one configuration I used:
And here is some sample output from the log:
[snip]
As you can see, the minimum fitness (with random starting points) started around -42k, and ended around -14k 30 seconds later. Regardless of how I implement the
Genome
interface, I don't see how this should be possible.