# NATCOR Prerequisite Material for Course on Combinatorial ... · NATCOR Prerequisite Material for...

### Transcript of NATCOR Prerequisite Material for Course on Combinatorial ... · NATCOR Prerequisite Material for...

NATCOR

Prerequisite Material for Course on Combinatorial Optimization

The course on combinatorial optimization assumes a prior knowledge of the basic OR tools Linear and Integer Programming. If you have studied a course in Mathematical Programming at undergraduate or master’s level, then the material will be familiar to you. The notes below are based on materials prepared by John Beasley of Brunel University.

Part A: Linear Programming

1. Linear Programming – Getting Started

Example: Two Mines Company

The Two Mines Company own two different mines that produce an ore which, after being crushed, is graded into three classes: high, medium and low-grade. The company has contracted to provide a smelting plant with 12 tons of high-grade, 8 tons of medium-grade and 24 tons of low-grade ore per week. The two mines have different operating characteristics as detailed below.

Mine Cost per day (£'000) Production (tons/day) High Medium Low X 180 6 3 4 Y 160 1 1 6

How many days per week should each mine be operated to fulfil the smelting plant contract?

Note: this is clearly a very simple (even simplistic) example but, as with many things, we have to start at a simple level in order to progress to a more complicated level.

Guessing

To explore the Two Mines problem further we might simply guess (i.e. use our judgement) how many days per week to work and see how they turn out.

• work one day a week on X, one day a week on Y

This does not seem like a good guess as it results in only 7 tonnes a week of high-grade, insufficient to meet the contract requirement for 12 tonnes of high-grade a week. We say that such a solution is infeasible.

• work 4 days a week on X, 3 days a week on Y

This seems like a better guess as it results in sufficient ore to meet the contract. We say that such a solution is feasible. However it is quite expensive (costly).

Rather than continue guessing we can approach the problem in a structured logical fashion as below. Reflect for a moment though that really we would like a solution which supplies what is necessary under the contract at minimum cost. Logically such a minimum cost solution to this decision problem must exist. However even if we keep guessing we can never be sure whether we have found this minimum cost solution or not. Fortunately our structured approach will enable us to find the minimum cost solution.

Two Mines solution

What we have is a verbal description of the Two Mines problem. What we need to do is to translate that verbal description into an equivalent mathematical description.

In dealing with problems of this kind we often do best to consider them in the order:

1. variables 2. constraints 3. objective.

We do this below and note here that this process is often called formulating the problem (or more strictly formulating a mathematical representation of the problem).

(1) Variables

These represent the "decisions that have to be made" or the "unknowns".

Let

x = number of days per week mine X is operated y = number of days per week mine Y is operated

Note here that x >= 0 and y >= 0.

(2) Constraints

It is best to first put each constraint into words and then express it in a mathematical form.

• ore production constraints - balance the amount produced with the quantity required under the smelting plant contract

Ore High 6x + 1y >= 12 Medium 3x + 1y >= 8 Low 4x + 6y >= 24

Note we have an inequality here rather than an equality. This implies that we may produce more of some grade of ore than we need. In fact we have the general rule: given a choice between an equality and an inequality choose the inequality.

For example - if we choose an equality for the ore production constraints we have the three equations 6x+y=12, 3x+y=8 and 4x+6y=24 and there are no values of x and y which satisfy all three equations (the problem is therefore said to be "over-constrained"). For example the (unique) values of x and y which satisfy 6x+y=12 and 3x+y=8 are x=4/3 and y=4, but these values do not satisfy 4x+6y=24.

The reason for this general rule is that choosing an inequality rather than an equality gives us more flexibility in optimising (maximising or minimising) the objective (deciding values for the decision variables that optimize the objective).

• days per week constraint - we cannot work more than a certain maximum number of days a week e.g. for a 5 day week we have

x <= 5 y <= 5

Constraints of this type are often called implicit constraints because they are implicit in the definition of the variables.

(3) Objective

Again in words our objective is (presumably) to minimize cost which is given by 180x + 160y

Hence we have the complete mathematical representation of the problem as:

minimize 180x + 160y subject to

6x + y >= 12 3x + y >= 8 4x + 6y >= 24 x <= 5 y <= 5 x,y >= 0

There are a number of points to note here:

• a common problem with formulation is to overlook some constraints or variables and the entire formulation process should be regarded as an iterative one (iterating back and forth between variables/constraints/objective until we are satisfied).

• the mathematical problem given above has the form o all variables continuous (i.e. can take fractional values) o a single objective (maximize or minimize) o the objective and constraints are linear i.e. any term is either a constant or

a constant multiplied by an unknown (e.g. 24, 4x, 6y are linear terms but xy is a non-linear term).

o any formulation which satisfies these three conditions is called a linear program (LP). As we shall see later LP's are important..

• we have (implicitly) assumed that it is permissible to work in fractions of days - problems where this is not permissible and variables must take integer values will be dealt with under integer programming.

• often (strictly) the decision variables should be integer but for reasons of simplicity we let them be fractional. This is especially relevant in problems where the values of the decision variables are large because any fractional part can then usually be ignored (note that often the data (numbers) that we use in formulating the LP will be inaccurate anyway).

• the way the complete mathematical representation of the problem is set out above is the standard way (with the objective first, then the constraints and finally the reminder that all variables are >=0).

2. Linear Programming – Formulation

As observed above, the conditions for a mathematical model to be a linear program (LP) are:

• all variables continuous (i.e. can take fractional values) • a single objective (minimize or maximize) • the objective and constraints are linear, i.e. any term is either a constant or a

constant multiplied by an unknown.

LP's are important - this is because:

• many practical problems can be formulated as LP's • there exists an algorithm (called the simplex algorithm) which enables us to solve

LP's numerically relatively easily.

We will return later to the simplex algorithm for solving LPs but for the moment we will concentrate upon formulating LP's.

Some of the major application areas to which LP can be applied are:

• Blending • Production planning • Oil refinery management • Distribution • Financial and economic planning • Manpower planning • Blast furnace burdening • Farm planning

We consider below some specific examples of the types of problem that can be formulated as LP's. Note here that the key to formulating LP's is practice. However a useful hint is that common objectives for LP's are minimize cost/maximize profit.

Example 1: Financial planning

A bank makes four kinds of loans to its personal customers and these loans yield the following annual interest rates to the bank:

• First mortgage 14% • Second mortgage 20% • Home improvement 20% • Personal overdraft 10%

The bank has a maximum foreseeable lending capability of £250 million and is further constrained by the policies:

1. first mortgages must be at least 55% of all mortgages issued and at least 25% of all loans issued (in £ terms)

2. second mortgages cannot exceed 25% of all loans issued (in £ terms) 3. to avoid public displeasure and the introduction of a new windfall tax the average

interest rate on all loans must not exceed 15%.

Formulate the bank's loan problem as an LP so as to maximize interest income whilst satisfying the policy limitations.

Note here that these policy conditions, whilst potentially limiting the profit that the bank can make, also limit its exposure to risk in a particular area. It is a fundamental principle of risk reduction that risk is reduced by spreading money (appropriately) across different areas.

Financial planning solution

We follow the same approach as for the Two Mines example - namely

• variables • constraints • objective.

Note here that as in all formulation exercises we are translating a verbal description of the problem into an equivalent mathematical description.

A useful tip when formulating LP's is to express the variables, constraints and objective in words before attempting to express them in mathematics.

Variables

Essentially we are interested in the amount (in £) the bank has loaned to customers in each of the four different areas (not in the actual number of such loans). Hence let

xi = amount loaned in area i in £m (where i=1 corresponds to first mortgages, i=2 to second mortgages etc)

and note that xi >= 0 (i=1,2,3,4).

Note here that it is conventional in LP's to have all variables >= 0. Any variable (X, say) which can be positive or negative can be written as X1-X2 (the difference of two new variables) where X1 >= 0 and X2 >= 0.

Constraints

(a) limit on amount lent

x1 + x2 + x3 + x4 <= 250

Note here the use of <= rather than = (following the general rule we put forward in the Two Mines problem, namely given a choice between an equality and an inequality choose the inequality (as this allows for more flexibility in optimizing the objective function)).

(b) policy condition 1

x1 >= 0.55(x1 + x2)

i.e. first mortgages >= 0.55(total mortgage lending) and also

x1 >= 0.25(x1 + x2 + x3 + x4)

i.e. first mortgages >= 0.25(total loans)

(c) policy condition 2

x2 <= 0.25(x1 + x2 + x3 + x4)

(d) policy condition 3 - we know that the total annual interest is 0.14x1 + 0.20x2 + 0.20x3 + 0.10x4 on total loans of (x1 + x2 + x3 + x4). Hence the constraint relating to policy condition (3) is

0.14x1 + 0.20x2 + 0.20x3 + 0.10x4 <= 0.15(x1 + x2 + x3 + x4)

Note: whilst many of the constraints given above could be simplified by collecting together terms this is not strictly necessary until we come to solve the problem numerically and does tend to obscure the meaning of the constraints.

Objective

To maximize interest income (which is given above) i.e.

maximize 0.14x1 + 0.20x2 + 0.20x3 + 0.10x4

In case you are interested the optimal solution to this LP (solved using appropriate software) is x1= 208.33, x2=41.67 and x3=x4=0. Note here that this optimal solution is not unique - other variable values, e.g. x1= 62.50, x2=0, x3=100 and x4=87.50 also satisfy all the constraints and have exactly the same (maximum) solution value of 37.5

Example 2: Blending problem

Consider the example of a manufacturer of animal feed who is producing feed mix for dairy cattle. In our simple example the feed mix contains two active ingredients and a filler to provide bulk. One kg of feed mix must contain a minimum quantity of each of four nutrients as below:

Nutrient A B C D gram 90 50 20 2

The ingredients have the following nutrient values and cost

A B C D Cost/kg Ingredient 1 (gram/kg) 100 80 40 10 40 Ingredient 2 (gram/kg) 200 150 20 - 60

What should be the amounts of active ingredients and filler in one kg of feed mix?

Blending problem solution

Variables

In order to solve this problem it is best to think in terms of one kilogram of feed mix. That kilogram is made up of three parts - ingredient 1, ingredient 2 and filler so let:

x1 = amount (kg) of ingredient 1 in one kg of feed mix x2 = amount (kg) of ingredient 2 in one kg of feed mix x3 = amount (kg) of filler in one kg of feed mix where x1 >= 0, x2 >= 0 and x3 >= 0.

Essentially these variables (x1, x2 and x3) can be thought of as the recipe telling us how to make up one kilogram of feed mix.

Constraints

• nutrient constraints

100x1 + 200x2 >= 90 (nutrient A) 80x1 + 150x2 >= 50 (nutrient B) 40x1 + 20x2 >= 20 (nutrient C) 10x1 >= 2 (nutrient D)

Note the use of an inequality rather than an equality in these constraints, following the rule we put forward in the Two Mines example, where we assume that the nutrient levels we want are lower limits on the amount of nutrient in one kg of feed mix.

• balancing constraint (an implicit constraint due to the definition of the variables)

x1 + x2 + x3 = 1

Objective

Presumably to minimize cost, i.e.

minimize 40x1 + 60x2

which gives us our complete LP model for the blending problem.

In case you are interested the optimal solution to this LP is x1= 0.3667, x2=0.2667 and x3=0.3667 to four decimal places.

Obvious extensions/uses for this LP model include:

• increasing the number of nutrients considered • increasing the number of possible ingredients considered - more ingredients can

never increase the overall cost (other things being unchanged), and may lead to a decrease in overall cost

• placing both upper and lower limits on nutrients • dealing with cost changes • dealing with supply difficulties • filler cost

Blending problems of this type were, in fact, some of the earliest applications of LP (for human nutrition during rationing) and are still widely used in the production of animal feedstuffs.

Example 3: Production planning problem

A company manufactures four variants of the same product and in the final part of the manufacturing process there are assembly, polishing and packing operations. For each variant the time required for these operations is shown below (in minutes) as is the profit per unit sold.

Assembly Polish Pack Profit (£) Variant 1 2 3 2 1.50 2 4 2 3 2.50 3 3 3 2 3.00 4 7 4 5 4.50

• Given the current state of the labour force the company estimate that, each year, they have 100000 minutes of assembly time, 50000 minutes of polishing time and

60000 minutes of packing time available. How many of each variant should the company make per year and what is the associated profit?

• Suppose now that the company is free to decide how much time to devote to each of the three operations (assembly, polishing and packing) within the total allowable time of 210000 (= 100000 + 50000 + 60000) minutes. How many of each variant should the company make per year and what is the associated profit?

Production planning solution

Variables

Let:

xi be the number of units of variant i (i=1,2,3,4) made per year Tass be the number of minutes used in assembly per year Tpol be the number of minutes used in polishing per year Tpac be the number of minutes used in packing per year

where xi >= 0 i=1,2,3,4 and Tass, Tpol, Tpac >= 0

Constraints

(a) operation time definition

Tass = 2x1 + 4x2 + 3x3 + 7x4 (assembly) Tpol = 3x1 + 2x2 + 3x3 + 4x4 (polish) Tpac = 2x1 + 3x2 + 2x3 + 5x4 (pack)

(b) operation time limits

The operation time limits depend upon the situation being considered. In the first situation, where the maximum time that can be spent on each operation is specified, we simply have:

Tass <= 100000 (assembly) Tpol <= 50000 (polish) Tpac <= 60000 (pack)

In the second situation, where the only limitation is on the total time spent on all operations, we simply have:

Tass + Tpol + Tpac <= 210000 (total time)

Objective

Presumably to maximize profit - hence we have

maximize 1.5x1 + 2.5x2 + 3.0x3 + 4.5x4

which gives us the complete formulation of the problem.

Example 4: Factory planning problem

Under normal working conditions a factory produces up to 100 units of a certain product in each of four consecutive time periods at costs which vary from period to period as shown in the table below.

Additional units can be produced by overtime working. The maximum quantity and costs are shown in the table below, together with the forecast demands for the product in each of the four time periods.

Time Demand Normal Overtime Overtime Period (units) Production Production Production Costs Capacity Cost (£K/unit) (units) (£K/unit) 1 130 6 60 8 2 80 4 65 6 3 125 8 70 10 4 195 9 60 11

It is possible to hold up to 70 units of product in store from one period to the next at a cost of £1.5K per unit per period. (This figure of £1.5K per unit per period is known as a stock-holding cost and represents the fact that we are incurring costs associated with the storage of stock).

It is required to determine the production and storage schedule which will meet the stated demands over the four time periods at minimum cost given that at the start of period 1 we have 15 units in stock. Formulate this problem as an LP.

Factory planning solution

Variables

The decisions that need to be made relate to the amount to produce in normal/overtime working each period. Hence let:

xt = number of units produced by normal working in period t (t=1,2,3,4), where xt >= 0 yt = number of units produced by overtime working in period t (t=1,2,3,4) where yt >= 0

In fact, for this problem, we also need to decide how much stock we carry over from one period to the next so let:

It = number of units in stock at the end of period t (t=0,1,2,3,4)

Constraints

• production limits

xt <= 100 t=1,2,3,4

y1 <= 60 y2 <= 65 y3 <= 70 y4 <= 60

• limit on space for stock carried over

It <= 70 t=1,2,3,4

• we have an inventory continuity equation of the form

closing stock = opening stock + production - demand

then assuming

• opening stock in period t = closing stock in period t-1 and • that production in period t is available to meet demand in period t

we have that

I1 = I0 + (x1 + y1) - 130 I2 = I1 + (x2 + y2) - 80 I3 = I2 + (x3 + y3) - 125 I4 = I3 + (x4 + y4) - 195

where I0 = 15

Note here that inventory continuity equations of the type shown above are common in production planning problems involving more than one time period. Essentially the inventory variables (It) and the inventory continuity equations link together the time periods being considered and represent a physical accounting for stock.

• demand must always be met - i.e. no "stock-outs". This is equivalent to saying that the opening stock in period t plus the production in period t must be greater than (or equal to) the demand in period t, i.e.

I0 + (x1 + y1) >= 130 I1 + (x2 + y2) >= 80 I2 + (x3 + y3) >= 125 I3 + (x4 + y4) >= 195

However these equations can be viewed in another way. Considering the inventory continuity equations we have that the above equations which ensure that demand is always met can be rewritten as:

I1 >= 0 I2 >= 0 I3 >= 0 I4 >= 0

Objective

To minimize cost - which consists of the cost of ordinary working plus the cost of overtime working plus the cost of carrying stock over (1.5K per unit). Hence the objective is:

minimize

(6x1 + 4x2 + 8x3 + 9x4) + (8y1 + 6y2 + 10y3 + 11y4) + (1.5I0 + 1.5I1 + 1.5I2 + 1.5I3 + 1.5I4)

Note here that we have assumed that if we get an answer involving fractional variable values this is acceptable (since the number of units required each period is reasonably large this should not cause too many problems).

In case you are interested the optimal solution to this LP is x1=x2=x3=x4=100; y1=15, y2=50, y3=0 and y4=50; I0=15, I1=0, I2=70, I3=45 and I4=0 with the minimal objective function value being 3865

Note:

• As discussed above assuming It >= 0 t=1,2,3,4 means "no stock-outs" i.e. we need a production plan in which sufficient is produced to ensure that demand is always satisfied.

• Allowing It (t=1,2,3,4) to be unrestricted (positive or negative) means that we may end up with a production plan in which demand is unsatisfied in period t (It < 0). This unsatisfied demand will be carried forward to the next period (when it will be satisfied if production is sufficient, carried forward again otherwise).

• If It is allowed to be negative then we need to amend the objective to ensure that we correctly account for stock-holding costs (and possibly to account for stock-out costs).

• If we get a physical loss of stock over time (e.g. due to damage, pilferage, etc) then this can be easily accounted for. For example if we lose (on average) 2% of stock each period then multiply the right-hand side of the inventory continuity equation by 0.98. If this is done then we often include a term in the objective function to account financially for the loss of stock.

• If production is not immediately available to meet customer demand then the appropriate time delay can be easily incorporated into the inventory continuity equation. For example a 2 period time delay for the problem dealt with above means replace (xt + yt) in the inventory continuity equation for It by (xt-2 + yt-2).

• In practice we would probably deal with the situation described above on a "rolling horizon" basis in that we would get an initial production plan based on current data and then, after one time period (say), we would update our LP and resolve to get a revised production plan. In other words even though we plan for a specific time horizon, here 4 months, we would only even implement the plan for the first month, so that we are always adjusting our 4 month plan to take account of future conditions as our view of the future changes. We illustrate this below.

• Period 1 2 3 4 5 6 7 8 P=plan • P P P P D=do (follow) the plan in a

period • D P P P P • D P P P P

D P P P P

This rolling horizon approach would be preferable to carrying out the plan for 4 time periods and then producing a new plan for the next 4 time periods, such as shown below.

Period 1 2 3 4 5 6 7 8 P=plan P P P P D=do (follow) the plan in a period D D D D P P P P D D D D

3. Linear Programming – Solution

To get some insight into solving LP's, consider the Two Mines problem that we had before - the LP formulation of the problem was:

minimize 180x + 160y subject to 6x + y >= 12 3x + y >= 8 4x + 6y >= 24 x <= 5 y <= 5 x,y >= 0

Since there are only two variables in this LP problem we have the graphical representation of the LP given below with the feasible region (region of feasible solutions to the constraints associated with the LP) outlined.

To draw the diagram above we turn all inequality constraints into equalities and draw the corresponding lines on the graph (e.g. the constraint 6x + y >= 12 becomes the line 6x + y = 12 on the graph). Once a line has been drawn then it is a simple matter to work out which side of the line corresponds to all feasible solutions to the original inequality

constraint (e.g. all feasible solutions to 6x + y >= 12 lie to the right of the line 6x + y = 12).

We determine the optimal solution to the LP by plotting (180x + 160y) = K (K constant) for varying K values (iso-profit lines). One such line (180x + 160y = 180) is shown dotted on the diagram. The smallest value of K (remember we are considering a minimization problem) such that 180x + 160y = K goes through a point in the feasible region is the value of the optimal solution to the LP (and the corresponding point gives the optimal values of the variables).

Hence we can see that the optimal solution to the LP occurs at the vertex of the feasible region formed by the intersection of 3x + y = 8 and 4x + 6y = 24. Note here that it is inaccurate to attempt to read the values of x and y off the graph and instead we solve the simultaneous equations

• 3x + y = 8 • 4x + 6y = 24

to get x = 12/7 = 1.71 and y = 20/7 = 2.86 and hence the value of the objective function is given by 180x + 160y = 180(12/7) + 160(20/7) = 765.71

Hence the optimal solution has cost 765.71

It is clear that the above graphical approach to solving LP's can be used for LP's with two variables but (alas) most LP's have more than two variables. This brings us to the simplex algorithm for solving LP's.

Simplex

Note that in the example considered above the optimal solution to the LP occurred at a vertex (corner) of the feasible region. In fact it is true that for any LP (not just the one considered above) the optimal solution occurs at a vertex of the feasible region. This fact is the key to the simplex algorithm for solving LP's.

Essentially the simplex algorithm starts at one vertex of the feasible region and moves (at each iteration) to another (adjacent) vertex, improving (or leaving unchanged) the objective function as it does so, until it reaches the vertex corresponding to the optimal LP solution.

The simplex algorithm for solving linear programs (LP's) was developed by Dantzig in the late 1940s, and since then a number of different versions of the algorithm have been developed. One of these later versions, called the revised simplex algorithm (sometimes known as the "product form of the inverse" simplex algorithm) forms the basis of most modern computer packages for solving LP's. However, it is not necessary to know the mechanics of the simplex algorithm for the combinatorial optimization course.

Part B: Integer Programming

4. Integer Programming – Formulation

Capital budgeting

There are four possible projects, which each run for 3 years and have the following characteristics.

Capital requirements (£m) Project Return (£m) Year 1 2 3 1 0.2 0.5 0.3 0.2 2 0.3 1.0 0.8 0.2 3 0.5 1.5 1.5 0.3 4 0.1 0.1 0.4 0.1 Available capital (£m) 3.1 2.5 0.4

We have a decision problem here: Which projects would you choose in order to maximise the total return?

Capital budgeting solution

We follow the same approach as we used for formulating LPs - namely:

• variables • constraints • objective.

We do this below and note here that the only significant change in formulating IP's as opposed to formulating LP's is in the definition of the variables.

Variables

Here we are trying to decide whether to undertake a project or not (a "go/no-go" decision). One "trick" in formulating IP's is to introduce variables which take the integer values 0 or 1 and represent binary decisions (e.g. do a project or not do a project) with typically:

• the positive decision (do something) being represented by the value 1; and • the negative decision (do nothing) being represented by the value 0.

Such variables are often called zero-one or binary variables

To define the variables we use the verbal description of

xj = 1 if we decide to do project j (j=1,...,4) = 0 otherwise, i.e. not do project j (j=1,...,4)

Note here that, by definition, the xj are integer variables which must take one of two possible values (zero or one).

Constraints

The constraints relating to the availability of capital funds each year are

0.5x1 + 1.0x2 + 1.5x3 + 0.1x4< = 3.1 (year 1) 0.3x1 + 0.8x2 + 1.5x3 + 0.4x4< = 2.5 (year 2) 0.2x1 + 0.2x2 + 0.3x3 + 0.1x4< = 0.4 (year 3)

Objective

To maximise the total return - hence we have

maximise 0.2x1 + 0.3x2 + 0.5x3 + 0.1x4

This gives us the complete IP which we write as

maximise 0.2x1 + 0.3x2 + 0.5x3 + 0.1x4

subject to

0.5x1 + 1.0x2 + 1.5x3 + 0.1x4< = 3.1 0.3x1 + 0.8x2 + 1.5x3 + 0.4x4< = 2.5 0.2x1 + 0.2x2 + 0.3x3 + 0.1x4< = 0.4 xj = 0 or 1 j=1,...,4

Capital budgeting extension

Suppose now that we have the additional condition that either project 1 or project 2 must be chosen (i.e. projects 1 and 2 are mutually exclusive). To cope with this condition we enlarge the IP given above in the following manner.

This condition is an example of an either/or condition "either project 1 or project 2 must be chosen". In terms of the variables we have already defined this condition is "either x1 = 1 or x2 = 1". The standard trick for dealing with either/or conditions relating to two zero-one variables is to add to the IP the constraint

• x1 + x2 = 1

To verify that this mathematical description is equivalent to the verbal description "either x1 = 1 or x2 = 1" we use the fact that x1 and x2 are both zero-one variables.

Choose any one of these two variables (x1, say) and tabulate, for each possible value of the chosen variable, the meaning of the corresponding mathematical and verbal descriptions as below.

Variable value Mathematical description Verbal description x1 + x2 = 1 "either x1 = 1 or x2 = 1" x1 = 0 x2 = 1 x2 = 1 x1 = 1 1 + x2 = 1 x2 = 0 i.e. x2 = 0

It is clear from this tabulation that the mathematical and verbal descriptions are equivalent with the proviso that we have interpreted the condition "either x1 = 1 or x2 = 1" as meaning that the case x1 = 1 and x2 = 1 (both projects 1 and 2 chosen) cannot occur. If this is not so (i.e. both projects 1 and 2 can be chosen) then we replace the constraint x1 + x2 = 1 by the constraint x1 + x2 >= 1 (i.e. at least one of projects 1 and 2 must be chosen).

Note here that, in general, we can regard formulating a problem as translating a verbal description of the problem into an equivalent mathematical description. What we have presented above is a similar process - translating a specific "either ... or ..." verbal description into an equivalent mathematical description. Whilst it is not usual to go to the lengths of a complete tabulation (as shown above) to verify that the verbal and mathematical descriptions are equivalent a complete tabulation is helpful in clarifying thought and detecting incorrect mathematical descriptions.

Other problems

The main areas in which IP is used in practice include:

• imposition of logical conditions in LP problems (such as the either/or condition dealt with above)

• blending with a limited number of ingredients • depot location • job shop scheduling • assembly line balancing • airline crew scheduling • timetabling

Example 1: Blending problem revisited

Consider again the blending problem considered above in which a manufacturer of animal feed is producing feed mix for dairy cattle. In our simple example the feed mix

contains two active ingredients and a filler to provide bulk. One kg of feed mix must contain a minimum quantity of each of four nutrients as below:

Nutrient A B C D gram 90 50 20 2

The ingredients have the following nutrient values and cost

A B C D Cost/kg Ingredient 1 (gram/kg) 100 80 40 10 40 Ingredient 2 (gram/kg) 200 150 20 - 60

What should be the amounts of active ingredients and filler in one kg of feed mix?

Blending problem solution

Variables

In order to solve this problem it is best to think in terms of one kilogram of feed mix. That kilogram is made up of three parts - ingredient 1, ingredient 2 and filler so: let x1 = amount (kg) of ingredient 1 in one kg of feed mix x2 = amount (kg) of ingredient 2 in one kg of feed mix x3 = amount (kg) of filler in one kg of feed mix where x1 >= 0, x2 >= 0 and x3 >= 0.

Constraints

• balancing constraint (an implicit constraint due to the definition of the variables)

x1 + x2 + x3 = 1

• nutrient constraints

100x1 + 200x2 >= 90 (nutrient A) 80x1 + 150x2 >= 50 (nutrient B) 40x1 + 20x2 >= 20 (nutrient C) 10x1 >= 2 (nutrient D)

Note the use of an inequality rather than an equality in these constraints, following the rule we put forward in the Two Mines example, where we assume that the nutrient levels we want are lower limits on the amount of nutrient in one kg of feed mix.

Objective

Presumably to minimize cost, i.e.

minimize 40x1 + 60x2

which gives us our complete LP model for the blending problem.

Suppose now we have the additional conditions:

• if we use any of ingredient 2 we incur a fixed cost of 15 • we need not satisfy all four nutrient constraints but need only satisfy three of them

(i.e. whereas before the optimal solution required all four nutrient constraints to be satisfied now the optimal solution could (if it is worthwhile to do so) only have three (any three) of these nutrient constraints satisfied and the fourth violated.

Give the complete MIP formulation of the problem with these two new conditions added.

Solution

To cope with the condition that if x2>=0 we have a fixed cost of 15 incurred we have the standard trick of introducing a zero-one variable y defined by

y = 1 if x2>=0 = 0 otherwise

and

• add a term +15y to the objective function

and add the additional constraint

• x2 <= [largest value x2 can take]y

In this case it is easy to see that x2 can never be greater than one and hence our additional constraint is x2<= y.

To cope with condition that need only satisfy three of the four nutrient constraints we introduce four zero-one variables zi (i=1,2,3,4) where

zi = 1 if nutrient constraint i (i=1,2,3,4) is satisfied

= 0 otherwise

and add the constraint

• z1+z2+z3+z4 >= 3 (at least 3 constraints satisfied)

and alter the nutrient constraints to be

• 100x1 + 200x2 >= 90z1 • 80x1 + 150x2 >= 50z2 • 40x1 + 20x2 >= 20z3 • 10x1 >= 2z4

The logic behind this change is that if a zi=1 then the constraint becomes the original nutrient constraint which needs to be satisfied. However if a zi=0 then the original nutrient constraint becomes

• same left-hand side >= zero

which (for the four left-hand sides dealt with above) is always true and so can be neglected - meaning the original nutrient constraint need not be satisfied. Hence the complete (MIP) formulation of the problem is given by

minimize 40x1 + 60x2 + 15y subject to x1 + x2 + x3 = 1 100x1 + 200x2 >= 90z1 80x1 + 150x2 >= 50z2 40x1 + 20x2 >= 20z3 10x1 >= 2z4 z1 + z2 + z3 + z4 >= 3 x2 <= y zi = 0 or 1 i=1,2,3,4 y = 0 or 1 xi >= 0 i=1,2,3

Example 2: Production Planning

In the planning of the monthly production for the next six months a company must, in each month, operate either a normal shift or an extended shift (if it produces at all). A normal shift costs £100,000 per month and can produce up to 5,000 units per month. An extended shift costs £180,000 per month and can produce up to 7,500 units per month. Note here that, for either type of shift, the cost incurred is fixed by a union guarantee agreement and so is independent of the amount produced.

It is estimated that changing from a normal shift in one month to an extended shift in the next month costs an extra £15,000. No extra cost is incurred in changing from an extended shift in one month to a normal shift in the next month.

The cost of holding stock is estimated to be £2 per unit per month (based on the stock held at the end of each month) and the initial stock is 3,000 units (produced by a normal shift). The amount in stock at the end of month 6 should be at least 2,000 units. The demand for the company's product in each of the next six months is estimated to be as shown below:

Month 1 2 3 4 5 6 Demand 6,000 6,500 7,500 7,000 6,000 6,000

Production constraints are such that if the company produces anything in a particular month it must produce at least 2,000 units. If the company wants a production plan for the next six months that avoids stockouts, formulate their problem as an integer program.

Hint: first formulate the problem allowing non-linear constraints and then attempt to make all the constraints linear.

Solution

Variables

The decisions that have to be made relate to:

• whether to operate a normal shift or an extended shift in each month; and • how much to produce each month.

Hence let:

xt = 1 if we operate a normal shift in month t (t=1,2,...,6) = 0 otherwise yt = 1 if we operate an extended shift in month t (t=1,2,...,6) = 0 otherwise Pt (>= 0) be the amount produced in month t (t=1,2,...,6)

In fact, for this problem, we can ease the formulation by defining three additional variables - namely let:

zt = 1 if we switch from a normal shift in month t-1 to an extended shift in month t (t=1,2,...,6) = 0 otherwise It be the closing inventory (amount of stock left) at the end of month t (t=1,2,...,6) wt = 1 if we produce in month t, and hence from the production constraints Pt >= 2000 (t=1,2,...,6) = 0 otherwise (i.e. Pt = 0)

The motivation behind introducing the first two of these variables (zt, It) is that in the objective function we will need terms relating to shift change cost and inventory holding cost. The motivation behind introducing the third of these variables (wt) is the production constraint "either Pt = 0 or Pt >= 2000", which needs a zero-one variable so that it can be dealt with using the standard trick for "either/or" constraints.

In any event formulating an IP tends to be an iterative process and if we have made a mistake in defining variables we will encounter difficulties in formulating the constraints/objective. At that point we can redefine our variables and reformulate.

Constraints

We first express each constraint in words and then in terms of the variables defined above.

• only operate (at most) one shift each month

xt + yt <= 1 t=1,2,...,6

Note here that we could not have made do with just one variable (xt say) and defined that variable to be one for a normal shift and zero for an extended shift (since in that case what if we decide not to produce in a particular month?).

Although we could have introduced a variable indicating no shift (normal or extended) operated in a particular month this is not necessary as such a variable is equivalent to 1-xt-yt.

• production limits not exceeded

Pt <= 5000xt + 7500yt t=1,2,...,6

Note here the use of addition in the right-hand side of the above equation where we are making use of the fact that at most one of xt and yt can be one and the other must be zero.

• no stockouts

It >= 0 t=1,2,...,6

• we have an inventory continuity equation of the form

closing stock = opening stock + production - demand

where I0 = 3000. Hence letting Dt = demand in month t (t=1,2,...,6) (a known constant) and assuming

• that opening stock in period t = closing stock in period t-1 and • that production in period t is available to meet demand in period t

we have that

It = It-1 + Pt - Dt t=1,2,...,6

As noted above this equation assumes that we can meet demand in the current month from goods produced that month. Any time lag between goods being produced and becoming available to meet demand is easily incorporated into the above equation. For example for a 2 month time lag we replace Pt in the above equation by Pt-2 and interpret It as the number of goods in stock at the end of month t which are available to meet demand i.e. goods are not regarded as being in stock until they are available to meet demand. Inventory continuity equations of the type shown are common in production planning problems.

• the amount in stock at the end of month 6 should be at least 2000 units

I6 >= 2000

• production constraints of the form "either Pt = 0 or Pt >= 2,000".

Here we make use of the standard trick we presented for "either/or" constraints. We have already defined appropriate zero-one variables wt (t=1,2,...,6) and so we merely need the constraints

Pt <= Mwt t=1,2,...,6 Pt >= 2000wt t=1,2,...,6

Here M is a positive constant and represents the most we can produce in any period t (t=1,2,...,6). A convenient value for M for this example is M = 7500 (the most we can produce irrespective of the shift operated).

• we also need to relate the shift change variable zt to the shifts being operated

The obvious constraint is

zt = xt-1yt t=1,2,...,6

since as both xt-1 and yt are zero-one variables zt can only take the value one if both xt-1 and yt are one (i.e. we operate a normal shift in period t-1 and an extended shift in period t). Looking back to the verbal description of zt it is clear that the mathematical description given above is equivalent to that verbal description. (Note here that we define x0 = 1 (y0 = 0)).

This constraint is non-linear. However we are told that we can first formulate the problem with non-linear constraints and so we proceed. We shall see later how to linearise (generate equivalent linear constraints for) this equation.

Objective

We wish to minimize total cost and this is given by

SUM{t=1,...,6}(100000xt + 180000yt + 15000zt + 2It)

Hence our formulation is complete.

Note that, in practice, we would probably regard It and Pt as taking fractional values and round to get integer values (since they are both large this should be acceptable). Note too here that this is a non-linear integer program.

Comments

In practice a model of this kind would be used on a "rolling horizon" basis whereby every month or so it would be updated and resolved to give a new production plan.

The inventory continuity equation presented is quite flexible, being able to accommodate both time lags (as discussed previously) and wastage. For example if 2% of the stock is wasted each month due to deterioration/pilfering etc then the inventory continuity equation becomes It = 0.98It-1 + Pt - Dt. Note that, if necessary, the objective function can include a term related to 0.02It-1 to account for the loss in financial terms.

In order to linearise (generate equivalent linear constraints) for our non-linear constraint we again use a standard trick. Note that that equation is of the form

• A = BC

where A, B and C are zero-one variables. The standard trick is that a non-linear constraint of this type can be replaced by the two linear constraints

• A <= (B+C)/2 and • A >= B+C-1

To see this we use the fact that as B and C take only zero-one values there are only four possible cases to consider:

B C A = BC A <= (B+C)/2 A >= B+C-1 becomes becomes becomes 0 0 A = 0 A <= 0 A >= -1 0 1 A = 0 A <= 0.5 A >= 0 1 0 A = 0 A <= 0.5 A >= 0 1 1 A = 1 A <= 1 A >= 1

Then, recalling that A can also only take zero-one values, it is clear that in each of the four possible cases the two linear constraints (A <= (B+C)/2 and A >= B+C-1) are equivalent to the single non-linear constraint (A=BC).

Returning now to our original non-linear constraint

• zt = xt-1yt

this involves the three zero-one variables zt, xt-1 and yt and so we can use our general rule and replace this non-linear constraint by the two linear constraints

zt <= (xt-1 + yt)/2 t=1,2,...,6 and zt >= xt-1 + yt - 1 t=1,2,...,6

Making this change transforms the non-linear integer program given before into an equivalent linear integer program.