WebCab Optimization for COM v2.6

LinearProgramming.ScenarioAnalysisCor Method 

Performs Scenario Analysis on a Linear programming problem by evaluating the location of the extremum (i.e. maximum or minimum) when the coefficients of the linear object function and the constraints are perturbed.

public double[] ScenarioAnalysisCor(
   ExtremumTypes extremumType,
   double[] coefficients,
   double[,] inequalityConstraints,
   double[,] equalityConstraints,
   double[] percentageShiftsOfCoefficients,
   double[] shiftsOfInequalities,
   double[] shiftsOfEqualities
);

Parameters

extremumType
Used to determine whether location of the minimum or maximum of the object function is found. If the minimum is required then input MINIMUM, if the maximum is required then input MAXIMUM.
coefficients
The coefficients of the linear object function f, where f(x1, x2, ...) = coefficients1 * x1 + coefficients2 * x2 + ....
inequalityConstraints
A two-dimensional array containing the coefficients of the inequalities, where each line corresponds to another inequality and contains the inequality coefficients of every variable and a constant value b as described above.
equalityConstraints
A two-dimensional array containing the coefficients of the equalities, where each line (i.e. array) corresponds to another equality and contains the equality coefficients of every variable and a constant value b as described above.
percentageShiftsOfCoefficients
An array which represents the percentages shifts in decimal format (i.e. 1 percent = 0.01) of the coefficients of the linear object function. The first term of the array represents the percentage shift of the first coefficient, the second term the second coefficient and son on. Please note that if the coefficient is negative for example -100, then a shift of 2%, gives result in a coefficient of -102.
shiftsOfInequalities
This is an array which represents the absolute change of the constant terms within the inequalities, which corresponds to a parallel shift of each of the boundaries. Here the first terms of the array corresponds to the absolute change of the first inequalities constant term, the second term corresponds to the absolute change of the second constant term and on so.
shiftsOfEqualities
This is an array which represents the absolute change of the constant terms within the equalities, which corresponds to a parallel shift of each of the boundaries. Here the first terms of the array corresponds to the absolute change of the equalities constant term, the second term corresponds to the absolute change of the second constant term and so on.

Remarks

In particular, this method returns the location of the extremum (i.e. maximum or minimum) of the given Linear Programming problem after one or both of the following has been performed:

  1. The coefficients of the linear object function have been perturbed.
  2. The constraints (or boundaries) of the linear programming function have been linearly shifted.

Overview of Scenario Testing

Scenario Analysis (also known as back testing) is another technique which allows a linear programming problem to be put under various stresses and to measure the implications in terms of the change in the location (and hence value) of the extremum of the object function. The advantage of Scenario Analysis (over Sensitivity Grids) is that it allows all (rather than only two) coefficients of the linear object function to be shifted and parallel shifts of the inequalities and equalities to be made and for the resulting effects on the location of the extremum to be recorded.

Remark: Further details concerning the application and use of Scenario Analysis is described within the accompanying PDF documentation.

Application to the Factory Example

In the case of the Factory Example (see Factory Example description) Scenario Analysis will allow you to see the effect of structural changes within the production procedure and market. For example, say there is a shortage of a particular `means of production' and because of a structural change in the market the profitability of a given product reduces. By applying a suitable parallel shift to the constraint which represents the `means of production' in shortage, and by making the appropriate change of the coefficient corresponding to the change in the profitability of a particular product. Through this method we are able to evaluate the product mix (i.e. location) which results in the greatest profit for the factor under the new business conditions.

Defining the Linear Programming Problem

The linear programming problem is passed to the method by specifying the array of coefficients of the linear object function and by using two 2-dimensional double arrays in order to describe the set of inequality and equality constraints which the solution of the linear programming problem must satisfy. Below we explicitly describe how a given linear programming problem, that is an object function together with a set of inequality and equality constraints can be mapped into the parameters which will be provided to the (simplex) method.

All linear (programming) object functions f can be written in the following form:

f(x1, x2, ..., xN) = coefficients1 * x1 + coefficients2 * x2 + ... + coefficientsN * xN,
where N is the number of variables considered, coefficientsi are the set of coefficients of the linear function and x1,...,xN are the coordinates (i.e. the degrees of freedom of the problem) of the solution set over which a point where an extremum (i.e. minimum or maximum) of the linear function is sought.

