Optimization vs. Business Rules: pick your evil
People always expect more than the “it depends” answer. But in that case, how could anyone answer such a broad “apples and oranges” question? It is actually like asking if I recommend a hammer or a screwdriver… Of course it depends on the job at hand!
Trying to satisfy my audience, I thought about it very carefully. It has always been clear to me that this technology choice was not really about the nature of the problem as it was about the approach to solve it. Let me clarify what I mean after we settle on a common terminology.
What are those Technologies?
Optimization is about finding the best solution to a problem. You can either find any solution that works, get all possible solutions or select the best one based on some objective criteria. The premise is that you can describe the problem itself and the associated constraints that define a “good” solution. The technology is responsible for performing the optimized search.
Illustration – an optimization model might look like those problems we used to solve in school. For example:
- X is monthly income
- Y is the monthly mortgage payment which is known to be $3,000
- X must be greater than 3 times Y for the primary borrower
- What is the lowest income you need to get documentation for? *** this is what the engine figures out ***
Granted, this example is extremely simplistic. In reality a traditional optimization model might look at a loan request and define the best terms for the bank (i.e. highest margin) that have the best chance to be competitive for the applicant. Interestingly, the optimization job can also deal with much larger search space — for example, allocating gates in airports or scheduling crews over a large geography.
Business Rules are about describing how you go about getting to the end result. You can describe the various steps you might perform to reach an end state — often a decision but it could also be a configuration or, more generally, some set values. The rules engine is responsible for “sequencing” and executing those IF-THEN-ELSE statements.
Illustration – a rulebase might look like this:
- If the total income of the primary borrower is less than 3 times the loan monthly payment then require guarantor
- If the total income of the guarantor is less than 5 times the loan monthly payment then decline
For two rules only, a rules engine would definitely be overkill but consider that you may have thousands or millions of rules in your system. Regulations may force you to create many different alternatives of the same rule with variations per State or Country; different products may have slightly different governing rules; Gold customers might be treated differently than your general customer. The beauty of engine that executes them is that it does not care about overlap or sequencing. Those potentially huge volumes of rules will be executed very efficiently as it relates to repeated tests over several rules and consistently. I should add a caveat here that I am mostly referring to RETE-based engines. Non-inferencing engines would not necessarily provide the same convenience.
So What Makes Them Similar?
With those definitions in mind you might wonder why anyone would use one in place of the other one… Well, there is overlap. The most obvious one being the problem of CONFIGURATION.
If you want to find a valid configuration as a manufacturer, you could possibly go either way. I have seen either technology being used for:
- Computer assembly as well as Trucks — in both cases, the problem was to fit parts that may be mutually exclusive (you can only have one motherboard in the PC and only one type of tires on the truck), including some physical limitations (only so many slots in your PC, a V8 engine may not fit under certain hoods), etc.
- Manufacturing processes — Some gases may not mix too well; some drugs may interact…
- Services — Life insurance policies can be extremely complex to set up; Telecom services now including so many options do require some intelligence as to what is compatible / required…
- Even Sports! Games can be scheduled according to the league’s demands: alternating home and away games, avoid blocked dates (football stadium may be used for concerts or baseball game), etc. Similar demands may be made by the announcers for the ads scheduling… You may have attended my landmark presentation on NFL at Business Rules Forum last year.
The nature of the problem does not dictate the technology that is most appropriate. You need to focus on the type of outcome and the approach that stakeholders are comfortable with.
Usage Guidelines for Optimization
Optimization, per its name, is about finding the best solution to a problem. Especially when it is heavily constrained, that technology is very efficient at finding a feasible solution if it exists, or at letting you know that none exists which is valuable in itself. Furthermore, if that problem lends itself to ranking — where one solution might be more valuable than another and you ave a way to measure that — optimization technology will typically outperform other techniques.
Let me illustrate with a typical crew scheduling example.
Let’s say you have 1,000 engineers to dispatch. Jobs have been contracted and include a specific deadline. You need to make sure that each engineer is assigned to a job that matches his/her credentials. Your objective is to perform all the work within the allocated timeframe to avoid penalties.
Granted the standard Miss Manners rules benchmark solves a somewhat similar problem (not scheduling within a timeframe but placing guests next to each other according to topics of interest), but the rules using in that test are certainly not easy to understand since they refer to the mechanics of allocating those guests to their seats rather than the description of the end result. And more importantly, that design is very opaque… How would you inject additional rules to reflect that Joe never works on Fridays and that Jack and Jill can’t be collaborating on a project?
Usage Guidelines for Business Rules
Business Rules are very good at applying a technique that you know will get you to the end result. If the problem is not constrained, meaning that you will not get yourself into a corner when you assemble your configuration, then business rules offer some advantages. Since a heuristic will lead you to a solution rather than the set of all possible solutions, business rules would make more sense when all solutions are equal. You simply care about finding any configuration that works.
I have met end users that were not comfortable using optimization because it changes radically from the way they have always been business and they will not trust that the outcome will be satisfactory or in other words “as good as if they had done it manually”. For those guys, business rules offer the flexibility to describe the logic step by step, one rule at a time, and they can also review execution traces that justify how the system got to the recommendation.
Imagine you had a Sudoku grid and you fed it into an engine that filled it in completely. You might go and check each row, each column and each square… just to be sure. But if you had a step by step animation explaining that this “3” completes the top right square, you would not worry as much. You would likely make sure that the square logic, the row logic, the column logic, etc. work correctly then trust the system. People like to understand and be able to anticipate how systems work in order to trust them.
Let me use an example that is a little bit more serious. In the Telecom space, you might sign up for products and services. In a package, you might get to select phone, internet access, television and cell phone. Product Managers can describe using business rules what components are mandatory or optional. Business rules can also be used to define incompatibilities and requirements. You cannot have DSL and Fiber at the same time. You need local service to enable long distance. You must select one data plan for an iPhone or smart phone. The advantage of using business rules in that example is that you can reuse them in different contexts: to guide a consumer on the self-serve website, to script an agent’s conversation in a call center, to validate application transmitted electronically or by mail.
In a Nutshell
Searching a needle in a hay stack? And not just any needle? Then pick Optimization!
Your experts know the recipe? A solution is a solution? Then pick Business Rules!