Generating potential schedules for college students - algorithm

Here is my problem: I am designing an application that will allow students to select the classes they want to take for the semester and create potential schedule layouts for them. Each class typically has several possible sections that occur at different times.
So I am looking for a good data structure to use in order to develop an algorithm that will do this.
Is there a common way to do this? Any data structures and/or algorithms I can apply to this situation? I am just looking for a place to get started.
EDIT: The classes tend to be Monday, Wednesday, Friday or Tuesday, Thursday. In a lot of cases there are also labs or recitations that occur at various times during the week
Thanks,
Rob

This is a problem where genetic algorithms are suitable. At least, my University staff developed an algorithm based on it. Here are some of their papers where the technique is presented.
http://morgoth.zemris.fer.hr/people/Marko.Cupic/files/2009-425555.EvoCOP_2009.pdf
http://morgoth.zemris.fer.hr/people/Marko.Cupic/files/2009-422047.iti2009.pdf

I would use a tree
At each node (which represents a class) branch for each section and an additional branch for not taking the course
You can prune for scheduling conflicts at any time
This shouldn't get too big as long as you aren't storing these forever, and as long as you don't include too many courses per student per semester
The tree would be rooted at any arbitrary class. Each branch from root would be a section of that class (and the extra branch for not taking it)
Then at the end of each of these branches you have more nodes. These nodes would all represent the second class you're fitting in the schedule.
Each of these nodes would have another branch for each section of the second class. And so on.
ex:
math
/ / \
2:00 1:00 blank
| | |
p.e p.e p.e
/ \ / \ / \
2:00 blank 2:00 blank 2:00 blank
|
conflict

Does each class have the same schedule each day of the week? Or are they like mine were, where some were MWF, others TuTh, and others Sat?
If all the classes are at the same time every day of the week, the model's pretty easy. You need tables for students, classes, classSections, and studentSchedules.
For your classSection table, since the classes aren't the same time every day, if they're the same days each week, you can include fields for each day of the week (M-Sa), start time, class length (in hours,) and, of course, the classCodeID.
At a minimum:
Student
ID
Class
classCodeID
description
classSection
classCodeID
classSectionID
isOnM
isOnTu
isOnW
isOnTh
isOnF
isOnSat
startTime
length
studentSchedule
studentID
classCodeID
classSectionID
You could also normalize the days of the week instead of having them in the classSection table, but I like seeing the week mapped out in a bunch of checkboxes.
I see you have multiple start times per week, so you'll need another ID field in the classSection table.
The app you have seems ok, don't you have a data model already? Looks like you don't even need to be a student to see the class schedules.

Related

Which machine learning algorithm I have to use for sequence prediction?

I have a dataset like below. I have datetime column as index, type is a column with sequence. For ex; R,C,D,D,D,R,R is a sequence.
start_time type
2019-12-14 09:00:00 RCDDDRR
2019-12-14 10:00:00 CCRD
2019-12-14 11:00:00 DDRRCC
2019-12-14 12:00:00 ?
I want to predict what would be the next sequence at time 12:00:00? which is the best algorithm to predict the next sequence?
I know that we can use Markov chain to predict the probable sequence. However, are there any other better algorithms?
Thanks
you can use from knn,svm for prediction.but the first of all you have to change database and define feature for training dataset for example
you can use from another method base on deep learning , I think this link can help you
https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/
LSTMs have an edge over conventional feed-forward neural networks and RNN in many ways. This is because of their property of selectively remembering patterns for long durations of time.
LSTMs on the other hand, make small modifications to the information by multiplications and additions. With LSTMs, the information flows through a mechanism known as cell states. This way, LSTMs can selectively remember or forget things. The information at a particular cell state has three different dependencies.
Let’s take the example of predicting stock prices for a particular stock. The stock price of today will depend upon:
The trend that the stock has been following in the previous days, maybe a downtrend or an uptrend.
The price of the stock on the previous day, because many traders compare the stock’s previous day price before buying it.
The factors that can affect the price of the stock for today. This can be a new company policy that is being criticized widely, or a drop in the company’s profit, or maybe an unexpected change in the senior leadership of the company.
These dependencies can be generalized to any problem as:
The previous cell state (i.e., the information that was present in the memory after the previous time step).
The previous hidden state (this is the same as the output of the previous cell).
The input at the current time step (i.e., the new information that is being fed in at that moment).
Maybe this link and method could help you
https://www.bioinf.jku.at/publications/older/2604.pdf
https://www.analyticsvidhya.com/blog/2017/12/fundamentals-of-deep-learning-introduction-to-lstm/

