### Example 10.4 Reoptimizing after Modifying the Objective Function

Using the diet problem described in Example 10.3, this example illustrates how to reoptimize an LP problem after modifying the objective function.

Assume that the optimal solution of the diet problem is found and the optimal solutions are stored in the data sets `ex3pout` and `ex3dout`.

Suppose the cost of cheese increases from 8 to 10 per unit and the cost of fish decreases from 11 to 7 per serving unit. The COLUMNS section in the input data set `ex3` is updated (and the data set is saved as `ex4`) as follows:

```
COLUMNS     .          .        .     .         .
...
.           ch         diet     10     calories  106
...
.           fi         diet     7      calories  130
...
RHS         .          .        .     .         .
...

ENDATA
;
```

You can use the following DATA step to create the data set `ex4`:

```data ex4;
input field1 \$ field2 \$ field3 \$ field4 field5 \$ field6;
datalines;
NAME        .          EX4      .     .         .
ROWS        .          .        .     .         .
N          diet       .        .     .         .
G          calories   .        .     .         .
L          protein    .        .     .         .
G          fat        .        .     .         .
G          carbs      .        .     .         .
COLUMNS     .          .        .     .         .
.           br         diet     2     calories  90
.           br         protein  4     fat       1
.           br         carbs    15    .         .
.           mi         diet     3.5   calories  120
.           mi         protein  8     fat       5
.           mi         carbs    11.7  .         .
.           ch         diet     10    calories  106
.           ch         protein  7     fat       9
.           ch         carbs    .4    .         .
.           po         diet     1.5   calories  97
.           po         protein  1.3   fat       .1
.           po         carbs    22.6  .         .
.           fi         diet      7    calories  130
.           fi         protein  8     fat       7
.           fi         carbs    0     .         .
.           yo         diet     1     calories  180
.           yo         protein  9.2   fat       1
.           yo         carbs    17    .         .
RHS         .          .        .     .         .
.           .          calories 300   protein   10
.           .          fat      8     carbs     10
BOUNDS      .          .        .     .         .
UP          .          mi       1     .         .
LO          .          fi       .5    .         .
ENDATA      .          .        .     .         .
;
```

You can use the BASIS=WARMSTART option (and the `ex3pout` and `ex3dout` data sets from Example 10.3) in the following call to PROC OPTLP to solve the modified problem:

```proc optlp data=ex4
presolver = none
basis     = warmstart
primalin  = ex3pout
dualin    = ex3dout
algorithm = primal
primalout = ex4pout
dualout   = ex4dout
logfreq   = 1;
run;
```

The following iteration log indicates that it takes the primal simplex solver no extra iterations to solve the modified problem by using BASIS=WARMSTART, since the optimal solution to the LP problem in Example 10.3 remains optimal after the objective function is changed.

Output 10.4.1: Iteration Log

 NOTE: The problem EX4 has 6 variables (0 free, 0 fixed). NOTE: The problem has 4 constraints (1 LE, 0 EQ, 3 GE, 0 range). NOTE: The problem has 23 constraint coefficients. NOTE: The LP presolver value NONE is applied. NOTE: The LP solver is called. NOTE: The Primal Simplex algorithm is used. Objective                Entering      Leaving Phase Iteration        Value         Time     Variable      Variable P 2          1    1.098034E+01         0 NOTE: Optimal. NOTE: Objective = 10.980335514. NOTE: The Primal Simplex solve time is 0.03 seconds. NOTE: The data set WORK.EX4POUT has 6 observations and 10 variables. NOTE: The data set WORK.EX4DOUT has 4 observations and 10 variables.

Note that the primal simplex solver is preferred because the primal solution to the original LP is still feasible for the modified problem in this case.