Inside/Outside Production

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 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.

Decision Model

The proper decision model is implemented as a simple project, “InsideOutsideProduction” coming with OpenRules Rule Solver. This example is based on the decision model “InsideOutsideProduction” located in “openrules.solver/ADVANCED”.

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 “InsideP1” or “OutsideP2” with possible values from 0 to the Demand of this particular product:

It also adds the product variables to the arrays “InsideVariables” and “OutsideVariables” that will be needed to specify optimization objectives.

The table “DefineDemanVariables” defines the demand variables like “DemandP1” that should be equal to the sum of variables “InsideP1” and “OutsideP1”:

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

The table “ConsumptionConstraints”

for each resource R in the array “Resources” does the following. First, it executes this table to define an array with all resource consumption variables for each consumption in the array “Consumptions”:

Then it executes this table to post the main consumption constraint for each resource:

To define optimization objectives, first we need to use temporary arrays “InsideCosts” and “OutsideCosts” 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:

Here are the execution results for the first test case: