14.3 Sensitivity Analysis

Given an optimization problem it is often useful to obtain information about how the optimal objective value changes when the problem parameters are perturbed. E.g, assume that a bound represents the capacity of a machine. Now, it may be possible to expand the capacity for a certain cost and hence it is worthwhile knowing what the value of additional capacity is. This is precisely the type of questions the sensitivity analysis deals with.

Analyzing how the optimal objective value changes when the problem data is changed is called sensitivity analysis.

References

The book [Chvatal83] discusses the classical sensitivity analysis in Chapter 10 whereas the book [RTV97] presents a modern introduction to sensitivity analysis. Finally, it is recommended to read the short paper [Wal00] to avoid some of the pitfalls associated with sensitivity analysis.

Warning

Currently, sensitivity analysis is only available for continuous linear optimization problems. Moreover, MOSEK can only deal with perturbations of bounds and objective function coefficients.

14.3.1 Sensitivity Analysis for Linear Problems

14.3.1.1 The Optimal Objective Value Function

Assume that we are given the problem

(14.3)z(lc,uc,lx,ux,c)=minimizecTxsubject tolcAxuc,lxxux,

and we want to know how the optimal objective value changes as lic is perturbed. To answer this question we define the perturbed problem for lic as follows

flic(β)=minimizecTxsubject tolc+βeiAxuc,lxxux,

where ei is the i-th column of the identity matrix. The function

(14.4)flic(β)

shows the optimal objective value as a function of β. Please note that a change in β corresponds to a perturbation in lic and hence (14.4) shows the optimal objective value as a function of varying lic with the other bounds fixed.

It is possible to prove that the function (14.4) is a piecewise linear and convex function, i.e. its graph may look like in Fig. 14.1 and Fig. 14.2.

_images/optimal_val_fun2.png

Fig. 14.1 β=0 is in the interior of linearity interval.

_images/optimal_val_fun.png

Fig. 14.2 β=0 is a breakpoint.

Clearly, if the function flic(β) does not change much when β is changed, then we can conclude that the optimal objective value is insensitive to changes in lic. Therefore, we are interested in the rate of change in flic(β) for small changes in β — specifically the gradient

flic(0),

which is called the shadow price related to lic. The shadow price specifies how the objective value changes for small changes of β around zero. Moreover, we are interested in the linearity interval

β[β1,β2]

for which

flic(β)=flic(0).

Since flic is not a smooth function flic may not be defined at 0, as illustrated in Fig. 14.2. In this case we can define a left and a right shadow price and a left and a right linearity interval.

The function flic considered only changes in lic. We can define similar functions for the remaining parameters of the z defined in (14.3) as well:

flic(β)=z(lc+βei,uc,lx,ux,c),i=1,,m,fuic(β)=z(lc,uc+βei,lx,ux,c),i=1,,m,fljx(β)=z(lc,uc,lx+βej,ux,c),j=1,,n,fujx(β)=z(lc,uc,lx,ux+βej,c),j=1,,n,fcj(β)=z(lc,uc,lx,ux,c+βej),j=1,,n.

Given these definitions it should be clear how linearity intervals and shadow prices are defined for the parameters uic etc.

14.3.1.1.1 Equality Constraints

In MOSEK a constraint can be specified as either an equality constraint or a ranged constraint. If some constraint eic is an equality constraint, we define the optimal value function for this constraint as

feic(β)=z(lc+βei,uc+βei,lx,ux,c)

Thus for an equality constraint the upper and the lower bounds (which are equal) are perturbed simultaneously. Therefore, MOSEK will handle sensitivity analysis differently for a ranged constraint with lic=uic and for an equality constraint.

14.3.1.2 The Basis Type Sensitivity Analysis

The classical sensitivity analysis discussed in most textbooks about linear optimization, e.g. [Chvatal83], is based on an optimal basis. This method may produce misleading results [RTV97] but is computationally cheap. This is the type of sensitivity analysis implemented in MOSEK.

