OpenRules Platform

Decision Optimization

Smart Investment

Build an investment decision model that allocates resources while respecting business constraints and optimization goals.

Problem. The problem was defined at https://dmcommunity.org/challenge-july-2024/ as Challenge July-2024:

image

Problem Definition. Let’s start with the glossary:

image

Here we used the business concept “Investment” which refers to our input data such as “Total Amount to Invest”, “Min to Invest”, “Max to Invest”, and our only output variable “OverallGain.” Each Investment contains the array “Stocks” of the type Stock[] where each Stock is defined by its Name, CurrentPrice, and ProjectedPrice.

Here is a test case:

image
image

Defining Decision Variables

For this problem, key constrained (unknown) variables represent how many stocks we want to purchase. Their values vary from 0 to a possible maximum investment. So first, we should define and calculate an intermediate decision variables “PossibleMaximumInvestment” and “Cheapest Stock Price”:

image

We also will need an array “StockProfits” that includes projected profit/loss for each stock:

image

Now, we are ready to define our unknown variables for each stock that represent how many stock items we recommend purchasing. We will use the Rule Solver column “SolverCreate” to do that and the column “SolverAddVariableToArray” to create an array of these Solver variables “StockVariables”:

image

The {{Name of Stock}} tells the Solver to use the actual name of the current stock (and not the words “Name of Stock”). The domain “0-{{PossibleMaximumInvestment}}” will be replaced with the proper value for each stock, from 0 to PossibleMaximumInvestment.

Then we will define the investment variables for each stock, post constraints on them to limit them by “Min to Invest” and “Max to Invest”, and add them to the array “StockInvestmentVariables”:

image

Then we will define the Solver variable for “OverallStock”

image

and post a constraint that it should not exceed “Total Amount to Invest”

image

This table

image

will set “OverallGain” as our optimization objective.

When Rule Solver finds an optimal solution, we will use the following tables to assign it back to our business output variable:

image

Here are the top-level tables “Define” and “Solve” that invoke the above tables:

image

Rule Solver will find the following optimal solution:

Solution #9:

  • ABC[120] XYZ[20] TTT[10] LMN[200]
  • ABCInvest[3000] XYZInvest[1000] TTTInvest[1000] LMNInvest[5000]
  • OverallGain[4650]

*** Execution Profile ***
Number of Choice Points: 1533
Number of Failures: 1522
Execution time: 65 msec

Try Rule Solver

Build decision models that find the best answer.

Start with the free evaluation, then install Rule Solver and explore its optimization examples.