The solution set is spanned by the coordinates x1,...,xNx which are subject to a set of inequality and equality constraints. That is, the solution set over which an extremum is sought is any combination of coordinates which satisfies the given constraints. These inequality and equality constraints are supplied in the form of 2 dimensional double arrays, where each line of the 2 dimensional array corresponds to the coefficients within a linear equality or inequality constraint. That is, in order to express the following inequality:

c1 * x1 + c2 * x2 + ... + cN * xN + b >= 0,
you will need to supply a line within the two-dimensional array which contains the inequality constraints coefficients plus the constant b (i.e. the N + 1th term), according to the following convention:
{c1, c2, ..., cN, b}
For every inequality of the problem considered you will need to provide such an array within the inequality constraints two-dimensional array.


The equality constraints for the problem are expressed in a similar fashion to the inequality constraints, where the coefficients are listed in order followed by a real number. The equalities should be collected within a two-dimensional array in a similar way to the inequalities and passed as a parameter to the method. In particular, each equality is expressed in the following form: c1 * x1 + c2 * x2 + ... + cN * xN + b = 0, for which you will need to provide the following array within the equality two-dimensional array:

{c1, c2, ..., cN, b}
For each of the equality constraints you will need to first encode then as an array in accordance with the above convention and then add the array to the equality constraints two-dimensional array.

Notes on the Scenario Analysis parameters

As mentioned above Scenario Analysis stresses the linear optimization problem by shifting one or both of the following:

  1. Linear Object Function Coefficients Shifts - which are described by the array percentageShiftsOfCoefficients
  2. Equality and Inequality Constraints Shift - for which the (parallel) inequality shifts are described by the array shiftsOfInequalities, and the (parallel) equality shifts are described by the array shiftsOfEqualities
Below be details the way in which a given set of shifts of the object function and constraints is described in terms of the methods parameters.

Object Function Coefficient Shifts: Within this methods the sizes of the shifts of the objects functions coefficients are provided to the method as percentages of a selected coefficients initial values. That is, the shifts are proportional to the absolute value of the (initial) values of the coefficients. The absolute size of each shift of the i-th coefficient is Absolute Shift size := percentageShift[i] * abs(coefficients[i]), where abs is the absolute value, percentageShift[i] is the i-th term of the parameter array percentageShiftsOfCoefficients and coefficients[i] is the i-th coefficient. By considering each of the coefficients shifts we are able to populate the parameter array percentageShiftsOfCoefficients.

Equality Constraint Shifts: A parallel shift of an equality constraint by `d', is equivalent to mapping the constraint:

c1 * x1 + c2 * x2 + ... + cN * xN + b >= 0,
into:
c1 * x1 + c2 * x2 + ... + cN * xN + b + d >= 0,

In accordance with the notes above concerning the construction of the 2-dimensional array equalityConstraints; representing the equality constraints, this parallel shifted equality constraint would be represented within the 2-dimensional array as:

{c1, c2, ..., cN, b+d}

In order to construct the 2-dimensional array representing the set of shifted equality constraints we go through each of the constraints contained within the Linear programming problem and make the changes within the 2-dimensional array equalityConstraints, which correspond to the absolute shifts of the constant term for each of the equality constraints.

Inequality Constraint Shifts: A parallel shift of an inequality constraint by `d', is equivalent to mapping the constraint:

c1 * x1 + c2 * x2 + ... + cN * xN + b > 0,
into:
c1 * x1 + c2 * x2 + ... + cN * xN + b + d > 0,

In accordance with the notes above concerning the construction of the 2-dimensional array inequalityConstraints; representing the inequality constraints, this parallel shifted inequality constraint would be represented within the 2-dimension array as:

{c1, c2, ..., cN, b+d}

In order to construct the 2-dimensional array representing the set of shifted inequality constraints we go through each of the constraints contained within the Linear programming problem and make the changes within the 2-dimensional array inequalityConstraints, which correspond to the absolute shifts of the constant term for each of the inequality constraints.

Exceptions

Exception TypeCondition
LinearProgrammingExceptionThrown if either the region given by the constraints is empty or if the function is unbounded on the region.

See Also

LinearProgramming Class | WebCab.COM.Math.Optimization.LinearProgramming Namespace