Simple Genetic Algorithm tutorial for timetabling? - java

My final year project is about automated timetabling using Genetic Algorithm.
First, I'm not asking about a sample working code.
I just need a tutorial in which I can understand more about GA in timetabling.
I currently understand GA operations (selection,crossover,mutation) based on tutorial I found.
But I have no idea on how to apply it onto the timetable. The GA tutorial I looked at encode data in the form of binary or string. But what about for creating timetable?
I hope somebody can guide me to understand about GA in timetabling in more detail. If you have another tutorial of GA that can help me understand GA better, it is welcomed. :)
Thanx in advance!

Define your individual/genotype
Which parameters does a time table have? Can you store them as a bit string or an array of integers?
Define your fitness function
Create rules how to calculate the goodness of a time table.
Define the type of selection
How to select individuals for mating? Will the best individual be stored during the whole run? (elitism)
Define genetic operators
How can two individuals create an offspring? Do you want to use mutation, crossover or both?
Define parameters for the algorithm
Will the population size be fixed and new individuals replace old individuals depending on their fitness value (steady state)? Or do you want to create a new generation each time all individuals are evaluated?
Implement a SGA and test.

Related

Predictive model using TensorFlow

My goal is to generate a predictive model using tensor flow in Java but I first want to ensure that my goal is achievable. Firstly, if I have a bunch of parameters and each set of parameters is assigned an output is it possible to train a model to predict an output given similar parameters? I am able to get hundreds of thousands samples (if needed) in order to train it so is this possible?
Secondly, after the model is trained how fast can it actually generate results?
Lastly, assuming everything up until this point checks out what is the best method in Java’s tensor flow to train a model with data that has multiple parameters associated with an outcome? Also in the result a given piece of data satisfies two results both can be returned as options ordered from most likely to least.
Also just to clarify I am not asking someone to make this for me I am just trying to make sure that a solution exists and is quick (if it’s slow I could just go back to brute forcing which I am trying to move away from since is kinda slow and resource intensive). Also, if you have any pointers on getting started tackling this I would greatly appreciate it!
Your question is very, very general, but I'll try to offer some insight:
Firstly, if I have a bunch of parameters and each set of parameters is assigned an output is it possible to train a model to predict an output given similar parameters?
Taking a set of parameters (known as the feature set X) and making predictions of another set of parameters (known as the output set Y) is the primary purpose of machine learning. Exactly how to do this requires many steps, how to do it well takes a lot of experience... However if you are asking if it is possible in principle, that depends on the specific feature set X, and output set Y.
I am able to get hundreds of thousands samples (if needed) in order to train it so is this possible?
The trick to machine learning is the data must be of a sufficient quantity and quality. This takes domain specific knowledge to know.
Are you able to provide any specifics about your data to help us understand?

Genetic Algorithm for Appliance Scheduling in java

i am doing a project on household appliance scheduling using genetic algorithm in java. I have little knowledge of genetic algorithm and Java programming. I would really appreciate if anyone could help me.
My project is to schedule appliances like washing machine, aircon etc. in a 48 time slot with varying electricity price for each slot but it stays constant in one slot. My objective is to have minimum cost. Using binary to represent the appliance ON/OFF. Solution should be in n x m matrix
For washing machine for example, it has a cycle of 1 hour, thus the binary should look like this "0000110000..." and not " 0001010000" and also there is preferred ON period for appliances for example 6-8am and 6-10pm and if the appliance is to be used 2x a day then it will be 1x during the 6-8am slot and 1x during the 6-10pm.
Also i have to include renewable source(PV) to sell when the price is right or store the energy to supply when it is not worth to sell. I'm not sure how. Should this be another GA? Or can it be together?
How do i start to program this? And how do i use excel file to store info about appliance so that i can extract it from excel when i need.
Thank you.
first I suggest develop the model for the genetic algo, i didn't understand exactly how the model is going to work
you need to define those key components:
how to represent the problem with chromosomes (building blocks)
how to induce mutation and breed between 2 (or more) chromosomes
fit function to evaluate each solution
I suggest because of your lack of knowledge in java, start with a coding lang you familiar with, best approach will be an oriented data lang like Python or R, if you don't familiar with any I suggest go with Python
once you develop and tested your model (the hard part) you can write it in java if you want to... (my suggestion is to use python all the way)
I suggest focus on that first, all other utilities like excel csv and such are pretty straight forward once you have your model and data figured out and implemented
the good news you are using the best approach to solve this NP problem, I suggest to search in the internet for implementation of this problem's variants
also take a look at this solution to the traveling salesman problem to get familiar with the genetic algo approach

Roommate matching algorithm

I'm currently in an advanced data structure class and learned a good bit about the graph. For this summer, I was asked to help write an algorithm to match roommates. Now for my data structure class, I've written a City Path graph and performs some sorting and prims algorithms and I'm sort of thinking that a graph may be a great place to start with my roommate matching algorithm.
I was thinking that our data base could just be a text file, nothing too fancy. However I could initialize each nodes in the graph as a student each student would have an un-directed edge to many more students (no edge to the student who doesn't want to be roommate with another one, the sorority also doesn't want repeating roommate). Now I could also make the edge weights more, depending on the special interest.
Everything listed above is quite simple and I don't think I'll run into any problem implementing it. But here is my question:
How should I update the common interest field? Should I start that with a physical survey and then go back into the text file and update the weight of the edge manually? Or should I be creating a field that keeps track of the matching interests?
What you're trying to design is called bipartite matching. Fortunately unlike other bipartite matching algorithms, you won't need fancy graph algorithms and complex implementation for this. This is very close of Stable Marriage Problem and surprisingly there are very effective even easier algorithm for this.
If you are interested, I can share my C++ implementation of stable marriage problem.

