For Those Who Want To Get Started With OptaPlanner

If you want to get started with OptaPlanner, the first thing you want to do is review the examples that come with it.

The second thing you will want to do is write your own HelloWorld. Hah! Not so easily done. Not that the existing examples don't provide all you would need, they provide that and much more. But they are written for a different purpose - to impress you quite artfully with just what OptaPlanner can do. That requires a lot of UI and persistence code, among other things. And it all might seem like it is very tightly woven together. It's not, but that doesn't make it much easier for someone like me to extract the essence of OptaPlanner into it's basic code fragments in a 10 minute code review.

If you run the examples that come from OptaPlanner and they don't blow you away with their power and art .... perhaps you haven't done much programming yet.

Yet what I needed was just the basics. Since it wasn't there in the examples, I created this git project to do just that. 270 lines of code, even including eclipse and maven project infrastructure.

Just fire it up, and you'll see the exact minimum of code to make the simplest OptaPlanner example work.

It's Too Simple - All It Does Is Deduce That You Wanted 5 Hellos

OptaPlanner is for NP-Complete math problems such as scheduling. It does it's work by substituting a range of planning variables and scoring solution. In so doing, it can sample from a complex combination of options without having to do every one brute force, which can sometimes take a seemingly infinite amount of processing power.

So doing something as simple as HelloWorld in OptaPlanner is painfully stupid. But this project finds the number 5 from a set of rules, and very well.

Up And Running In Seconds

Download it, run maven, run the main(). Shown below in 10 second video.

How I Am Using This Project To Learn OptaPlanner 

I have been changing up the rules to see what happens. Drools syntax is a must learn, so it helps me to do this in a simpler, more isolated environment.

I've also been messing around a bit with the whole idea of planningVariables, and planningEntities, and how they work together. This is still not entirely clear to me, so it helps me to experiment with them a little bit in isolation, before I do the real work that I am targeting for OptaPlanner.

I'm also trying to come up with how I want to handle the whole UI and persistence thing. Should I do a webapp? Or stick with a headless utility? So many options. So this helps me start clean from headless, and then I can expand from there as I think it through.

Is OptaPlanner The Most Interesting Project Out There?

What?  You don't know what OptaPlanner is? You have never heard of NP-Complete mathematical problems?

I will grant you this - nobody that I personally know thinks that this is an interesting area. Yet, to me, it is the most interesting area in all of computing. More interesting than applications, more interesting than big data and machine learning, more interesting than automation. Because the most interesting problems in the world cannot be solved with brute force or linear computing. They are NP-Complete mathematical problems.  And there are so many of them. Way too many to begin that discussion here.

It is also noteable that even the creator of OptaPlanner does not appear to see just how many human problems could be addressed by an engine such as OptaPlanner - which is advertised only for business planning problems. But this is a subject for another blog than this.

Geoffrey De Smet is OptaPlanner's brilliant creator. Or, at least, he sure seems brilliant to me. Great stuff.

Your Feedback? Was there an easier way?

It is entirely possible that I burned up some time writing this project when it was already written for me, I just never looked for it.

Please feel free to advise me if this is the case, or any other feedback you may wish to give me. My first name is Pete and my email address is my first name at dataFundamentals.com

Eventually something such as this might be found within the official optaPlanner examples. I've been careful to not include any license restrictions with this code, in case Geoffey wishes to take any of this code for such a usage.

Links:

Update: Why Might OptaPlanner Have Seemed Tightly Coupled With UI and Persistence Layers?

The genesis of this project was an xstream converter error. The persistence layer in the normal examples uses xstream to serialize and deserialize for persistence. So when I created my own project using example code without the persistence piece, this xstream error was very confusing. How could this be?

From using this simpler project I learned the source of the error. The solverConfig.xml file was written from OptaPlanner 6.0 example code, and my pom.xml had everything pointed to 6.1. There was a change in the xml types used, which caused the xstream error.

 I could have figured this out without creating a whole new project, but I didn't. I'm still glad I did, because there ended up being a number of other pieces which were easier to figure out in isolation. Still it was my error, not OptaPlanner's perceived tight coupling.