Final Blog Post

This is my final blog post. It has been a great semester. I know I picked the right major because most of my project didn't feel like work. I truly enjoyed working on my project throughout the semester. That being said, I am happy with how my project turned out. Before this project, I had no idea what a genetic algorithm was, and towards the end I was getting nervous because the algorithm wasn't working like I wanted it to. But it all turned out in the end.


Here are some images of the final application.

Launch Screen    Configuration Screen    Run Screen    Final Screen


Here are some images of pictures the genetic algorithm generated next to the original image the algorithm was given.

Balloons    Balloons Generated

Geometric    Geometric Generated

Pooh    Pooh Generated

Credit to Dr. McVey for generating the balloon image.

Monday, April 5th (Week 10)

It's been a while since I've last made a blog post, but I have made significant progress since the last update.

I currently have an algorithm, but it doesn't work very well. I can enter an image into the algorithm and it will start by creating a generation 0, then proceed to crossover and mutate populations to create the next generations. My problem is that the overall fitness of the generations don't really improve.

I previously had an issue with pointers and references in Java. Java passes all parameters by value, there is no passing by reference in Java. For primitive types and strings, this doesn't cause any issues, but for objects, it is a difference story. For programmer-created classes (and other classes) when passing to a function, Java passes the value of the pointer to the function. So, the parameter is not a pointer itself but the value stored in the parameter is the value of the pointer to the object in the program heap. Obviously, this creates some confusion.

When I first tested my algorithm, I used strings instead of populations (a class created by me), so I didn't have pointer issues and couldn't figure out why the fitnesses of populations were getting worse when they weren't supposed to.

I have fixed the pointer issue but the algorithm still doesn't work as it is supposed to. That is pretty much what the rest of my time working on my project is going to consist of. After that, all I have to do is implement the algorithm into the GUI and make minor UI improvements.

Tuesday, March 9th (Week 6)

In the last week, I've spent a lot of time working on the GUI for my project. This probably shouldn't be my focus right now but it needs to be done eventually. When I originally learned Java GUI, we used the Swing and Abstract Window Toolkit (AWT) libraries. In 2012, Oracle released JavaFX for Java GUI programming and that has become the new standard.

I spent most of the weekend watching JavaFX tutorials and I now have a working GUI written in JavaFX instead of Swing and AWT. Overall, I like the look of the JavaFX GUI much better than the Swing GUI. One thing I like better about JavaFX is that the layout managers are much easier to work with. Another thing I like is that you can create different scenes for your program, so it is really easy to create a starting screen with information about the program and then flip to a different scene with the click of a button.

One of the biggest things that set JavaFX apart from Swing and AWT is that you can style your application with CSS. JavaFX also has a Scene Builder which lets you drag and drop GUI elements on to a scene and it creates the code for you. I am sure will end up using that eventually so that my application looks more visually appealing.

GUI 03-09-2021    small triangles

I also worked on the size of the shapes that are randomly generated. When I met with Dr. McVey, she suggested that I limit the size of the polygons so I don't get ones that fill the whole screen. To limit the size of the triangles, I create the first point and then create another point and calculate the distance between the points measured in pixels. If the distance is greater than 75 pixels, then a new point is generated until it is within 75 pixels of the original point.

Wednesday, March 3rd (Week 5)

The biggest breakthrough I have made in the past week and a half is being able to draw random shapes to the screen. This is a very import part of my application, because if I can't draw shapes to the screen, I don't have an application.

I watched a couple tutorials on how to draw shapes to the screen, and multiple recommended that you use a custom canvas class that extends the Java 'Canvas' object. The first iteration/generation of the generated image is completely random, made of shapes that the user will be able to pick.

For now, I just hard-code in the number of vertices. To generate random shapes, I use nested for-loops. The inner for loop generates the points of the shape based on the number of vertices, and the outer for-loop determines how many shapes will be drawn to the screen. There are a couple screen shots below of random shapes the program generated.

The shapes used, in order from left to right: triangles, quadrilaterals, pentagons

triangles    quadrilaterals    pentagons

I am a little behind the schedule I created for myself. I just finished researching which Java data structures will work best for my project. I researched a couple different data structures and narrowed the possiblities down to three: ArrayList, LinkedList, and Vector. All three data structures were pretty similar in performance. One thing I did note though is that Java uses a doubly-linked list which means it uses more memory. I think I am going to stick with ArrayLists because I have used them before and I am familiar with them.

Friday, February 19th (Week 3)

I've made some steady progress on the textbook I got from the library. It is really helping me understand geneitc algorithms better.

Last time, I talked about doing my project in Python. Python is not my favorite language and trying to learn Python all while learning about Genetic Algorithms felt like I was trying to learn too much at once.

I am now doing my project in Java. Java is my favorite language to code in, probably because it was language that I first learned. There is almost no learning curve with Java. It didn't take me that long to get a GUI up and running in Java while it took me several hours to do the same thing in Python.

Wednesday, February 8th (Week 2)

Welcome to my first blog post! Last week, Dr. McVey gave us our topics. Aldo and I's projects both use genetic algorithms, so we met with Dr. McVey together and she gave us a little information on how to get started.

Dr. McVey recommended that I get a textbook from the library on genetic algorithms. So far, the one that I checked out has been pretty helpful. The book uses Python to show examples. I am relatively new to Python, but I am eager to learn more about it. Dr. McVey said Python has a good visual library and I think that will help a lot given my project topic, so I am pretty sure I am going to use Python for my project. I know that previous projects using genetic algorithms were written in C# so I am excited to do something different.

My project seems pretty daunting right now because I have never done something like it, but I am eager to get working on it more in the coming weeks. I will probably spend this weekend reading the textbook and exploring some of its examples.