Given an optimization problem it is often useful to obtain information about how the optimal objective value change when the problem parameters are perturbed. For instance assume that a bound represents a capacity of a machine. Now, it may be possible to expand the capacity for a certain cost and hence it worthwhile to know what the value of additional capacity is. This is precisely the type of questions sensitivity analysis deals with.
Analyzing how the optimal objective value changes when the problem data is changed is called sensitivity analysis.
Currently, sensitivity analysis is only available for continuous linear optimization problems. Moreover, MOSEK can only deal with perturbations in bounds or objective coefficients.
The book [20] discusses the classical sensitivity analysis in Chapter 10 whereas the book [15, Chapter 19] presents a modern introduction to sensitivity analysis. Finally, it is recommended to read the short paper [2] to avoid some of the pitfalls associated with sensitivity analysis.
Assume that we are given the problem
![]() |
(14.4.1) |
and we want to know how the optimal objective value changes as is perturbed. In order to answer this question then define the perturbed problem for
as follows
![]() |
(14.4.2) |
where is the ith column of the identity matrix. The function
![]() |
(14.4.3) |
shows the optimal objective value as a function of . Note that a change in
corresponds to a perturbation in
and hence (14.4.3) shows the optimal objective value as a function of
.
It is possible to prove that the function (14.4.3) is a piecewise linear and convex function i.e. the function may look like the illustration in Figure 14.1.
![]() ![]() ![]() |
Clearly, if the function does not change much when
is changed, then we can conclude that the optimal objective value is insensitive to changes in
. Therefore, we are interested in how
changes for small changes in
. Now define
![]() |
(14.4.4) |
to be the so called shadow price related to . The shadow price specifies how the objective value changes for small changes in
around zero. Moreover, we are interested in the so called linearity interval
![]() |
(14.4.5) |
for which
![]() |
(14.4.6) |
To summarize the sensitivity analysis provides a shadow price and the linearity interval in which the shadow price is constant.
The reader may have noticed that we are sloppy in the definition of the shadow price. The reason is that the shadow price is not defined in the right example in Figure 14.1 because the function is not differentiable for
. However, in that case we can define a left and a right shadow price and a left and a right linearity interval.
In the above discussion we only discussed changes in . We define the other optimal objective value functions as follows
![]() |
(14.4.7) |
Given these definitions it should be clear how linearity intervals and shadow prices are defined for the parameters etc.
In MOSEK a constraint can be specified as either an equality constraints or a ranged constraints. Suppose constraint i is an equality constraint. We then define the optimal value function for constraint i by
![]() |
(14.4.8) |
Thus for a equality constraint the upper and lower bound (which are equal) are perturbed simultaneously. From the point of view of MOSEK sensitivity analysis a ranged constrain with therefore differs from an equality constraint.
The classical sensitivity analysis discussed in most textbooks about linear optimization, e.g. [20, Chapter 10], is based on an optimal basic solution or equivalently on an optimal basis. This method may produce misleading results [15, Chapter 19] but is computationally cheap. Therefore, and for historical reasons this method is available 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 then the basis type sensitivity analysis computes the linearity interval such 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. This implies that the computed interval is only a subset of the largest interval for which the shadow price is constant. Furthermore, the optimal objective value function might have a breakpoint for
. In this case 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.
Another method for computing the complete linearity interval is called the optimal partition type sensitivity analysis. The main drawback to the optimal partition type sensitivity analysis is it is computationally expensive. This type of sensitivity analysis is currently provided as an experimental feature in MOSEK.
Given optimal primal and dual solutions to (14.4.1) i.e. and
then the optimal objective value is given by
![]() |
(14.4.9) |
The left and right shadow prices and
for
is given by the pair of optimization problems
![]() |
(14.4.10) |
and
![]() |
(14.4.11) |
The above two optimization problems makes it easy to interpret-ate the shadow price. Indeed assume that is an arbitrary optimal solution then it must hold
![]() |
(14.4.12) |
Next the linearity interval for
is computed by solving the two optimization problems
![]() |
(14.4.13) |
and
![]() |
(14.4.14) |
The linearity intervals and shadow prices for
and
can be computed in a similar way to how it is computed for
.
The left and right shadow price for denoted
and
respectively is given by the pair optimization problems
![]() |
(14.4.15) |
and
![]() |
(14.4.16) |
Once again the above two optimization problems makes it easy to interpret-ate the shadow prices. Indeed assume that is an arbitrary primal optimal solution then it must hold
![]() |
(14.4.17) |
The linearity interval for a
is computed as follows
![]() |
(14.4.18) |
and
![]() |
(14.4.19) |
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 Figure 14.2.
If we denote the number of transported goods from location i to location j by , the problem can be formulated as the linear optimization problem
minimize
![]() |
(14.4.20) |
subject to
![]() |
(14.4.21) |
The basis type and the optimal partition type sensitivity results for the transportation problem is shown in Table 14.1 and 14.2 respectively.
Basis type
Con.
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.
-∞
300.00
0.00
0.00
-∞
100.00
0.00
0.00
-∞
0.00
0.00
0.00
-∞
500.00
0.00
0.00
-∞
500.00
0.00
0.00
-∞
500.00
0.00
0.00
-0.000000
500.00
2.00
2.00
Optimal partition type
Con.
1
-300.00
500.00
3.00
1.00
2
-700.00
+∞
-0.00
-0.00
3
-500.00
500.00
3.00
1.00
4
-500.00
500.00
2.00
4.00
5
-100.00
300.00
3.00
5.00
6
-500.00
700.00
3.00
5.00
7
-500.00
700.00
2.00
2.00
Var.
-∞
300.00
0.00
0.00
-∞
100.00
0.00
0.00
-∞
500.00
0.00
2.00
-∞
500.00
0.00
0.00
-∞
500.00
0.00
0.00
-∞
500.00
0.00
0.00
-∞
500.00
0.00
2.00
Looking at the results from the optimal partition type sensitivity analysis we see that for the constraint number 1 we have
Basis type
Var.
-∞
3.00
300.00
300.00
-∞
∞
100.00
100.00
-2.00
∞
0.00
0.00
-∞
2.00
500.00
500.00
-3.00
∞
500.00
500.00
-∞
2.00
500.00
500.00
-2.00
∞
0.00
0.00
Optimal partition type
Var.
-∞
3.00
300.00
300.00
-∞
∞
100.00
100.00
-2.00
∞
0.00
0.00
-∞
2.00
500.00
500.00
-3.00
∞
500.00
500.00
-∞
2.00
500.00
500.00
-2.00
∞
0.00
0.00
and
. Therefore, we have a left linearity interval of [-300,0] and a right interval of [0,500]. The corresponding left and right shadow price is 3 and 1 respectively. This implies that if the upper bound on constraint 1 increases by
![]() |
(14.4.22) |
then the optimal objective value will decrease by the value
![]() |
(14.4.23) |
Correspondingly, if the upper bound on constraint 1 is decreased by
![]() |
(14.4.24) |
then the optimal objective value will increased by the value
![]() |
(14.4.25) |
The following describe sensitivity analysis from the MATLAB toolbox.
The index of bounds/variables to analyzed for sensitivity are specified in the following subfields of the matlab structure prob:
Indexes of constraints, where upper bounds are analyzed for sensitivity.
Indexes of constraints, where lower bounds are analyzed for sensitivity.
Indexes of variables, where upper bounds are analyzed for sensitivity.
Indexes of variables, where lower bounds are analyzed for sensitivity.
Index of variables where coefficients are analysed for sensitivity.
For an equality constraint, the index can be specified in either subu or subl. After calling
[r,res] = mosekopt('minimize',prob)
the results are returned in the subfields prisen and duasen of res.
The field prisen is structured as follows:
MATLAB structure with subfields:
Left value in the linearity interval for a lower bound.
Right value in the linearity interval for a lower bound.
Left shadow price for a lower bound.
Right shadow price for a lower bound.
Left value in the linearity interval for an upper bound.
Right value in the linearity interval for an upper bound.
Left shadow price for an upper bound.
Right shadow price for an upper bound.
MATLAB structure with subfields:
Left value in the linearity interval for a lower bound on a varable.
Right value in the linearity interval for a lower bound on a varable.
Left shadow price for a lower bound on a varable.
Right shadow price for lower bound on a varable.
Left value in the linearity interval for an upper bound on a varable.
Right value in the linearity interval for an upper bound on a varable.
Left shadow price for an upper bound on a varables.
Right shadow price for an upper bound on a varables.
The field duasen is structured as follows:
Left value of linearity interval for an objective coefficient.
Right value of linearity interval for an objective coefficient.
Left shadow price for an objective coefficients .
Right shadow price for an objective coefficients.
The type (basis or optimal partition) of analysis to be performed can be selected by setting the parameter
MSK_IPAR_SENSITIVITY_TYPE
to one of the values:
MSK_SENSITIVITY_TYPE_BASIS = 0 MSK_SENSITIVITY_TYPE_OPTIMAL_PARTITION = 1
as seen in the following example.
Consider the problem defined in (14.4.21). 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.
% sensitivity.m % Obtain all symbolic constants % defined by MOSEK. [r,res] = mosekopt('symbcon'); sc = res.symbcon; [r,res] = mosekopt('read(transport.lp) echo(0)'); prob = res.prob; % 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]; %Select basis sensitivity analysis and optimize. param.MSK_IPAR_SENSITIVITY_TYPE=sc.MSK_SENSITIVITY_TYPE_BASIS; [r,res] = mosekopt('minimize echo(0)',prob,param); results(1) = res; % Select optimal partition sensitivity analysis and optimize. param.MSK_IPAR_SENSITIVITY_TYPE=sc.MSK_SENSITIVITY_TYPE_OPTIMAL_PARTITION; [r,res] = mosekopt('minimize echo(0)',prob,param); results(2) = res; %Print results for m = [1:2] if m == 1 fprintf('\nBasis sensitivity results:\n') else fprintf('\nOptimal partition sensitivity results:\n') end 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.subu(i),results(m).prisen.cons.lr_bu(i), ... results(m).prisen.cons.rr_bu(i),... results(m).prisen.cons.ls_bu(i),... results(m).prisen.cons.rs_bu(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),results(m).prisen.cons.lr_bu(i), ... results(m).prisen.cons.rr_bu(i),... results(m).prisen.cons.ls_bu(i),... results(m).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),results(m).prisen.vars.lr_bl(i), ... results(m).prisen.vars.rr_bl(i),... results(m).prisen.vars.ls_bl(i),... results(m).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),results(m).prisen.vars.lr_bu(i), ... results(m).prisen.vars.rr_bu(i),... results(m).prisen.vars.ls_bu(i),... results(m).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),results(m).duasen.lr_c(i), ... results(m).duasen.rr_c(i),... results(m).duasen.ls_c(i),... results(m).duasen.rs_c(i)); end end
The output from running the example sensitivity.m is shown below.
Basis sensitivity results: 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 Optimal partition sensitivity results: Sensitivity for bounds on constraints: con = 1, beta_1 = -300.0, beta_2 = 500.0, delta_1 = 3.0,delta_2 = 1.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 = 500.0, delta_1 = 3.0,delta_2 = 1.0 con = 4, beta_1 = -500.0, beta_2 = 500.0, delta_1 = 2.0,delta_2 = 4.0 con = 5, beta_1 = -100.0, beta_2 = 300.0, delta_1 = 3.0,delta_2 = 5.0 con = 6, beta_1 = -500.0, beta_2 = 700.0, delta_1 = 3.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 = 500.0, delta_1 = 0.0,delta_2 = 2.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 = Inf, beta_2 = 500.0, delta_1 = 0.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