If you to use Java Solver in conjunction with OpenRules Decision Manager, you may easily deploy your decision optimization model as an Decision Optimization Microservice, namely an AWS Lambda function. Usually this process requires some programming efforts and complex configuration. OpenRules essentially simplifies this process.
Traditionally to deploy a Java-based program as a AWS Lambda function you need to go through serious configuration efforts. For instance, you may follow a path similar to the one described here:
-
- Put them into SpringBoot Environment
- Add several Java classes required by Spring for the service configuration
- Configure the service using AWS Lambda and AWS Gateway.
With OpenRules Decision Manager you can deploy your optimization models as AWS Lambdas with ONE CLICK and no additional programming! The basic idea is very simple:
-
- As usual, describe your Business Problem and its test cases using regular business rules in Excel in the OpenRules format
- Write a Java class called Optimization Problem (inherited from JavaSolver) to define your optimization problem
- Create an Excel-based table “SolveOptimizationProblem” of the OpenRules type “Method”
- Use the standard OpenRules “deployLambda.bat” to deploy the integrated model as AWS Lambda microservice.
The 3rd step is the most interesting one. It allows us to treat a Java-based Optimization Problem as a part of the rules-based decision model, and thus utilize the standard OpenRules deployment mechanism! Similarly you can deploy optimization models using RESTfull web services or Docker containers. While JavaSolver allows you to choose different off-the-shelf constraint or linear solvers, there is nothing that prevent us of integrating OpenRules directly with other Java-based solvers.
The following example explains how to deploy the decision model “Advanced Vacation Days” with a Java Solver optimization component as an AWS Lambda. This problem was offered as the DMCommunity Nov-2018 Challenge :
Every employee receives vacation days according to the following rules:
-
-
- Every employee receives at least 22 vacation days.
- Employees younger than 18 or at least 60 years, or employees with at least 30 years of service can receive extra 5 days.
- Employees with at least 30 years of service and also employees of age 60 or more, can receive extra 3 days, on top of possible additional days already given
- If an employee has at least 15 but less than 30 years of service, extra 2 days can be given. These 2 days can also be provided for employees of age 45 or more.
- A college student is eligible to 1 extra vacation day.
- If an employee is a veteran, 2 extra days can be given.
- The total number of vacation days cannot exceed 29.
-
The objective: give an employee as many vacation days as s/he is eligible to while satisfying all 7 rules. The rule 7 explicitly specifies the maximum of 29 vacation days that cannot be exceeded.
This decision model consists of two parts:
-
-
- A pure business part that specifies employee eligibility to all types of vacation days
- A more technical optimization part that deals with the Rule 7 and search of an optimal solution.
-
Business Data. Let’s start with the test data. We will need an information about the company that should include:
-
-
- Vacation Benefit Types
- Vacation Benefit Days (for each type)
- Max Vacation days (29)
-
Here is the proper Data table in Excel:
We also may define the corresponding Java class Company:
The following table describes test-employees:
And here is the corresponding Java class:
Each employee contains an array of eligibilities of this type:
Business Part. The following decision table defines eligibility of one employee to different vacation benefits:
To execute this table for all types of vacation benefits, we will use the following table:
Optimization Part. We will use Java Solver to represent optimization logic in the Java class “OptimizationProblem”:
To invoke this problem from Excel we define the following method:
And finally our decision model may use the following table to execute both business and optimization parts:
To test and deploy this integrated decision model we need to specify the file “project.properties”:
As you can see, it includes AWS Lambda deployment properties. So, it’s enough to double-click to the standard OpenRules file “deployLambda.bat” and it will generate all necessary Java files and will deploy this integrated Rule+Optimization decision model as AWS Lambda microservice:
If we run the generated “testLambda.bat” it will execute all out tests with an average execution time (including optimization!) withing 100 milliseconds!