Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision...
Transcript of Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision...
Jacob Feldman, PhD
OpenRules, Inc.
Chief Technology Officer
Developing
Decision Optimization Microservicesfor Real-World
Decision-Making Applications
1. There are plenty of very good off-the-shelf tools
for building stand-alone Decision Optimization
Services and the use of them is not as difficult as
people might think
2. Incorporating Decision Optimization Services into
Business Decision Models makes them “good
citizens” of the real-world of business decision
management
Two main points I will try to make today:
Customer Software
Landscape
Operational
Decision Service
Operational
Decision Service
Operational
Decision Service
BR
ML
CP/LP
Service
Orchestration
Platforms
Optimization (CP/LP) Services within
Decision Management World
• Split Decision Optimization Problem into 2 parts:
• Business Problem
• Define - using any busines rules modeling tool
• Solve – using a rule engine
• Optimization Problem
• Define – using a constraint reasoning tool
• Solve – using an off-the-shelf constraint or linear solver
• Deploy it like any other decision service within
this software landscape:
• cloud-based microservice, RESTful web service, Docker
container, using event streaming platform like Kafka,…
How to Build Decision Optimization Services:
Generic Approach
Off-the-shelf Constraint and Linear Solvers
• Free Open Source “JavaSolver.com” available from Maven and GitHub
• Provides a minimalistic Java API for multiple off-the-shelf solvers:
• Constraint Solvers: Sugar, Constrainer, Choco, JSetL,…
• Linear Solvers: CPLEX, Gurobi, SCIP, GLPK, COIN, …
DEMO: Building a Decision Optimization Service
• An advanced Vacation Days decision model:
DEMO: Test Data
Let’s look at our business concepts and decision variables:
Company:
Employee:
For each employee we need to define eligibilities to different benefits and
decide how better to apply them under certain constraints
DEMO: Building a Decision Optimization Service
• We split the problem in 2 parts:
• Business Problem:
• Define employee’s eligibility to different vacation day
benefits
• Solve with OpenRules
• Optimization Problem:
• Find such a combination of benefits that maximizes the
total vacation days but no more than 29 days
• Solve with JavaSolver
DEMO: Building a Decision Optimization Service
The Integrated Decision can be represented in this
OpenRules table in Excel:
So, we need to implement two sub-decisions:
• DefineEmployeeEligibilities
• SolveOptimizationProblem
DEMO: Building a Decision Optimization Service
Business Problem: decision tables in Excel
DEMO: Building a Decision Optimization Service
OptimizationProblem.java: defined using JavaSolver API
There is no
minimize()
DEMO: Building a Decision Optimization Service
Invoke Optimization Problem from the Excel’s table “Code”:
• Build, Test, Deploy
• test.bat – to build and test the decision model
• deployLambda.bat – to deploy the decision model ad AWS Lambda
DEMO: Testing Decision Optimization Service
Business Problem:
DEMO: Testing Decision Optimization Service
Optimization Problem results:
Switch between underlying
Constraint/Linear solvers
Just change the solver dependency in pom.xml:
test.bat – to re-build and test the same decision model with different solvers
Deployed as AWS Lambda
• deployLambda.bat – to deploy the decision model as AWS Lambda
• testLambda.bat – to
test AWS Lambda
• It also generates JSON
Running Lambda from POSTMAN
Other deployment options
• One of the favorite problem domains for Constraint Solvers
• DMCommunity Challenge Apr-2020
• Approach
* Understand the problem by developing GUI
* Solve the problem by calling a Decision Optimization Microservice (initially use a simple stub)
An Example of a More Complex Optimization Service
“Workforce Scheduling”
DEMO: http://amazon.openrules.com:8080/DoctorPlanning/
An Example of a More Complex Optimization Service
Worker Scheduler
DEMO: http://amazon.openrules.com:8080/DoctorPlanning/
Implementation
Worker Scheduler
AWS
EC2 AWS
Lambda
Another Example:
Inside/Outside Production
Worker Scheduler
Implementation:
Conclusion
• Creating Decision Optimization Microservices
• For Business Problem - use any Business Rules tool
• For Optimization Problem – use any off-the-shelf Constraint or Linear solvers
• One of many implementation approaches:
• What is important:
• Make Optimization Service a component of a larger Business Decision Model!
Advantages of Incorporating
Optimization Engines in Business Decision Models