Genetic Algorithm for Appliance Scheduling in java - 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

Related

Neural networks in evolution simulator- how to calculate error without expected result

I am creating an evolution simulator in Java. The simulation consists of a map with cold/hot regions and high/low elevation, etc'.
I want the creatures in the world to evolve in two ways- every single creature will evolve it's AI during the course of his lifetime, and when a creature reproduces there is a chance for mutation.
I thought it would be good to make the brain of the creatures a neural network that takes the sensor's data as input (only eyes at the moment), and produces commands to the thrusters (which move the creature around).
However, I only have experience with basic neural networks that recieve desired inputs from the user and calculate the error accordingly. However in this simulator, there is no optimal result. Results can be rated by a fitness function I have created (which takes in count energy changes, amount of offsprings, etc'), but it is unknown which output node is wrong and which is right.
Am I using the correct approach for this problem? Or perhaps neural networks are not the best solution for it?
If it is a viable way to achieve what I desire, how can I make the neural network adjust the correct weights if I do not know them?
Thanks in advance, and sorry for any english mistakes.
You ran into a common problem with neural networks and games. As mentioned in the comments a Genetic algorithm is often used when there is no 'correct' solution.
So your goal is basically to somehow combine neural networks and genetic algorithms. Luckily somebody did this before and described the process in this paper.
Since the paper is relatively complex and it is very time consumeing to implemwnt the algorithm you should consider using a library.
Since I couldn't find any suiting library for me, I decided to write my own one, you can find it here
The library should work good enough for 'smaller' problems like yours. You will find some example code in the Main class.
Combine networks using
Network.breedWith(Network other);
Create networks using
Network net = new Network(int inputs, int outputs);
Mutate networks using
Network.innovate();
As you will see in the example code it is important to always have an initial amount of mutations for each new network. This is because when you create a new network there are no connections, so innovation (fancy word for mutation) is needed to create connections.
If needed you can always create copys of networks (Network.getCopy();). The Network class and all of its attributes implement serializable, so you can save/load a network using an ObjectOutputStream.
If you decide to use my library please let me know what results you got!

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.

Which algorithm to use to classify data by using 3 different parameters?

I am trying to develop an android (java) project for my Artificial Intelligent thesis. It is shortly based on story reading and word quiz. One person reads a story and marks the words that he doesnt know. These words are registered to WordPortfolio db that has "Word_id", "Seen"(how many times), "Asked" (How many times asked in quiz), "Right"(how many times answered right).
I have "Words" table in my db that has 3 different parameters to make one word unique. Those are "Priority", "Level" and a specifier whether it is a Verb, Noun, Adj, Adv. etc.
What I want to ask is;
Which algorithm can I use to classify these words to ask a "word-meaning question" wisely to the learner? I want learner to see the words he had seen in story-reading part more than one to consolidate the meaning of it and also I want him to learn new words.
There are many types of algorithms designed to do this. For instance, you could use a linear regression, nearest neightbor, clustering, or neural network. http://en.wikipedia.org/wiki/List_of_machine_learning_algorithms provides a pretty comprehinsive list of the options out there.
I would also see if your library has the book "Programming Collective Intelligence" by Toby Segaran (http://shop.oreilly.com/product/9780596529321.do) or something similar in your library.
classification and clustering algorithms has implemented in many artificial intelligence software's such as MATLAB,WEKA,etc. you can see a sample of this in WEKA Text Classification for First Time & Beginner Users but i think your problem will have a good performance on MAP/REDUCE Freamework. I suggest you to use MAHOUT in your Problem which has a parallel framework and you can compromise your speed of other platforms with it.

Concurrently search a game tree using minimax and AB pruning. Is that possible?

I'm going be competing in a board game AI competition at my school and am trying to come up with some ideas for concurrency to gain an edge. I will most likely be at a disadvantage because I will be implementing it in java and I understand c or c++ would be much faster.
It doesn't seem like you could just split the game tree in half because of the move ordering which should leave the best moves first and it seems that it would be difficult or maybe even impossible to communicate the current alpha/beta at a given depth. I'm going to be using transposition tables as well which would need to be synchronized.
Besides searching, is there something that a second thread could be doing which could aid in the search or provide some type of speed increase. Each AI will have 5 seconds to make a move and your program can be working while the opponent is thinking.
Any input, no matter how obscure, would be appreciated.
An overview can be found in the Chess Programming Wiki's parallel search article. Even if your actual game is not chess, many concepts will also apply. The site also covers sophisticated solutions for shared transposition tables.
However, when you don't have much time, I would not start with a parallel search. You are correct that parallelism can increase the strength of the search algorithm. It is very difficult to get it right, though, and the benefits are way lower than one would expect.
If you want to experiment with parallelism, go ahead. It is an interesting topic. However, if you just want to get the best results in a limited amount of time, I would recommend to stick with a sequential search, and instead focus on move ordering and correctness.
It is possible. You have to make communication between threads to have AB prunning help. Also, move ordering must be tweaked, it doesn't help if one thread has the best-rated moves to analyze while the others not.

Want to implement a reinforcement learning connect four agent

I want to implement a reinforcement learning connect four agent.
I am unsure how to do so and how it should look. I am familiar with the theoretical aspects of reinforcement learning but don't know how they should be implemented.
How should it be done?
Should I use TD(lambda) or Q-learning, and how do MinMax trees come in to this?
How does my Q and V functions work (Quality of action and Value of state). How do I score those things? What is my base policy which I improve, and what is my model?
Another thing is how should I save the states or statesXactions (depending on the learning algorithm). Should I use neural networks or not? And if yes, how?
I am using JAVA.
Thanks.
This might be a more difficult problem than you think, and here is why:
The action space for the game is the choice of column to drop a piece into. The state space for the game is an MxN grid. Each column contains up to M pieces distributed among the 2 players.This means there are (2M+1-1)N states. For a standard 6x7 board, this comes out to about 1015. It follows that you cannot apply reinforement learning to the problem directly. The state value function is not smooth, so naĆ­ve function approximation would not work.
But not all is lost. For one thing, you could simplify the problem by separating the action space. If you consider the value of each column separately, based on the two columns next to it, you reduce N to 3 and the state space size to 106. Now, this is very manageable. You can create an array to represent this value function and update it using a simple RL algorithm, such as SARSA.
Note, that the payoff for the game is very delayed, so you might want to use eligibility traces to accelerate learning.

Categories