Initializing help system before first use

XPRBexpr

  • java.lang.Object
    • com.dashoptimization.XPRBexpr
  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    XPRBlinExp, XPRBquadExp, XPRBrelation


    public class XPRBexpr
    extends java.lang.Object
    implements java.lang.Cloneable
    This class represents an expression in BCL. All variables in an expression must belong to the same problem.
    • Constructor Detail

      • XPRBexpr

        public XPRBexpr(double d,
                        XPRBvar v)
        Create an expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
         
        Parameters:
        d - a double constant (= coefficient or constant term)
        v - a variable of type XPRBvar
      • XPRBexpr

        public XPRBexpr(double d,
                        XPRBvar v1,
                        XPRBvar v2)
        Create a quadratic expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBvar x2;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1,x2);
         
        Parameters:
        d - a double constant (= coefficient or constant term)
        v1 - a variable of type XPRBvar
        v2 - a variable of type XPRBvar
    • Method Detail

      • clone

        public java.lang.Object clone()
        Make a copy of an expression.
        Overrides:
        clone in class  java.lang.Object
        Returns:
        A new expression
      • reset

        public void reset()
        Reset an expression. This method deletes the content of an expression.
      • getSol

        public double getSol()
        Get the evaluation of an expression with the current solution. This method returns the evaluation of the expression with the current solution values for all its variables that are in the problem (that is, for which a solution value is available). All other variables are treated as 0.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1;
             double sol;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL);
             l1 = new XPRBexpr(3.7, x1);
             l1.add(x2);
             expl2.lpOptimize();
             sol = l1.getSol();
         
        Returns:
        Evaluation of an expression (default 0)
      • neg

        public XPRBexpr neg()
        Negate an expression. This methods turns an expression l into the expression -1*l.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.neg();
         
        Returns:
        An expression
      • neg

        public static XPRBexpr neg(XPRBexpr l)
        Create the negation of an expression. This methods returns the negation -1*l of an expression l.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1, l2;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l2 = XPRBexpr.neg(l1);
         
        Returns:
        A new expression
      • add

        public XPRBexpr add(XPRBexpr l)
        Add an expression to an expression.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1, l2;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr(x2);
             l2.add(l1);
         
        Parameters:
        l - expression of type XPRBexpr
        Returns:
        An expression
      • add

        public static XPRBexpr add(XPRBexpr l1,
                                   XPRBexpr l2)
        Create the sum of two expressions.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1, l2, l3;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr(x2);
             l3 = XPRBexpr.add(l1,l2);
         
        Parameters:
        l1 - expression of type XPRBexpr
        l2 - expression of type XPRBexpr
        Returns:
        A new expression
      • setTerm

        public XPRBexpr setTerm(XPRBvar var,
                                double val)
        Set a term in an expression. This method sets the coefficient of a given variable to the value val.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.setTerm(x1, 5.4);        // Set coefficient of x1 to 5.4
         
        Parameters:
        var - variable of type XPRBvar
        val - value of the coefficient of the variable var
        Returns:
        An expression
      • setTerm

        public XPRBexpr setTerm(XPRBvar var1,
                                XPRBvar var2,
                                double val)
        Set a quadratic term in an expression. This method sets the coefficient of the product of the given variables to the value val.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr q1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1");
             q1 = new XPRBexpr(-7.2, x1, x2);
             q1.setTerm(x1, x2, 5.4);        // Set coefficient of x1*x2 to 5.4
         
        Parameters:
        var1 - variable of type XPRBvar
        var2 - variable of type XPRBvar
        val - value of the coefficient of the product of the variables
        Returns:
        A quadratic expression
      • addTerm

        public XPRBexpr addTerm(XPRBvar var,
                                double val)
        Add a linear term to an expression. This method adds a new term to an expression, comprising the variable var with coefficient val. If the expression already has a term with variable var, val is added to its coefficient.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.addTerm(x1, 5.4);        // New coefficient of x1: 8.1
         
        Parameters:
        var - variable of type XPRBvar
        val - value of the coefficient of the variable var
        Returns:
        An expression
      • addTerm

        public XPRBexpr addTerm(XPRBvar var1,
                                XPRBvar var2,
                                double val)
        Add a quadratic term to an expression. This method adds a new term to an expression, comprising the product of the variables var1 and var2 with coefficient val. If the expression already has a term with variables var1 and var2, then val is added to its coefficient.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr q1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1");
             q1 = new XPRBexpr(-7.2, x1, x2);
             q1.addTerm(x1, x2, 5.4);        // New coefficient of x1*x2: -1.8
         
        Parameters:
        var1 - variable of type XPRBvar
        var2 - variable of type XPRBvar
        val - value of the coefficient of the product of the variables
        Returns:
        A quadratic expression
      • delTerm

        public XPRBexpr delTerm(XPRBvar var)
        Delete a term from an expression. This method removes the term involving the given variable var from the expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.delTerm(x1);
         
        Parameters:
        var - variable of type XPRBvar
        Returns:
        An expression
      • delTerm

        public XPRBexpr delTerm(XPRBvar var1,
                                XPRBvar var2)
        Delete a quadratic term from an expression. This method removes the term involving the product of the two given variables from the expression.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr q1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1");
             q1 = new XPRBexpr(-7.2, x1, x2);
             q1.delTerm(x1, x2);
         
        Parameters:
        var1 - variable of type XPRBvar
        var2 - variable of type XPRBvar
        Returns:
        A quadratic expression
      • mul

        public XPRBexpr mul(double d)
        Multiply an expression with a constant factor.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.mul(-2);
         
        Parameters:
        d - constant value
        Returns:
        An expression
      • mul

        public static XPRBexpr mul(XPRBexpr l,
                                   double d)
        Create the product of an expression with a constant factor.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1, l2;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l2 = XPRBexpr.mul(l1, -2);
         
        Parameters:
        l - expression of type XPRBexpr
        d - constant value
        Returns:
        A new expression
      • mul

        public XPRBexpr mul(XPRBvar v)
                     throws java.lang.ArithmeticException
        Multiply an expression with a variable.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1;
             XPRBexpr q;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             q = l1.mul(x2);
         
        Parameters:
        v - variable of type XPRBvar
        Returns:
        A new expression
        Throws:
        java.lang.ArithmeticException - If the result of the multiplication has a power higher than quadratic.
      • sqr

        public XPRBexpr sqr()
                     throws java.lang.ArithmeticException
        Raise an expression to the power of 2
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             XPRBexpr q;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.sqr();
         
        Returns:
        An expression
        Throws:
        java.lang.ArithmeticException
      • sqr

        public static XPRBexpr sqr(XPRBexpr l)
                            throws java.lang.ArithmeticException
        Create the square of an expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             XPRBexpr q;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             q = XPRBexpr.sqr(l1);
         
        Returns:
        A new expression
        Throws:
        java.lang.ArithmeticException
      • mul

        public XPRBexpr mul(XPRBexpr q)
                     throws java.lang.ArithmeticException
        Multiply an expression with an expression.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr q1, q2;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1");
             q1 = new XPRBexpr(-7.2, x1, x2);
             q2 = new XPRBexpr(x1.mul(3.7));
             q1.mul(q2);
         
        Parameters:
        q - expression of type XPRBexpr
        Returns:
        An expression
        Throws:
        java.lang.ArithmeticException - If the result of the multiplication has a power higher than quadratic.
      • mul

        public static XPRBexpr mul(XPRBexpr q1,
                                   XPRBexpr q2)
                            throws java.lang.ArithmeticException
        Create the product of two expressions.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr q1, q2, q3;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1");
             q1 = new XPRBexpr(-7.2, x1, x2);
             q2 = new XPRBexpr(x1.mul(3.7));
             q3 = XPRBexpr.mul(q1, q2);
         
        Parameters:
        q1 - expression of type XPRBexpr
        q2 - expression of type XPRBexpr
        Returns:
        An expression
        Throws:
        java.lang.ArithmeticException - If the result of the multiplication has a power higher than quadratic.
      • assign

        public XPRBexpr assign(XPRBexpr l)
        Assign an expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1, l2;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr();
             l2.assign(l1);
         
        Parameters:
        l - expression of type XPRBexpr
        Returns:
        An expression
      • getStatus

        public int getStatus()
        Get the status of an expression
        Returns:
        0 if constant, 1 if linear, 2 or 3 if quadratic
      • lEql

        public XPRBrelation lEql(XPRBexpr l)
        Create a relation of type "less or equal". Applied to an expression l1, this method creates a new relation l1<=l.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1, l2;
             XPRBrelation lr;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr(8, x2);
             lr = l1.lEql(l2);
         
        Parameters:
        l - expression of type XPRBexpr
        Returns:
        A new relation
      • gEql

        public XPRBrelation gEql(XPRBexpr l)
        Create a relation of type "greater or equal". Applied to an expression l1, this method creates a new relation l1>=l.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1, l2;
             XPRBrelation lr;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr(8, x2);
             lr = l1.gEql(l2);
         
        Parameters:
        l - expression of type XPRBexpr
        Returns:
        A new relation
      • eql

        public XPRBrelation eql(XPRBexpr l)
        Create a relation of type "equal". Applied to an expression l1, this method creates a new relation l1=l.
             XPRBprob expl2;
             XPRBvar x1, x2;
             XPRBexpr l1, l2;
             XPRBrelation lr;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             x2 = expl2.newVar("abc1", XPRB.PL, 0, XPRB.INFINITY);
             l1 = new XPRBexpr(3.7, x1);
             l2 = new XPRBexpr(8, x2);
             lr = l1.eql(l2);
         
        Parameters:
        l - expression of type XPRBexpr
        Returns:
        A new relation
      • print

        public void print()
        Print out an expression. This method is not available in the Student Edition.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             l1.print();
         
      • toString

        public java.lang.String toString()
        Provide a string representation of an expression.
             XPRBprob expl2;
             XPRBvar x1;
             XPRBexpr l1;
             expl2 = new XPRBprob("example2");
             x1 = expl2.newVar("abc3", XPRB.UI, 1, 100);
             l1 = new XPRBexpr(3.7, x1);
             System.out.println(l1.toString());
         
        Overrides:
        toString in class  java.lang.Object

© 2001-2020 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.