visual graph representation in gui

So I am working on this project for class and the assignment was to build a digraph in java and have it resemble all of the courses in the CS department. With the course prerequisites edges leading into the courses that have the other course as a prerec. I did the assignment I just want to take it farther for my own knowledge and want to make a gui representation of the graph. I also want it to be able to handle different kinds of course inputs not just the ones from the CS department. So the problem I am running into is generating X amount of buttons to represent the courses. I can make it with a fixed number I am just not sure how I would do it with a X amount. Any guidance is appreciated
If you want to explore doing it yourself, you can combine GraphPanel, cited here, with PointyThing, seen here. Alternatively, look at one of the graph libraries mentioned here.

String analysis and classification

I am developing a financial manager in my freetime with Java and Swing GUI. When the user adds a new entry, he is prompted to fill in: Moneyamount, Date, Comment and Section (e.g. Car, Salary, Computer, Food,...)
The sections are created "on the fly". When the user enters a new section, it will be added to the section-jcombobox for further selection. The other point is, that the comments could be in different languages. So the list of hard coded words and synonyms would be enormous.
So, my question is, is it possible to analyse the comment (e.g. "Fuel", "Car service", "Lunch at **") and preselect a fitting Section.
My first thought was, do it with a neural network and learn from the input, if the user selects another section.
But my problem is, I don´t know how to start at all. I tried "encog" with Eclipse and did some tutorials (XOR,...). But all of them are only using doubles as in/output.
Anyone could give me a hint how to start or any other possible solution for this?
Here is a runable JAR (current development state, requires Java7) and the Sourceforge Page
Forget about neural networks. This is a highly technical and specialized field of artificial intelligence, which is probably not suitable for your problem, and requires a solid expertise. Besides, there is a lot of simpler and better solutions for your problem.
First obvious solution, build a list of words and synonyms for all your sections and parse for these synonyms. You can then collect comments online for synonyms analysis, or use parse comments/sections provided by your users to statistically detect relations between words, etc...
There is an infinite number of possible solutions, ranging from the simplest to the most overkill. Now you need to define if this feature of your system is critical (prefilling? probably not, then)... and what any development effort will bring you. One hour of work could bring you a 80% satisfying feature, while aiming for 90% would cost one week of work. Is it really worth it?
Go for the simplest solution and tackle the real challenge of any dev project: delivering. Once your app is delivered, then you can always go back and improve as needed.
String myString = new String(paramInput);
if(myString.contains("FUEL")){
//do the fuel functionality
}
In a simple app, if you will be having only some specific sections in your application then you can get string from comments and check it if it contains some keywords and then according to it change the value of Section.
If you have a lot of categories, I would use something like Apache Lucene where you could index all the categories with their name's and potential keywords/phrases that might appear in a users description. Then you could simply run the description through Lucene and use the top matched category as a "best guess".
P.S. Neural Network inputs and outputs will always be doubles or floats with a value between 0 and 1. As for how to implement String matching I wouldn't even know where to start.
It seems to me that following will do:
hard word statistics
maybe a stemming class (English/Spanish) which reduce a word like "lunches" to "lunch".
a list of most frequent non-words (the, at, a, for, ...)
The best fit is a linear problem, so theoretical fit for a neural net, but why not take immediately the numerical best fit.
A machine learning algorithm such as an Artificial Neural Network doesn't seem like the best solution here. ANNs can be used for multi-class classification (i.e. 'to which of the provided pre-trained classes does the input represent?' not just 'does the input represent an X?') which fits your use case. The problem is that they are supervised learning methods and as such you need to provide a list of pairs of keywords and classes (Sections) that spans every possible input that your users will provide. This is impossible and in practice ANNs are re-trained when more data is available to produce better results and create a more accurate decision boundary / representation of the function that maps the inputs to outputs. This also assumes that you know all possible classes before you start and each of those classes has training input values that you provide.
The issue is that the input to your ANN (a list of characters or a numerical hash of the string) provides no context by which to classify. There's no higher level information provided that describes the word's meaning. This means that a different word that hashes to a numerically close value can be misclassified if there was insufficient training data.
(As maclema said, the output from an ANN will always be floats with each value representing proximity to a class - or a class with a level of uncertainty.)
A better solution would be to employ some kind of word-relation or synonym graph. A Bag of words model might be useful here.
Edit: In light of your comment that you don't know the Sections before hand,
an easy solution to program would be to provide a list of keywords in a file that gets updated as people use the program. Simply storing a mapping of provided comments -> Sections, which you will already have in your database, would allow you to filter out non-keywords (and, or, the, ...). One option is to then find a list of each Section that the typed keywords belong to and suggest multiple Sections and let the user pick one. The feedback that you get from user selections would enable improvements of suggestions in the future. Another would be to calculate a Bayesian probability - the probability that this word belongs to Section X given the previous stored mappings - for all keywords and Sections and either take the modal Section or normalise over each unique keyword and take the mean. Calculations of probabilities will need to be updated as you gather more information ofcourse, perhaps this could be done with every new addition in a background thread.

Categories