lazypanda10117 / scheduler

Automatic Class Scheduler using Genetic Algorithm, updated from Version 1. It now includes schedule impossibility failure check to prevent program from crashing, and supports reading data from excel and outputting data to excel for ease of analysis.
0 stars 0 forks source link

Asking questions about the program #1

Open NinaGao opened 6 years ago

NinaGao commented 6 years ago

Hello,I've researched your code for a week and I want to ask a question about the block. Now, I need to change the block to another style just as five days a week, nine lessons a day, a total of 45 lessons a week course.I hava no idea yet, because the program is designed to block having 7 "for" loop , I think I changed to 45 "for" loop too unrealistic, so would like to ask any good way? I‘m Chinese,so English expression is not accurate, please don't mind it.Thank you.

lazypanda10117 commented 6 years ago

How many blocks before your schedule repeat? I coded the core code in a rush so it was not generalized to fit schedule outside of 7 blocks. If you have to change it, there will be other sections that you will have to fix too (i.e Scheduler, Student, and probably more). A possible fix is to write another function and do a tail recursion, but you still have to be aware of unexpected error due to the strict restriction I have set before, which you can probably trace back through the console. Currently, I am working on a general version that will theoretically work for an arbitrary number of blocks; I will update you when I figure out a better solution later. Hope this helps :D

NinaGao commented 6 years ago

Firstly, thanks for your reply.On the block, we don't have the concept of block , I check on the Internet means the block is similar to our class time.You are divided into seven blocks a week and I do not understand the specific time allocation. We are divided into 45 lessons a week, (five days and 9 lessons per day, )one lesson 40 minutes . So,for example, math lesson may be have five times in a week. In here ,each student need chooses 3 courses from physics, chemistry, biology, geography, history and politics, and I need to arrange 3 courses of their choice plus some common courses such as English, math and PE in a week 45 lessons. I think your code is very useful, and now the problem about class time is very confused . I feel too many loops will run slower. I‘m looking forward to your new version, but I also want to solve this problem as soon as possible.I am also a java beginner, so I would like to ask you that is it feasible if I expand the block in the excel form from 7 to 45 ?

lazypanda10117 commented 6 years ago

Actually, I am not sure will it work, but I think it is well worth a shot. One thing to note is that the code will get exponentially longer to run if each student will have multiple preferred classes on each "block". For instance, if there are 2 preferred choices for each class time for each student, there will be 2^45 combinations of potential schedules for each student, which would be computationally impossible. (A possible workaround is to limit students to have only 1 choice for each block, and thus only 1 possible combination for the student's schedule) Also, I think a recursive approach for the loop will be less tedious to write, something along the line of this:

public int recur-func(int i, int numOfBlocks){ if(i != numOfBlocks){ for(int k=0; k<blocksOf7[i].size();k++) { tempBlockList[k] = (int)blocksOf7[i].get(k); recur-func(i+1,numOfBlocks); }else{ //some code }}}

NinaGao commented 6 years ago

Well, limitting students to have only 1 choice for each period is a feasible way. Then,I still have two questions : 1.I don't understand four concepts in your code may because the regional difference. ①Preferred classes .This is a well-defined course in Students sheet. What does it means that in your country students can choose what module does he preferred in per block? ②ArrayList<int[]> maxBlockAL and ArrayList maxPCL. These two concepts are completely do not understand what it means. ③The method "numberFit(Class classes[])"means?The return value maxNumFit means? 2.Above code meaning that I can pre-written nine subjects in each block and recursive loop to get all the information about one student 45 lessons per week under the premise of only 1 choice for each period?Then can make the next genetic algorithm based on the 45 lessons I got?

lazypanda10117 commented 6 years ago

1) i) In our situation, the students in school will be able to choose courses they want to take for each block, and the courses they choose are called the preferred courses. However, a potential problem here is that your 45 blocks will have repeated classes (i.e. Math on Monday and on Wednesday), whereas, my code requires each student schedule to have unique classes. ii)

2) The above recursion is to make the numberFit function in Student less tedious to write, as you don't have to write 45 nested for loops to accomplish the task. This can also be applied to the create2DModuleArray function in Scheduler with some modification.

Hope this answer helps!

NinaGao commented 6 years ago

Thanks for your answer. It's very helpful. The concepts I didn't understand before may be caused by our different situations.I understand that the key to our difference is that we have repeated classes at 45 blocks and one teacher only teaches one subject, there are many teachers in one subject. I'll re - think about my problems to solve it and thank you again.I'm glad to make friends with you.