CakePHP: Interaction between different files/classes
- by Alexx Hardt
Hey,
I'm cloning a commercial student management system. Students use the frontend to apply for lectures, uni staff can modify events (time, room, etc).
The core of the app will be the algortihm which distributes the seats to students. I already asked about it here:
How to implement a seat distribution algorithm for uni lectures
Now, I found a class for that algorithm here:
http://www.phpclasses.org/browse/file/10779.html
I put the 'class GA' into app/vendors. I need to write a 'class Solution', which represents one object (a child, and later a parent for the evolutionary process).
I'll also have to write functions mutate(), crossover() and fitness(). fitness calculates a score of a solution, based on if there are overbooked courses etc; crossover() is the crazy monkey sex function which produces a child from two parents, and mutate() modifies a child after crossover.
Now, the fitness()-function needs to access a few related models, and their find()-functions. It evaluates a solution's fitness by checking e.g. if there are overbooked courses, or unfulfilled wishes, and penalizes that.
Where would I put the ga.php, solution.php and the three functions? ga.php has to access the functions, but the functions have to access the models. I also don't want to call any App::import()'s from within the fitness()-function, because it gets called many thousand times when the algorithm runs.
Hope someone can help me. Thanks in advance =)