Intro: CPLEX Studio for Linear Programming

Introducing IBM ILOG CPLEX Optimization Studio for Linear Programming by solving a simple puzzle.

Consider the following problem:

300 boxes need to be loaded and shipped to a supermarket from a warehouse.

We may rent lorries that can accommodate 40 boxes and 30 boxes, costing us RM 500 and ​RM 400 respectively.

How many lorries of each type to load all boxes while minimising the cost?

How many lorries of each type do we need?

warehousing-cargo-logistics-storage-transportation-shipping-delivery-loader-boxes-near-truck

Our goal is to minimise the cost of loading these boxes by selecting the right amount of the different lorries.

A box costs RM 12.50 for 40-boxes-lorry (​RM 500 / 40 boxes) and ​RM 13.33 for 30-boxes-lorry.

So we would prefer the 40-boxes-lorry over 30-boxes-lorry, for cheaper unit price.

We first put 280 boxes into 7 lorries of 40-boxes for RM 3500 (7 x ​RM 500).

Then we add an eighth 30-boxes-lorry for RM 400 for the remaining 20 boxes.

Total cost is RM 3900 for 8 lorries.

This looks fine.

But this is not the best solution.

Better Solution – Saving extra RM 100!

With 6 lorries of 40 boxes (240 boxes @ RM 3000) and 2 lorries with 30 seats (60 boxes @ ​RM 800), we can load all the boxes and pay only ​RM 3800.

We can save RM 100!

The best decision is not that obvious.

Solving puzzle with CPLEX

We can easily solve the puzzle above with CPLEX code:

dvar int+ nLorry30;
dvar int+ nLorry40;

minimize 400 * nLorry30 + 500 * nLorry40;

subject to {
    30 * nLorry30 + 40 * nLorry40 >= 300;
}

execute {
    writeln("Minimised Cost:", cplex.getObjValue());
    writeln("nLorry30:", nLorry30);
    writeln("nLorry40:", nLorry40);
}

and get the result:

Minimised Cost:3800 
nLorry30:2 
nLorry40:6

Solving Real World Problems for Millions of ROI

This problem is a very simple example with only 2 variables, which are 2 types of lorries.

In reality, real business problems in real companies can contain up to thousands or more variables.

Solving it using our brain purely or graphically is totally impossible.

With modern tools, like CPLEX, companies can tackle more complex real-world problems and the return of investment would not be just RM 100 as in our toy lorry problem but millions of dollars.

Other pratical applications are production planning, resource allocation, investment decisions, military operations, inventory management, transportation scheduling,… etc.

IBM Decision Optimization Use Cases

In the coming lessons, we will be revisiting how to code in CPLEX/OPL to solve this puzzle in details!