# OptRhsSa

## Contents

## OptRhsSa(opt*, constraint*)

Computes the range over which a right-hand-side constraint coefficient can vary in a linear or quadratic optimization program without a change in the dual value (aka shadow price) of the optimal solution. See OptShadow for more information on what the dual value is.

«opt» is an LP or QP returned from a previous call to DefineOptimization. This function cannot be applied to an NLP.

«constraint» identifies which constraint coefficient you want the sensitivity for. You may provide your problem's *constraint index* for this parameter to get the sensitivities for all RHS coefficients.

### The Rhs constant term

Depending on how a constraint is written, the right-hand side constant is not always obvious. For example, consider the following quadratic constraint:

- $ (x+3)(y+2) <= (x-1)^2 $

The right-hand side constant here is 5. Obvious, right? It becomes a bit more obvious if you algebraically re-arrange the terms, moving all constants (those terms that don't depend on the decision variables) to the right-hand side, and everything else to the left side. Doing so yields:

- $ x^2-xy-4x-3y \ge 5 $

So when your constraint is expressed as

`(x + 3)*(y + 2) <= (x - 1)^2`

,

**OptRhsSa** provides the range over which the *5* can vary.

### Multiple comparison constraints

When you have a constraint with multiple *cascaded* comparisons, e.g.:

`10 <= 3*x + 2*y <= 20`

{*}

Then **OptRhsSa** returns the range for the greated upper bound coefficient -- in this case, the range over which the 20 can vary. You would also get the range over which 20 varies if the same constraint has been written as:

`20 >= 3*x + 2*y >= 10`

since 20 is still the upper bound coefficient when it appears on the left-hand side. Conversely, you would get the range for the 10 coefficient in this example if you wrote your constraint as:

`-10 >= -3*x - 2*y >= -20`

{**}

where **OptRhsSa** would yield the range over which -10 could vary, since -10 is now the upper bound constraint.

In more general constraints, it becomes hard to predict which side will be the upper and lower bound side. For example, the same constraint might be expressed as:

`3*x >= 10 - 2*y >= 3*x - 20`

When Analytica re-arranges this constraint, it is hard to predict whether it will obtain the {*} form above or the {**} form above. The lesson is that when you really want to know the range for a particular side of the constraint, it is more reliable to divide the constraint into separate single comparisons. This must be traded off with the fact that you may increase your count of scalar constraints (which is relevant for solver engines that have a limit on the number of scalar constraints allowed).

## History

This function was introduced in Analytica 4.3; an earlier version of the function was called LpRhsSa.

## See Also

- OptScalarToConstraint
- OptShadow
- OptSlack
- DefineOptimization
- OptObjectiveSa
- OptReducedCost
- LpRhsSa -- for Analytica 4.2 and earlier

Enable comment auto-refresher