Factory, Warehouse, Sales Allocation Model: Solver-Based

This example shows how to set up and solve a mixed-integer linear programming problem. The problem is to find the optimal production and distribution levels among a set of factories, warehouses, and sales outlets. For the problem-based approach, see Factory, Warehouse, Sales Allocation Model: Problem-Based.

The example first generates random locations for factories, warehouses, and sales outlets. Feel free to modify the scaling parameter , which scales both the size of the grid in which the production and distribution facilities reside, but also scales the number of these facilities so that the density of facilities of each type per grid area is independent of .

Facility Locations

For a given value of the scaling parameter , suppose that there are the following:

factories

warehouses

sales outlets

These facilities are on separate integer grid points between 1 and in the and directions. In order that the facilities have separate locations, you require that . In this example, take , , , and .

Production and Distribution

There are products made by the factories. Take .

The demand for each product in a sales outlet is . The demand is the quantity that can be sold in a time interval. One constraint on the model is that the demand is met, meaning the system produces and distributes exactly the quantities in the demand.

There are capacity constraints on each factory and each warehouse.

The production of product at factory is less than .

The capacity of warehouse is .

The amount of product that can be transported from warehouse to a sales outlet in the time interval is less than , where is the turnover rate of product .

Suppose that each sales outlet receives its supplies from just one warehouse. Part of the problem is to determine the cheapest mapping of sales outlets to warehouses.

Costs

The cost of transporting products from factory to warehouse, and from warehouse to sales outlet, depends on the distance between the facilities, and on the particular product. If is the distance between facilities and , then the cost of shipping a product between these facilities is the distance times the transportation cost :

The distance in this example is the grid distance, also known as the distance. It is the sum of the absolute difference in coordinates and coordinates.

The cost of making a unit of product in factory is .

Optimization Problem

Given a set of facility locations, and the demands and capacity constraints, find:

A production level of each product at each factory

A distribution schedule for products from factories to warehouses

A distribution schedule for products from warehouses to sales outlets

These quantities must ensure that demand is satisfied and total cost is minimized. Also, each sales outlet is required to receive all its products from exactly one warehouse.

Variables and Equations for the Optimization Problem

The control variables, meaning the ones you can change in the optimization, are

These random demands and capacities can lead to infeasible problems. In other words, sometimes the demand exceeds the production and warehouse capacity constraints. If you alter some parameters and get an infeasible problem, during solution you will get an exitflag of -2.

Generate Objective and Constraint Matrices and Vectors

The objective function vector obj in intlincon consists of the coefficients of the variables and . So there are naturally P*F*W + S*W coefficients in obj.

One way to generate the coefficients is to begin with a P-by-F-by-W array obj1 for the coefficients, and an S-by-W array obj2 for the coefficients. Then convert these arrays to two vectors and combine them into obj by calling

obj = [obj1(:);obj2(:)];

obj1 = zeros(P,F,W); % Allocate arrays
obj2 = zeros(S,W);

Throughout the generation of objective and constraint vectors and matrices, we generate the array or the array, and then convert the result to a vector.

To begin generating the inputs, generate the distance arrays distfw(i,j) and distsw(i,j).

For example, how many sales outlets are associated with each warehouse? Notice that, in this case, some warehouses have 0 associated outlets, meaning the warehouses are not in use in the optimal solution.