We will now briefly discuss the basis type sensitivity analysis. Given an optimal basic solution which provides a partition of variables into basic and non-basic variables, the basis type sensitivity analysis computes the linearity interval [β1,β2] so that the basis remains optimal for the perturbed problem. A shadow price associated with the linearity interval is also computed. However, it is well-known that an optimal basic solution may not be unique and therefore the result depends on the optimal basic solution employed in the sensitivity analysis. If the optimal objective value function has a breakpoint for β=0 then the basis type sensitivity method will only provide a subset of either the left or the right linearity interval.

In summary, the basis type sensitivity analysis is computationally cheap but does not provide complete information. Hence, the results of the basis type sensitivity analysis should be used with care.

14.3.1.3 Example: Sensitivity Analysis

As an example we will use the following transportation problem. Consider the problem of minimizing the transportation cost between a number of production plants and stores. Each plant supplies a number of goods and each store has a given demand that must be met. Supply, demand and cost of transportation per unit are shown in Fig. 14.3.

_images/transportp2.png

Fig. 14.3 Supply, demand and cost of transportation.

If we denote the number of transported goods from location i to location j by xij, problem can be formulated as the linear optimization problem of minimizing

1x11+2x12+5x23+2x24+1x31+2x33+1x34

subject to

(14.5)x11+x12400,x23+x241200,x31+x33+x341000,x11+x31=800,x12=100,x23+x33=500,x24+x34=500,x11,x12,x23,x24,x31,x33,x340.

The sensitivity parameters are shown in Table 14.1 and Table 14.2.

Table 14.1 Ranges and shadow prices related to bounds on constraints and variables.

Con.

β1

β2

σ1

σ2

1

300.00

0.00

3.00

3.00

2

700.00

+

0.00

0.00

3

500.00

0.00

3.00

3.00

4

0.00

500.00

4.00

4.00

5

0.00

300.00

5.00

5.00

6

0.00

700.00

5.00

5.00

7

500.00

700.00

2.00

2.00

Var.

β1

β2

σ1

σ2

x11

300.00

0.00

0.00

x12

100.00

0.00

0.00

x23

0.00

0.00

0.00

x24

500.00

0.00

0.00

x31

500.00

0.00

0.00

x33

500.00

0.00

0.00

x34

0.000000

500.00

2.00

2.00


Table 14.2 Ranges and shadow prices related to the objective coefficients.

Var.

β1

β2

σ1

σ2

c1

3.00

300.00

300.00

c2

100.00

100.00

c3

2.00

0.00

0.00

c4

2.00

500.00

500.00

c5

3.00

500.00

500.00

c6

2.00

500.00

500.00

c7

2.00

0.00

0.00


Examining the results from the sensitivity analysis we see that for constraint number 1 we have σ1=3 and β1=300, β2=0.

If the upper bound on constraint 1 is decreased by

β[0,300]

then the optimal objective value will increase by the value

σ1β=3β.

14.3.2 Sensitivity Analysis with MOSEK

The following describe sensitivity analysis from the MATLAB toolbox.

14.3.2.1 On bounds

The index of bounds/variables to analyzed for sensitivity are specified in the following subfields of the MATLAB structure prob:

  • .prisen.cons.subu Indexes of constraints, where upper bounds are analyzed for sensitivity.

  • .prisen.cons.subl Indexes of constraints, where lower bounds are analyzed for sensitivity.

  • .prisen.vars.subu Indexes of variables, where upper bounds are analyzed for sensitivity.

  • .prisen.vars.subl Indexes of variables, where lower bounds are analyzed for sensitivity.

  • .duasen.sub Index of variables where coefficients are analyzed for sensitivity.

For an equality constraint, the index can be specified in either subu or subl. After calling mosekopt the results are returned in the subfields prisen and duasen of res.

14.3.2.2 prisen