java.time.temporal.ChronoUnit VS java.time.temporal.ChronoField

While looking at java 8 Time API I see a lot of methods expect as a parameter ChronoUnit (implementation of TemporalUnit) as here while other expect a ChronoField (implementation of TemporalField) as here.
Could anyone help me clarify the designers decision when a method is expecting to use a ChronoUnit and when a ChronoField and what are their differences?
Thanks.
Units are used to measure a quantity of time - years, months, days, hours, minutes, seconds. For example, the second is an SI unit.
By contrast, fields are how humans generally refer to time, which is in parts. If you look at a digital clock, the seconds count from 0 up to 59 and then go back to 0 again. This is a field - "second-of-minute" in this case, formed by counting seconds within a minute. Similarly, days are counted within a month, and months within a year. To define a complete point on the time-line you have to have a set of linked fields, eg:
second-of-minute
minute-of-hour
hour-of-day
day-of-month
month-of-year
year (-of-forever)
The ChronoField API exposes the two parts of second-of-minute. Use getBaseUnit() to get "seconds" and getRangeUnit() to get "minutes".
The Chrono part of the name refers to the fact that the definitions are chronology-neutral. Specifically, this means that the unit or field has a meaning only when associated with a calendar system, or Chronology. An example of this is the Coptic chronology, where there are 13 months in a year. Despite this being different to the common civil/ISO calendar system, the ChronoField.MONTH_OF_YEAR constant can still be used.
The TemporalUnit and TemporalField interfaces provide the higher level abstraction, allowing units/fields that are not chronology-neutral to be added and processed.
A TemporalUnit serves as general unit of time measurement. Therefore it can be used in determining the size of temporal amount between two given points in time (in abstract sense).
However, a TemporalField is not necessarily related to any kind of (abstract) time axis and usually represents a detail value of a point in time. Example: A month is only one component of a complete calendar date consisting of year, month and day-of-month.
Some people might argue that a calendar month and the month unit could be interpreted more or less as equivalent. Older libraries like java.util.Calendar don't make this difference. However, field and unit are used in a very different way as shown above (composing points in time versus measuring temporal amount).
Interestingly, the JDK-8-designers have decided that a field must have a base unit which is not null (I am personally not happy about this narrowing decision because I can imagine other fields not necessarily having a base unit). In case of months it is quite trivial. In case of days, we have different fields with the same base unit DAYS, for example day-of-month, day-of-year, day-of-week. This 1:n-relationship justifies the separation of units and fields in context of JSR-310 (aka java.time-package).

A specific scheduling algorithm

The question I have concerns a hobby project that I'm working on to help out my wife with her work.
I realize that the problem I'm facing is quite similar to what's been answered on SO in numerous threads. However, I can't seem to find any thread that would address one little specific difference that I need to count in.
Here's a detailed description of the problem:
A teacher has numerous students that she teaches. Each student needs to have two lessons every week at least two days apart (i.e. Monday + Wednesday, Tuesday + Thursday etc.). The lessons are individual meaning there's only one student and the teacher in a class at a time. The teacher needs to have exactly one lunch break every day. The lunch break can be any time between two classes - the only condition is: a day cannot start or end in a lunch break. Each student provides their availability during a week (a list of possible time slots they can attend the class).
So far, this looks like a "regular" scheduling problem that there's bunch of material available online on.
But here's the catch: students are in different age meaning their lesson takes either 30 or 45 minutes. Younger students' lesson takes 30 minutes and olders' - 45 minutes. The goal of the algorithm is to find the optimal weekly schedule for the teacher. By optimal I mean a schedule where the teacher needs to spend least amount of time in school - all lessons back to back with no need for the teacher to wait for another student.
My first attempt was to come with all possible permutations of students' classes, lunch breaks and week days but for a 3 student schedule I came up with 13! permutations (that's roughly around 6 bln permutations). Here's why 13:
3 students - 2 classes each
4 lunch breaks (a 4 day week to keep the numbers small)
3 day breaks (a "night" so to speak)
The above gave me 13 elements to try in different permutations. However, after calculating the factorial I gave that up - 6 bln permutations will not be tried in any reasonable time on a "regular" machine. And that's just counting 3 students, the real-life data will be closer to 9 or 10. Obviously, the nonsense permutations (2 "nights" in a row, 2 classes for the same student on the same day and so on) would be thrown right away but still...
That was when I realized I'm not going to do this inventing the wheel by myself.
I did some research and came across Hopcroft-Karp algorithm. However I don't think it can be applied in a mixed timespan slots scenario (30/45 minute lessons). Am I wrong? Then I found some info on genetic algorithms. However, again I am not sure if they can take the mixed timespan condition into account?
I would greatly appreciate any pointers as to which directions my research should go.

