Main Content

Expression ContainsInforNaN

Optimization modeling functions do not allow you to specify complex,Inf, orNaNvalues. However,InforNaNexpressions can arise during ordinary operations. Often, these expressions lead to erroneous solutions.

Optimization expressions containingInforNaNcannot be displayed. For example, the largest real number in double precision arithmetic is about1.8e308. So2e308overflows toInf.

x = optimvar('x'); y = 1e308; expr = 2*x*y
expr = OptimizationExpression Expression contains Inf or NaN.

Similarly, becauseInf - Inf = NaN, the following expression cannot be displayed.

expr = 2*x*y - 3*x*y
expr = OptimizationExpression Expression contains Inf or NaN.

If any of your optimization expressions containInforNaN, try to eliminate these values before callingsolve. To do so:

  • Search for these expressions by using theshoworwritefunctions.

  • Check whether the expressions came from a division by zero or from the addition or multiplication of large quantities. If so, eliminate or correct the expressions.

  • Usually, these expressions appear as the result of errors. However, sometimes they arise from poor scaling. If necessary, divide each relevant expression by a large enough scalar so that the expression no longer overflows, or use another scaling operation.

See Also

|

Related Topics