Decision Intelligence Platform

Decision Playground: Inside/Outside Production

Problem
Graphical Interface
Finding Optimal Decisions
Filters
Decision Pool
Integrated Optimization Objective
Switching Solvers
Underlying Decision Model

Problem

We need to help a manufacturer decide how much of each demanded product should be produced internally and how much should be sourced from outside. Whether a product is made inside or outside, it has an associated cost. A product can consume a given amount of internal resources that have limited capacities. The general objective is to minimize the total production cost while ensuring the company meets the demand exactly or with a certain tolerance. This DMCommunity’s challenge provides the following data samples with products, resources, and capacity requirements:

The manufacturer wants to consider various production decisions to choose the most suitable ones based on the long-term resource availability and uncertain future demand. This sample demonstrates how OpenRules Decision Playground can be used to find the best production decision.

Graphical Interface

The proper decision model is implemented as a simple project, “InsideOutsideProduction” coming with OpenRules Rule Solver. You can find its implementation at the end of this page. Now you may use Decision Playground to generate various production decisions using the same decision model.

Click on “InsideOutsideProduction/play.bat” to start Decision Playground. Here is your Playground’s view after you click on “New Request” to select a JSON file with input data:

The proper JSON files, such as “testCases-1.json,” were generated based on the test cases in Excel during the testing of the decision model. Still, you may also create a JSON request manually or get it from your production system.

Finding Optimal Decisions

Then you may click on “Optimize” to get the following Decision Playground’s view:

Let’s say you first want to minimize the Total Production Cost. You can select “Total Production Cost” as your optimization objective and click “Minimize”. By default, OpenRules will use an underlying constraint solver to find an optimal solution, and after ~1 minute, you will receive the following decision:

This decision indicates which products, and in what quantities, should be produced internally versus externally to achieve the minimum possible total production cost of $5,020. You may memorize this decision in the Decision Pool by selecting “Add to Pool”:

Note. You can expedite this optimal search from 1 minute to under 1 second by switching from the default constraint solver to a linear solver – see below.

Probably you would like to produce more products internally, even if the total production cost would go slightly up. To do this, you may choose a different optimization criterion:

You will receive the following decision, which you may also add to the Decision Pool:

So, you may produce internally 18 products P1, 191 products P2, and 115 products P3 to achieve the maximum possible inside cost of $1,981. However, using this decision, your total production cost will grow from $5,020 to $5,618. You may define filters to find a trade-off decision.

Filters

So, you probably want to increase the total inside cost inside the interval [$1,440; $1,981] while still minimizing the total production cost. You may limit the total inside cost to be larger than $1,700 using the following Filter:

Save this filter and choose the following “Optimize”:

You will receive the following decision:

This decision will increase the you probably want to increase the total production cost only by $50, but produce more products internally. So, instead of the threshold of $1,700 we may try $1,800 by modifying the filter. Here is the resulting decision:

This decision looks even better. You may try two filters:

and again maximize the Total Inside Cost:

You will receive an even better decision:

Let’s save this decision in Decision Pool as well.

Decision Pool

Click on the button “Decision Pool” to compare all the saved decisions we received so far:

You can continue experimenting with different filters and optimization objectives to obtain the decisions that best suit your situation.

Integrated Optimization Objective

This decision model defines one more optimization goal called “Total Weighted Cost”, which is defined by the following formula:

totalInsideCost*insideWeight + totalOutsideCost*outsideWeight

In our request, we may define insideWeight=3 and outsideWeight=6. Then, without any filters, we may use the following optimization criterion:

It will give us the following decision:

You can save this decision and compare all found decisions by looking inside the Decision Pool:

Switching Underlying Solvers

OpenRules Rule Solver utilizes the standard JSR-331 API that allows you to easily switch between different constraint solvers and linear or MIP solvers without changing a character in your decision model. You start Decision Playground using a simple batch file “play.bat” that looks as follows:

To instruct the Playground to use an alternative solver, simply uncomment the corresponding setting above. For example, you can modify the above settings as follows:

Upon restarting the Playground, the linear solver Scip or a similar open-source or commercial MIP solver will be used, resulting in a substantial performance gain for this decision model. An optimal solution will be produced within 1 second, compared to the previous 1 minute.

Note. Not all decision models can use superfast linear or MIP solvers, as they may contain non-linear constraints. In these cases, you may rely on open-source constraint solvers such as “Constrainer” or “JSetL” that are built into the OpenRules Rule Solver.

Underlying Decision Model

This example is based on a very simple decision model – see file “openrules.solver/InsideOutsideProduction/rules/InsideOutsideProduction.xls”. Here is the Glossary:

Here are two main methods, “Define” and “Solve”, that are pretty common for decision models utilizing Rule Solver:

The table “DefineProductVariables” for each product P in the input array “Products” defines the proper constrained decision variables with names like “P1 Inside Var” or “P2 Outside Var” with possible values from 0 to the Demand of this particular product:

It also defines the demand variables like “P1 Demand Var” that should be equal to the sum of variables “P1 Inside Var” and “P1 Outside Var”. It adds the product variables to the arrays “Inside Variables” and “Outside Variables” that will be needed to specify optimization objectives.

The table “PostDemandConstraints” for each product P in the input array “Products” posts a constraint that states that the proper demand constrained decision variable should not be less than the required demand of this product:

The table “RequirentsConstraints”

for each requirement in the array “Requirements” executes the following three tables:

To define optimization objectives, we need to use arrays “Inside Costs: and “Outside Costs: that can be easily filled out by the regular OpenRules decision table “DefineInOutCosts”:

The following table defines all optimization objectives as new constrained decision variables:

The table “Solve” relies on the standard solving method “SolveWithOptions”. When a solution is found, this method automatically invokes the method “SaveSolution” if it exists. This decision model saves every solution using the following table:

If you make changes in the decision model, you need to restart Decision Playground to see how they affect the generated decisions.