Is there a complex date filter algorithm?

Essentially, I want a system that can filter simply such as "Between August 4th and August 7th", but be as complicated as "Every third saturday or monday of each january on leap years".
I figured that in order to represent the complicated boolean algebra, I would need a tree structure. Each node would either be a boolean operation (AND, OR, XOR, NOT) and then would have children that it apply to, which can either be specific filters or another boolean operation.
Each "specific filter" would be something like "Sundays" or "Leap Years". I think everything up to this point is very doable. However, the problem then arises in parsing the tree to actually find what dates are needed, in order to then make database queries to get the data points.
With the example above (Every third saturday or monday of each january on leap years), if we pre-restrict ourselves to the years that we have data (5 years worth). If the sat/mon filters happen to be the top nodes in the tree, we will end up with 500 segmented dates (2 per week, 50 weeks a year, 5 years). Then, the next node has to search through all 500 to find which ones conform to "every third" filter. This isn't even the most complicated example, because an arbitrary number of filters should be allowed, and XOR makes that even more crazy.
So, is there any easy route? Did someone already build this? This is just a small part a project involving data visualization, but it seems that it could be an entire project by itself.
I found a couple in Ruby. IceCube seems promising, even though it might not support all your needs.

Best approach: transfer daily values from one year to another

I will try to explain what I want to accomplish. I am looking for an algorithm or approach, not the actual implementation in my specific system.
I have a table with actuals (incoming customer requests) on a daily basis. These actuals need to be "copied" into the next year, where they will be used as a basis for planning the amount of requests in the future.
The smallest timespan for planning, on a technical basis, is a "period", which consists of at least one day. A period always changes after a week or after a month. This means, that if a week is both in May and June, it will be split in two periods.
Here's an example:
2010-05-24 - 2010-05-30 Week 21 | Period_Id 123
2010-05-31 - 2010-05-31 Week 22 | Period_Id 124
2010-06-01 - 2010-06-06 Week 22 | Period_Id 125
We did this to reduce the amount of data, because we have a few thousand items that have 356 daily values. For planning, this is reduced to "a few thousand x 65" (or whatever the period count is per year). I can aggregate a month, or a week, by combining all periods that belong to one month. The important thing about this is, I could still use daily values, then find the corresponding period and add it there if necessary.
What I need, is an approach on aggregating the actuals for every (working)day, week or month in next years equivalent period. My requirements are not fixed here. The actuals have a certain distribution, because there are certain deadlines and habits that are reflected in the data. I would like to be able to preserve this as far as possible, but planning is never completely accurate, so I can make a compromise here.
Don't know if this is what you're looking for, but this is a strategy for calculating the forecasts using flexible periods:
First define a mapping for each day in next year to the corresponding day in this year. Then when you need a forecast for period x you take all days in that period and sum the actuals for the matching days.
With this you can precalculate every week/month but create new forecasts if the contents of periods change.
Map weeks to weeks. The first full week of this year to the first full week of the next. Don't worry about "periods" and aggregation; they are irrelevant.
Where a missing holiday leaves a hole in the data, just take the values for the same day of the previous week or the next week, and do the same at the beginning/end of the year.
Now for each day of the week, combine the results for the year and look for events more than, say, two standard deviations from the mean (if you don't know what that means then skip this step), and look for correlations with known events like holidays. If a holiday doesn't show an effect in this test then ignore it. If you find an effect, shift it to compensate for the different date next year. Don't worry about higher-order effects, you don't have enough data to pin them down.
Now draw in periods wherever you like and aggregate all you want.
Don't make any promises about the accuracy of these predictions, there's no way to know it. Don't worry about whether this is the best possible way; it isn't, but it's as good as any you're likely to find. You can spend as much more time and effort fine-tuning this as you wish; it might raise expectations but it's not likely to make the results much more accurate-- it's about as likely to make them worse.
There is no A-priori way to answer that question. You have to look at your data, and decide what the important parameters (day of week, week number, month, season, temperature outside?) using the results.
For example, if many of your customers are jewish/muslim, then the gregorian calendar, and ISO-week numbers and all that won't help you much, because jewish/muslim holidays (and so users behaviour) are determined using other calendars.
Another example - Trying to predict iPhone search volume according to last year's search doesn't sound like a good idea. It seems that the important timescales are much longer than a year (the technology becoming mainstream over the years) and much shorter than a year (Specific events that affect us for days-weeks).

Resources