Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision...
Transcript of Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision...
![Page 1: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/1.jpg)
Jacob Feldman, PhD
OpenRules, Inc.
Chief Technology Officer
Developing
Decision Optimization Microservicesfor Real-World
Decision-Making Applications
![Page 2: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/2.jpg)
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:
![Page 3: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/3.jpg)
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
![Page 4: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/4.jpg)
• 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
![Page 5: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/5.jpg)
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, …
![Page 6: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/6.jpg)
DEMO: Building a Decision Optimization Service
• An advanced Vacation Days decision model:
![Page 7: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/7.jpg)
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
![Page 8: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/8.jpg)
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
![Page 9: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/9.jpg)
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
![Page 10: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/10.jpg)
DEMO: Building a Decision Optimization Service
Business Problem: decision tables in Excel
![Page 11: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/11.jpg)
DEMO: Building a Decision Optimization Service
OptimizationProblem.java: defined using JavaSolver API
There is no
minimize()
![Page 12: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/12.jpg)
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
![Page 13: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/13.jpg)
DEMO: Testing Decision Optimization Service
Business Problem:
![Page 14: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/14.jpg)
DEMO: Testing Decision Optimization Service
Optimization Problem results:
![Page 15: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/15.jpg)
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
![Page 16: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/16.jpg)
Deployed as AWS Lambda
• deployLambda.bat – to deploy the decision model as AWS Lambda
• testLambda.bat – to
test AWS Lambda
• It also generates JSON
![Page 17: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/17.jpg)
Running Lambda from POSTMAN
Other deployment options
![Page 18: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/18.jpg)
• 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/
![Page 19: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/19.jpg)
An Example of a More Complex Optimization Service
Worker Scheduler
DEMO: http://amazon.openrules.com:8080/DoctorPlanning/
![Page 20: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/20.jpg)
Implementation
Worker Scheduler
AWS
EC2 AWS
Lambda
![Page 21: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/21.jpg)
Another Example:
Inside/Outside Production
Worker Scheduler
Implementation:
![Page 22: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/22.jpg)
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!
![Page 23: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:](https://reader033.fdocuments.us/reader033/viewer/2022053118/609f14792eb802124667e770/html5/thumbnails/23.jpg)
Advantages of Incorporating
Optimization Engines in Business Decision Models