23
Jacob Feldman, PhD OpenRules, Inc. Chief Technology Officer Developing Decision Optimization Microservices for Real-World Decision-Making Applications

Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Developing Decision Optimization Microservices · 2020. 6. 30. · DEMO: Building a Decision Optimization Service Invoke Optimization Problem from the Excel’s table “Code”:

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”:

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”:

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”:

• 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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

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”:

• 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”:

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”:

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”:

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”:

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”:

Advantages of Incorporating

Optimization Engines in Business Decision Models