The field prisen is structured as follows:

  • .cons: a MATLAB structure with subfields:

    • .lr_bl Left value β1 in the linearity interval for a lower bound.

    • .rr_bl Right value β2 in the linearity interval for a lower bound.

    • .ls_bl Left shadow price sl for a lower bound.

    • .rs_bl Right shadow price sr for a lower bound.

    • .lr_bu Left value β1 in the linearity interval for an upper bound.

    • .rr_bu Right value β2 in the linearity interval for an upper bound.

    • .ls_bu Left shadow price sl for an upper bound.

    • .rs_bu Right shadow price sr for an upper bound.

  • .var: MATLAB structure with subfields:

    • .lr_bl Left value β1 in the linearity interval for a lower bound on a varable.

    • .rr_bl Right value β2 in the linearity interval for a lower bound on a varable.

    • .ls_bl Left shadow price sl for a lower bound on a varable.

    • .rs_bl Right shadow price sr for lower bound on a varable.

    • .lr_bu Left value β1 in the linearity interval for an upper bound on a varable.

    • .rr_bu Right value β2 in the linearity interval for an upper bound on a varable.

    • .ls_bu Left shadow price sl for an upper bound on a varables.

    • .rs_bu Right shadow price sr for an upper bound on a varables.

14.3.2.2.1 duasen

The field duasen is structured as follows:

  • .lr_c Left value β1 of linearity interval for an objective coefficient.

  • .rr_c Right value β2 of linearity interval for an objective coefficient.

  • .ls_c Left shadow price sl for an objective coefficients .

  • .rs_c Right shadow price sr for an objective coefficients.

Example

Consider the problem defined in (14.5). Suppose we wish to perform sensitivity analysis on all bounds and coefficients. The following example demonstrates this as well as the method for changing between basic and full sensitivity analysis.

Listing 14.2 A script to perform sensitivity analysis on problem (14.5). Click here to download.
function sensitivity()

clear prob;

% Obtain all symbolic constants
% defined by MOSEK.
[r,res]  = mosekopt('symbcon');
sc       = res.symbcon;

prob.blc = [-Inf, -Inf, -Inf, 800,100,500,500];
prob.buc = [ 400, 1200, 1000, 800,100,500,500];
prob.c   = [1.0,2.0,5.0,2.0,1.0,2.0,1.0]';
prob.blx = [0.0,0.0,0.0,0.0,0.0,0.0,0.0];
prob.bux = [Inf,Inf,Inf,Inf, Inf,Inf,Inf];

subi     = [  1,  1,  2,  2,  3,  3,  3,  4,  4,  5,  6,  6,  7,  7];
subj     = [  1,  2,  3,  4,  5,  6,  7,  1,  5,  6,  3,  6,  4,  7];
val      = [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0];

prob.a = sparse(subi,subj,val);

% analyse upper bound 1:7
prob.prisen.cons.subl = [];
prob.prisen.cons.subu = [1:7];
% analyse lower bound on variables 1:7
prob.prisen.vars.subl = [1:7];
prob.prisen.vars.subu = [];
% analyse coeficient 1:7
prob.duasen.sub = [1:7];
[r,res] = mosekopt('minimize echo(0)',prob);

%Print results

fprintf('\nBasis sensitivity results:\n')
fprintf('\nSensitivity for bounds on constraints:\n')
for i = 1:length(prob.prisen.cons.subl)
  fprintf (...
  'con = %d, beta_1 = %.1f, beta_2 = %.1f, delta_1 = %.1f,delta_2 = %.1f\n', ...
  prob.prisen.cons.subl(i),res.prisen.cons.lr_bl(i), ...
  res.prisen.cons.rr_bl(i),...
  res.prisen.cons.ls_bl(i),...
  res.prisen.cons.rs_bl(i));
end

for i = 1:length(prob.prisen.cons.subu)
  fprintf (...
  'con = %d, beta_1 = %.1f, beta_2 = %.1f, delta_1 = %.1f,delta_2 = %.1f\n', ...
  prob.prisen.cons.subu(i),res.prisen.cons.lr_bu(i), ...
  res.prisen.cons.rr_bu(i),...
  res.prisen.cons.ls_bu(i),...
  res.prisen.cons.rs_bu(i));
