Initializing help system before first use

Utils

  • java.lang.Object
    • com.dashoptimization.objects.Utils

  • public abstract class Utils
    extends java.lang.Object
    Utilities for modeling.
    Since:
    43.00
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • sum

        public static <A extends ExpressionSumExpression sum​(int count,
                                                               java.util.function.Function<java.lang.Integer,​A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the return sum.
        Type Parameters:
        A - Type of expressions that are summed up.
        Parameters:
        count - Number of elements in the sum.
        makeTerm - Function to produce an expression for each data element.
        Returns:
        The sum.
        Since:
        43.00
      • sum

        public static <T,​A extends ExpressionSumExpression sum​(java.util.stream.Stream<T> data,
                                                                       java.util.function.Function<? super T,​A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the return sum.
        Type Parameters:
        T - Type of data in data.
        A - Type of expressions summed up.
        Parameters:
        data - Data to iterate.
        makeTerm - Function to create terms.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T,​A extends ExpressionSumExpression sum​(java.lang.Iterable<T> data,
                                                                       java.util.function.Function<? super T,​A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the return sum.
        Type Parameters:
        T - Type of data in data.
        A - Type of expressions to be summed up.
        Parameters:
        data - The data from which to build the sum.
        makeTerm - Function to produce an expression for each data element.
        Returns:
        The sum.
        Since:
        43.00
      • sum

        public static <T,​A extends ExpressionSumExpression sum​(T[] data,
                                                                       java.util.function.Function<? super T,​A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the returned sum.
        Type Parameters:
        T - Type of data in data.
        A - Type of expressions to be summed up.
        Parameters:
        data - Data to iterate.
        makeTerm - Function to create terms.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T,​A extends ExpressionSumExpression sum​(int[] data,
                                                                       java.util.function.IntFunction<A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the returned sum.
        Type Parameters:
        T - Type of data in data.
        A - Type of expressions to be summed up.
        Parameters:
        data - Data to iterate.
        makeTerm - Function to create terms.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T,​A extends ExpressionSumExpression sum​(java.util.stream.IntStream data,
                                                                       java.util.function.IntFunction<A> makeTerm)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the returned sum.
        Type Parameters:
        T - Type of data in data.
        A - Type of expressions to be summed up.
        Parameters:
        data - Data to iterate.
        makeTerm - Function to create terms.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T extends ExpressionSumExpression sum​(java.util.stream.Stream<T> terms)
        Create an expression from a stream of other expressions. Note that the other expressions are copied by reference, so changing them later will affect the returned expression.
        Type Parameters:
        T - The actual term type.
        Parameters:
        terms - The expression to sum up.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T extends ExpressionSumExpression sum​(java.lang.Iterable<T> terms)
        Create an expression from a collection of other expressions. Note that the other expressions are copied by reference, so changing them later will affect the returned expression.
        Type Parameters:
        T - The actual term type.
        Parameters:
        terms - The expression to sum up.
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static <T extends ExpressionSumExpression sum​(T[] terms)
        Create a sum of expressions. Note that the terms are captured by reference, i.e., changing those terms later will affect the return sum.
        Type Parameters:
        T - The actual term type.
        Parameters:
        terms - Terms to sum up
        Returns:
        The new expression.
        Since:
        43.00
      • sum

        public static SumExpression sum​(Expression firstTerm,
                                        Expression... moreTerms)
        Create an expression from an array of other expressions. Note that the other expressions are copied by reference, so changing them later will affect the returned expression.
        Parameters:
        firstTerm - The first term to sum up.
        moreTerms - The other terms to sum up.
        Returns:
        The new expression.
        Since:
        43.00
      • uminus

        public static Expression uminus​(Expression value)
        Create an expression for -value.
        Parameters:
        value - The value to negate.
        Returns:
        An expression representing -value.
        Since:
        43.00
      • plus

        public static Expression plus​(Expression augend,
                                      Expression addend)
        Create an expression for augend + addend. This is equivalent to augend.plus(addend) and is only provided for completeness.
        Parameters:
        augend - augend.
        addend - addend.
        Returns:
        sum of augend and addend.
        Since:
        43.00
      • plus

        public static Expression plus​(double augend,
                                      Expression addend)
        Create an expression for augend + addend. This is equivalent to new ConstantExpression(augend).plus(addend) and is only provided for completeness.
        Parameters:
        augend - augend.
        addend - addend.
        Returns:
        sum of augend and addend.
        Since:
        43.00
      • plus

        public static Expression plus​(Expression augend,
                                      double addend)
        Create an expression for augend + addend. This is equivalent to augend.plus(addend) and is only provided for completeness.
        Parameters:
        augend - augend.
        addend - addend.
        Returns:
        sum of augend and addend.
        Since:
        43.00
      • minus

        public static Expression minus​(Expression minuend,
                                       Expression subtrahend)
        Create an expression for minuend - subtrahend. This is equivalent to minuend.minus(subtrahend) and is only provided for completeness.
        Parameters:
        minuend - minuend.
        subtrahend - subtrahend.
        Returns:
        difference of minuend and subtrahend.
        Since:
        43.00
      • minus

        public static Expression minus​(double minuend,
                                       Expression subtrahend)
        Create an expression for minuend + subtrahend. This is equivalent to new ConstantExpression(minuend).minus(subtrahend) and is only provided for completeness.
        Parameters:
        minuend - minuend.
        subtrahend - subtrahend.
        Returns:
        difference of minuend and subtrahend.
        Since:
        43.00
      • minus

        public static Expression minus​(Expression minuend,
                                       double subtrahend)
        Create an expression for minuend + subtrahend. This is equivalent to minuend.minus(subtrahend) and is only provided for completeness.
        Parameters:
        minuend - minuend.
        subtrahend - subtrahend.
        Returns:
        difference of minuend and subtrahend.
        Since:
        43.00
      • div

        public static Expression div​(Expression dividend,
                                     Expression divisor)
        Create an expression for dividend / divisor. This is equivalent to dividend.div(divisor) and is only provided for completeness.
        Parameters:
        dividend - dividend.
        divisor - divisor.
        Returns:
        quotient of dividend and divisor.
        Since:
        43.00
      • div

        public static Expression div​(double dividend,
                                     Expression divisor)
        Create an expression for dividend + divisor. This is equivalent to new ConstantExpression(dividend).div(divisor) and is only provided for completeness.
        Parameters:
        dividend - dividend.
        divisor - divisor.
        Returns:
        quotient of dividend and divisor.
        Since:
        43.00
      • div

        public static Expression div​(Expression dividend,
                                     double divisor)
        Create an expression for dividend + divisor. This is equivalent to dividend.div(divisor) and is only provided for completeness.
        Parameters:
        dividend - dividend.
        divisor - divisor.
        Returns:
        quotient of dividend and divisor.
        Since:
        43.00
      • mul

        public static Expression mul​(Expression factor1,
                                     Expression factor2)
        Create an expression for factor1 * factor2. This is equivalent to factor1.mul(factor2) and is only provided for completeness.
        Parameters:
        factor1 - factor1.
        factor2 - factor2.
        Returns:
        product of factor1 and factor2.
        Since:
        43.00
      • mul

        public static Expression mul​(double factor1,
                                     Expression factor2)
        Create an expression for factor1 + factor2. This is equivalent to new ConstantExpression(factor1).mul(factor2) and is only provided for completeness.
        Parameters:
        factor1 - factor1.
        factor2 - factor2.
        Returns:
        product of factor1 and factor2.
        Since:
        43.00
      • mul

        public static Expression mul​(Expression factor1,
                                     double factor2)
        Create an expression for factor1 + factor2. This is equivalent to factor1.mul(factor2) and is only provided for completeness.
        Parameters:
        factor1 - factor1.
        factor2 - factor2.
        Returns:
        product of factor1 and factor2.
        Since:
        43.00
      • pow

        public static BinaryExpression pow​(Expression basis,
                                           Expression exp)
        Create an expression for base ^ exp. Note that adding the result of pow to your model in any way will turn the model into a non-linear model. In order to square a variable or linear expression, use one of Variable.square(), LinTerm.square(), or LinExpression.square(). They all create linear or quadratic expressions.
        Parameters:
        basis - Base.
        exp - Exponent.
        Returns:
        basis raised to the power of exp.
        Since:
        43.00
      • pow

        public static BinaryExpression pow​(double basis,
                                           Expression exp)
        Create an expression for base ^ exp. Note that adding the result of pow to your model in any way will turn the model into a non-linear model. In order to square a variable or linear expression, use one of Variable.square(), LinTerm.square(), or LinExpression.square(). They all create linear or quadratic expressions.
        Parameters:
        basis - Base.
        exp - Exponent.
        Returns:
        basis raised to the power of exp.
        Since:
        43.00
      • pow

        public static BinaryExpression pow​(Expression basis,
                                           double exp)
        Create an expression for base ^ exp. Note that adding the result of pow to your model in any way will turn the model into a non-linear model. In order to square a variable or linear expression, use one of Variable.square(), LinTerm.square(), or LinExpression.square(). They all create linear or quadratic expressions.
        Parameters:
        basis - Base.
        exp - Exponent.
        Returns:
        basis raised to the power of exp.
        Since:
        43.00
      • log10

        public static InternalFunctionExpression log10​(Expression value)
        Create an expression for log10(value).
        Parameters:
        value - Function argument.
        Returns:
        log10(value).
        Since:
        43.00
      • ln

        public static InternalFunctionExpression ln​(Expression value)
        Create an expression for ln(value).
        Parameters:
        value - Function argument.
        Returns:
        ln(value).
        Since:
        43.00
      • exp

        public static InternalFunctionExpression exp​(Expression value)
        Create an expression for exp(value).
        Parameters:
        value - Function argument.
        Returns:
        exp(value).
        Since:
        43.00
      • abs

        public static InternalFunctionExpression abs​(Expression value)
        Create an expression for abs(value).

        Used in these examples:

        • AddMipSol
        • FixBV
        • GlobalObjectiveParametrics
        • GlobalRHSParametrics
        • GoalProg
        • Knapsack
        • LoadLP
        • MipSolEnum
        • MipSolPool
        • MostViolated
        • Repair
        • SaveSol
        • Tableau
        • Trimloss
        Parameters:
        value - Function argument.
        Returns:
        abs(value).
        Since:
        43.00
      • sqrt

        public static InternalFunctionExpression sqrt​(Expression value)
        Create an expression for sqrt(value).

        Used in these examples:

        • TSP
        Parameters:
        value - Function argument.
        Returns:
        sqrt(value).
        Since:
        43.00
      • sin

        public static InternalFunctionExpression sin​(Expression value)
        Create an expression for sin(value).

        Used in these examples:

        • PolygonMap
        • PolygonMapDelta
        • PolygonMultiMap
        • PolygonMultiMapDelta
        • PolygonVecMap
        • PolygonVecMapDelta
        Parameters:
        value - Function argument.
        Returns:
        sin(value).
        Since:
        43.00
      • cos

        public static InternalFunctionExpression cos​(Expression value)
        Create an expression for cos(value).

        Used in these examples:

        • PolygonMap
        • PolygonMapDelta
        • PolygonMultiMap
        • PolygonMultiMapDelta
        • PolygonVecMap
        • PolygonVecMapDelta
        Parameters:
        value - Function argument.
        Returns:
        cos(value).
        Since:
        43.00
      • tan

        public static InternalFunctionExpression tan​(Expression value)
        Create an expression for tan(value).
        Parameters:
        value - Function argument.
        Returns:
        tan(value).
        Since:
        43.00
      • arcsin

        public static InternalFunctionExpression arcsin​(Expression value)
        Create an expression for arcsin(value).
        Parameters:
        value - Function argument.
        Returns:
        arcsin(value).
        Since:
        43.00
      • arccos

        public static InternalFunctionExpression arccos​(Expression value)
        Create an expression for arccos(value).
        Parameters:
        value - Function argument.
        Returns:
        arccos(value).
        Since:
        43.00
      • arctan

        public static InternalFunctionExpression arctan​(Expression value)
        Create an expression for arctan(value).
        Parameters:
        value - Function argument.
        Returns:
        arctan(value).
        Since:
        43.00
      • sign

        public static InternalFunctionExpression sign​(Expression value)
        Create an expression for sign(value).
        Parameters:
        value - Function argument.
        Returns:
        sign(value).
        Since:
        43.00
      • min

        public static InternalFunctionExpression min​(Expression... value)
        Create an expression for min(value, ...). Consider also using Variable.minOf(...).

        Used in these examples:

        • MostViolated
        Parameters:
        value - Arguments.
        Returns:
        min(value...).
        Since:
        43.00
      • max

        public static InternalFunctionExpression max​(Expression... value)
        Create an expression for max(value, ...). Consider also using Variable.maxOf.
        Parameters:
        value - Arguments.
        Returns:
        max(value...).
        Since:
        43.00
      • prod

        public static Expression prod​(Expression... value)
        Create an expression for prod(value, ...).
        Parameters:
        value - Expressions to multiply.
        Returns:
        The product of the expression in value.
        Since:
        43.00
      • scalarProduct

        public static LinExpression scalarProduct​(java.util.stream.Stream<Variable> variables,
                                                  java.util.stream.Stream<java.lang.Double> coefs)
        Compute the scalar product between a vector of variables and a vector of coefficients. Both vectors are specified as streams of elements.
        Parameters:
        variables - Variables in the scalar product.
        coefs - Coefficients in the scalar product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00
      • scalarProduct

        public static LinExpression scalarProduct​(Variable[] variables,
                                                  double[] coefs)
        Compute the scalar product between a vector of variables and a vector of coefficients. Both vectors are specified as arrays.
        Parameters:
        variables - Variables in the scalar product.
        coefs - Coefficients in the scalar product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00
      • scalarProduct

        public static LinExpression scalarProduct​(java.lang.Iterable<Variable> variables,
                                                  java.lang.Iterable<java.lang.Double> coefs)
        Compute the scalar product between a vector of variables and a vector of coefficients. Both vectors are specified as iterables of elements.
        Parameters:
        variables - Variables in the scalar product.
        coefs - Coefficients in the scalar product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00
      • scalarProduct

        public static <K> LinExpression scalarProduct​(java.util.Map<K,​Variable> variables,
                                                      java.util.Map<K,​java.lang.Double> coefs)
        Compute the scalar product between a map of variables and a map of coefficients. The function assumes that variables and coefs have the same keys (missing keys in coefs are treated as zero) and creates a new linear expression by iterating over the keys in variables and adding up the variable/coefficient pair for each key.
        Type Parameters:
        K - Key type.
        Parameters:
        variables - Map of variables.
        coefs - Map of coefficients for the variables in variables.
        Returns:
        The new linear expression.
        Since:
        43.00
      • scalarProduct

        public static QuadExpression scalarProduct​(java.util.stream.Stream<Variable> variables1,
                                                   java.util.stream.Stream<Variable> variables2,
                                                   java.util.stream.Stream<java.lang.Double> coefs)
        Compute the elementwise product between two vectors of variables and a vector of coefficients. All vectors are specified as streams of elements.
        Parameters:
        variables1 - First variables in the product.
        variables2 - Second variables in the product.
        coefs - Coefficients in the product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00
      • scalarProduct

        public static QuadExpression scalarProduct​(Variable[] variables1,
                                                   Variable[] variables2,
                                                   double[] coefs)
        Compute the elementwise product between two vectors of variables and a vector of coefficients. All vectors are specified as arrays.
        Parameters:
        variables1 - First variables in the product.
        variables2 - Second variables in the product.
        coefs - Coefficients in the product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00
      • scalarProduct

        public static QuadExpression scalarProduct​(java.lang.Iterable<Variable> variables1,
                                                   java.lang.Iterable<Variable> variables2,
                                                   java.lang.Iterable<java.lang.Double> coefs)
        Compute the elementwise product between two vectors of variables and a vector of coefficients. All vectors are specified as collection of elements.
        Parameters:
        variables1 - First variables in the product.
        variables2 - Second variables in the product.
        coefs - Coefficients in the product.
        Returns:
        The sum of the specified terms.
        Since:
        43.00

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.