# 6.8 Problem Modification and Reoptimization¶

Often one might want to solve not just a single optimization problem, but a sequence of problems, each differing only slightly from the previous one. This section demonstrates how to modify and re-optimize an existing problem. The example we study is a simple production planning model.

Problem modifications regarding variables, cones, objective function and constraints can be grouped in categories:

- add/remove,
- coefficient modifications,
- bounds modifications.

Especially removing variables and constraints can be costly. Special care must be taken with respect to constraints and variable indexes that may be invalidated.

Depending on the type of modification, **MOSEK** may be able to optimize the modified problem more efficiently exploiting the information and internal state from the previous execution. After optimization, the solution is always stored internally, and is available before next optimization. The former optimal solution may be still feasible, but no longer optimal; or it may remain optimal if the modification of the objective function was small. This special case is discussed in Section 15.

In general, **MOSEK** exploits dual information and availability of an optimal basis from the previous execution. The simplex optimizer is well suited for exploiting an existing primal or dual feasible solution. Restarting capabilities for interior-point methods are still not as reliable and effective as those for the simplex algorithm. More information can be found in Chapter 10 of the book [Chv83].

## 6.8.1 Example: Production Planning¶

A company manufactures three types of products. Suppose the stages of manufacturing can be split into three parts: Assembly, Polishing and Packing. In the table below we show the time required for each stage as well as the profit associated with each product.

Product no. | Assembly (minutes) | Polishing (minutes) | Packing (minutes) | Profit ($) |
---|---|---|---|---|

0 | 2 | 3 | 2 | 1.50 |

1 | 4 | 2 | 3 | 2.50 |

2 | 3 | 3 | 2 | 3.00 |

With the current resources available, the company has \(100,000\) minutes of assembly time, \(50,000\) minutes of polishing time and \(60,000\) minutes of packing time available per year. We want to know how many items of each product the company should produce each year in order to maximize profit?

Denoting the number of items of each type by \(x_0,x_1\) and \(x_2\), this problem can be formulated as a linear optimization problem:

and

Code in Listing 6.12 loads and solves this problem.

```
% Specify the c vector.
prob.c = [1.5 2.5 3.0]';
% Specify a in sparse format.
subi = [1 1 1 2 2 2 3 3 3];
subj = [1 2 3 1 2 3 1 2 3];
valij = [2 4 3 3 2 3 2 3 2];
prob.a = sparse(subi,subj,valij);
% Specify lower bounds of the constraints.
prob.blc = [-inf -inf -inf]';
% Specify upper bounds of the constraints.
prob.buc = [100000 50000 60000]';
% Specify lower bounds of the variables.
prob.blx = zeros(3,1);
% Specify upper bounds of the variables.
prob.bux = [inf inf inf]';
% Perform the optimization.
[r,res] = mosekopt('maximize',prob);
% Show the optimal x solution.
res.sol.bas.xx
```

## 6.8.2 Changing the Linear Constraint Matrix¶

Suppose we want to change the time required for assembly of product \(0\) to \(3\) minutes. This corresponds to setting \(a_{0,0} = 3\), which is done by directly modifying the `A`

matrix of the problem, as shown below.

```
prob.a(1,1) = 3.0
```

The problem now has the form:

and

After this operation we can reoptimize the problem.

## 6.8.3 Appending Variables¶

We now want to add a new product with the following data:

Product no. | Assembly (minutes) | Polishing (minutes) | Packing (minutes) | Profit ($) |
---|---|---|---|---|

3 | 4 | 0 | 1 | 1.00 |

This corresponds to creating a new variable \(x_3\), appending a new column to the \(A\) matrix and setting a new term in the objective. We do this in Listing 6.13

```
prob.c = [prob.c;1.0];
prob.a = [prob.a,sparse([4.0 0. 1.0]')];
prob.blx = zeros(4,1);
prob.bux = [prob.bux; inf]
```

After this operation the new problem is:

and

## 6.8.4 Appending Constraints¶

Now suppose we want to add a new stage to the production process called *Quality control* for which \(30000\) minutes are available. The time requirement for this stage is shown below:

Product no. | Quality control (minutes) |
---|---|

0 | 1 |

1 | 2 |

2 | 1 |

3 | 1 |

This corresponds to adding the constraint

to the problem. This is done as follows.

```
prob.a = [prob.a;sparse([1.0 2.0 1.0 1.0])];
prob.blc = [prob.blc;30000.0];
prob.buc = [prob.buc;-inf];
```

Again, we can continue with re-optimizing the modified problem.