end
fprintf('Sensitivity for bounds on variables:\n')
for i = 1:length(prob.prisen.vars.subl)
fprintf (...
'var = %d, beta_1 = %.1f, beta_2 = %.1f, delta_1 = %.1f,delta_2 = %.1f\n', ...
 prob.prisen.vars.subl(i),res.prisen.vars.lr_bl(i), ...
 res.prisen.vars.rr_bl(i),...
 res.prisen.vars.ls_bl(i),...
 res.prisen.vars.rs_bl(i));
end

for i = 1:length(prob.prisen.vars.subu)
  fprintf (...
  'var = %d, beta_1 = %.1f, beta_2 = %.1f, delta_1 = %.1f,delta_2 = %.1f\n', ...
  prob.prisen.vars.subu(i),res.prisen.vars.lr_bu(i), ...
  res.prisen.vars.rr_bu(i),...
  res.prisen.vars.ls_bu(i),...
  res.prisen.vars.rs_bu(i));
end

fprintf('Sensitivity for coefficients in objective:\n')
for i = 1:length(prob.duasen.sub)
  fprintf (...
  'var = %d, beta_1 = %.1f, beta_2 = %.1f, delta_1 = %.1f,delta_2 = %.1f\n', ...
  prob.duasen.sub(i),res.duasen.lr_c(i), ...
  res.duasen.rr_c(i),...
  res.duasen.ls_c(i),...
  res.duasen.rs_c(i));
end

The output from running the example in Listing 14.2 is shown below.

Sensitivity for bounds on constraints:
con = 1, beta_1 = -300.0, beta_2 = 0.0, delta_1 = 3.0,delta_2 = 3.0
con = 2, beta_1 = -700.0, beta_2 = Inf, delta_1 = 0.0,delta_2 = 0.0
con = 3, beta_1 = -500.0, beta_2 = 0.0, delta_1 = 3.0,delta_2 = 3.0
con = 4, beta_1 = -0.0, beta_2 = 500.0, delta_1 = 4.0,delta_2 = 4.0
con = 5, beta_1 = -0.0, beta_2 = 300.0, delta_1 = 5.0,delta_2 = 5.0
con = 6, beta_1 = -0.0, beta_2 = 700.0, delta_1 = 5.0,delta_2 = 5.0
con = 7, beta_1 = -500.0, beta_2 = 700.0, delta_1 = 2.0,delta_2 = 2.0
Sensitivity for bounds on variables:
var = 1, beta_1 = Inf, beta_2 = 300.0, delta_1 = 0.0,delta_2 = 0.0
var = 2, beta_1 = Inf, beta_2 = 100.0, delta_1 = 0.0,delta_2 = 0.0
var = 3, beta_1 = Inf, beta_2 = 0.0, delta_1 = 0.0,delta_2 = 0.0
var = 4, beta_1 = Inf, beta_2 = 500.0, delta_1 = 0.0,delta_2 = 0.0
var = 5, beta_1 = Inf, beta_2 = 500.0, delta_1 = 0.0,delta_2 = 0.0
var = 6, beta_1 = Inf, beta_2 = 500.0, delta_1 = 0.0,delta_2 = 0.0
var = 7, beta_1 = -0.0, beta_2 = 500.0, delta_1 = 2.0,delta_2 = 2.0
Sensitivity for coefficients in objective:
var = 1, beta_1 = Inf, beta_2 = 3.0, delta_1 = 300.0,delta_2 = 300.0
var = 2, beta_1 = Inf, beta_2 = Inf, delta_1 = 100.0,delta_2 = 100.0
var = 3, beta_1 = -2.0, beta_2 = Inf, delta_1 = 0.0,delta_2 = 0.0
var = 4, beta_1 = Inf, beta_2 = 2.0, delta_1 = 500.0,delta_2 = 500.0
var = 5, beta_1 = -3.0, beta_2 = Inf, delta_1 = 500.0,delta_2 = 500.0
var = 6, beta_1 = Inf, beta_2 = 2.0, delta_1 = 500.0,delta_2 = 500.0
var = 7, beta_1 = -2.0, beta_2 = Inf, delta_1 = 0.0,delta_2 = 0.0