/** * Build a constraint involving two linear equations. * <p> * A linear constraint with two linear equation has one of the forms: * <ul> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> = * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> <= * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> >= * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * </ul> * </p> * @param lhsCoefficients The coefficients of the linear expression on the left hand side of the constraint * @param lhsConstant The constant term of the linear expression on the left hand side of the constraint * @param relationship The type of (in)equality used in the constraint * @param rhsCoefficients The coefficients of the linear expression on the right hand side of the constraint * @param rhsConstant The constant term of the linear expression on the right hand side of the constraint */ public LinearConstraint(final RealVector lhsCoefficients, final double lhsConstant, final Relationship relationship, final RealVector rhsCoefficients, final double rhsConstant) { this.coefficients = lhsCoefficients.subtract(rhsCoefficients); this.relationship = relationship; this.value = rhsConstant - lhsConstant; }
/** * Build a constraint involving two linear equations. * <p> * A linear constraint with two linear equation has one of the forms: * <ul> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> = * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> <= * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> >= * r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li> * </ul> * </p> * @param lhsCoefficients The coefficients of the linear expression on the left hand side of the constraint * @param lhsConstant The constant term of the linear expression on the left hand side of the constraint * @param relationship The type of (in)equality used in the constraint * @param rhsCoefficients The coefficients of the linear expression on the right hand side of the constraint * @param rhsConstant The constant term of the linear expression on the right hand side of the constraint */ public LinearConstraint(final RealVector lhsCoefficients, final double lhsConstant, final Relationship relationship, final RealVector rhsCoefficients, final double rhsConstant) { this.coefficients = lhsCoefficients.subtract(rhsCoefficients); this.relationship = relationship; this.value = rhsConstant - lhsConstant; }
/** * Calculates the residuals of multiple linear regression in matrix * notation. * * <pre> * u = y - X * b * </pre> * * @return The residuals [n,1] matrix */ protected RealVector calculateResiduals() { RealVector b = calculateBeta(); return Y.subtract(X.operate(b)); }
/** * Calculates the residuals of multiple linear regression in matrix * notation. * * <pre> * u = y - X * b * </pre> * * @return The residuals [n,1] matrix */ protected RealVector calculateResiduals() { RealVector b = calculateBeta(); return Y.subtract(X.operate(b)); }
/** * {@inheritDoc} */ public double[] estimateResiduals() { RealVector b = calculateBeta(); RealVector e = Y.subtract(X.operate(b)); return e.getData(); }
/** * {@inheritDoc} */ public double[] estimateResiduals() { RealVector b = calculateBeta(); RealVector e = Y.subtract(X.operate(b)); return e.getData(); }
/** * Subtracts a multiple of one row from another. * <p> * After application of this operation, the following will hold: * minuendRow = minuendRow - multiple * subtrahendRow * </p> * @param minuendRow row index * @param subtrahendRow row index * @param multiple multiplication factor */ protected void subtractRow(final int minuendRow, final int subtrahendRow, final double multiple) { tableau.setRowVector(minuendRow, tableau.getRowVector(minuendRow) .subtract(tableau.getRowVector(subtrahendRow).mapMultiply(multiple))); }
/** * Subtracts a multiple of one row from another. * <p> * After application of this operation, the following will hold: * minuendRow = minuendRow - multiple * subtrahendRow * </p> * @param minuendRow row index * @param subtrahendRow row index * @param multiple multiplication factor */ protected void subtractRow(final int minuendRow, final int subtrahendRow, final double multiple) { tableau.setRowVector(minuendRow, tableau.getRowVector(minuendRow) .subtract(tableau.getRowVector(subtrahendRow).mapMultiply(multiple))); }
final RealVector diff = sd.getKey().subtract(p); final double diffNorm = diff.getNorm();
final RealVector diff = sd.getKey().subtract(p); final double diffNorm = diff.getNorm();
matrix.setEntry(0, getArtificialVariableOffset() + artificialVar, 1); matrix.setEntry(row, getArtificialVariableOffset() + artificialVar++, 1); matrix.setRowVector(0, matrix.getRowVector(0).subtract(matrix.getRowVector(row)));
matrix.setEntry(0, getArtificialVariableOffset() + artificialVar, 1); matrix.setEntry(row, getArtificialVariableOffset() + artificialVar++, 1); matrix.setRowVector(0, matrix.getRowVector(0).subtract(matrix.getRowVector(row)));