/** * Returns the column with the most negative coefficient in the objective function row. * * @param tableau simple tableau for the problem * @return column with the most negative coefficient */ private Integer getPivotColumn(SimplexTableau tableau) { double minValue = 0; Integer minPos = null; for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getWidth() - 1; i++) { if (MathUtils.compareTo(tableau.getEntry(0, i), minValue, epsilon) < 0) { minValue = tableau.getEntry(0, i); minPos = i; } } return minPos; }
/** * Returns whether the problem is at an optimal state. * * @param tableau simple tableau for the problem * @return whether the model has been solved */ public boolean isOptimal(final SimplexTableau tableau) { if (tableau.getNumArtificialVariables() > 0) { return false; } for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getWidth() - 1; i++) { if (MathUtils.compareTo(tableau.getEntry(0, i), 0, epsilon) < 0) { return false; } } return true; }
/** * Returns the row with the minimum ratio as given by the minimum ratio test (MRT). * * @param tableau simple tableau for the problem * @param col the column to test the ratio of. See {@link #getPivotColumn(SimplexTableau)} * @return row with the minimum ratio */ private Integer getPivotRow(final int col, final SimplexTableau tableau) { double minRatio = Double.MAX_VALUE; Integer minRatioPos = null; for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) { final double rhs = tableau.getEntry(i, tableau.getWidth() - 1); final double entry = tableau.getEntry(i, col); if (MathUtils.compareTo(entry, 0, epsilon) > 0) { final double ratio = rhs / entry; if (ratio < minRatio) { minRatio = ratio; minRatioPos = i; } } } return minRatioPos; }
public void test11() throws Throwable { java.lang.Double var0 = new java.lang.Double((-1.0d)); java.lang.Double var1 = new java.lang.Double(0.0d); java.lang.Double var2 = new java.lang.Double((-1.0d)); double[] var3 = new double[] {var0, var1, var2}; org.apache.commons.math.linear.ArrayRealVector var4 = new org.apache.commons.math.linear.ArrayRealVector(var3); java.lang.Double var5 = new java.lang.Double((-1.0d)); java.lang.Double var6 = new java.lang.Double(0.0d); java.lang.Double var7 = new java.lang.Double((-1.0d)); double[] var8 = new double[] {var5, var6, var7}; org.apache.commons.math.linear.ArrayRealVector var9 = new org.apache.commons.math.linear.ArrayRealVector(var8); org.apache.commons.math.linear.RealVector var10 = var4.ebeDivide((org.apache.commons.math.linear.RealVector) var9); java.lang.Double var11 = new java.lang.Double((-1.0d)); java.lang.Double var12 = new java.lang.Double(10.0d); java.lang.Double var13 = new java.lang.Double(100.0d); int var14 = org.apache.commons.math.util.MathUtils.compareTo( (double) var11, (double) var12, (double) var13); org.apache.commons.math.linear.RealVector var15 = var9.mapPowToSelf((double) var13); java.lang.Double[] var16 = new java.lang.Double[] {var13}; org.apache.commons.math.linear.ArrayRealVector var17 = new org.apache.commons.math.linear.ArrayRealVector(var16); org.apache.commons.math.linear.RealVector var18 = var17.mapCbrtToSelf(); org.apache.commons.math.linear.RealVector var19 = var17.mapFloorToSelf(); org.apache.commons.math.linear.RealVector var20 = var17.mapCosh(); org.apache.commons.math.linear.RealVector var21 = var17.mapAcos(); java.lang.Double var22 = new java.lang.Double((-1.0d)); double[] var23 = new double[] {var22}; org.apache.commons.math.linear.OpenMapRealVector var24 = new org.apache.commons.math.linear.OpenMapRealVector(var23); java.lang.Double var25 = new java.lang.Double((-1.0d)); double[] var26 = new double[] {var25}; org.apache.commons.math.linear.OpenMapRealVector var27 = new org.apache.commons.math.linear.OpenMapRealVector(var26); org.apache.commons.math.linear.OpenMapRealVector var28 = var24.add(var27); org.apache.commons.math.linear.OpenMapRealVector var29 = new org.apache.commons.math.linear.OpenMapRealVector(var28); java.lang.Double var30 = new java.lang.Double((-1.0d)); java.lang.Double var31 = new java.lang.Double(0.0d); java.lang.Double var32 = new java.lang.Double((-1.0d)); double[] var33 = new double[] {var30, var31, var32}; org.apache.commons.math.linear.ArrayRealVector var34 = new org.apache.commons.math.linear.ArrayRealVector(var33); java.lang.Double var35 = new java.lang.Double((-1.0d)); java.lang.Double var36 = new java.lang.Double(0.0d); java.lang.Double var37 = new java.lang.Double((-1.0d)); double[] var38 = new double[] {var35, var36, var37}; org.apache.commons.math.linear.ArrayRealVector var39 = new org.apache.commons.math.linear.ArrayRealVector(var38); org.apache.commons.math.linear.RealVector var40 = var34.ebeDivide((org.apache.commons.math.linear.RealVector) var39); java.lang.Double var41 = new java.lang.Double(0.0d); java.lang.Double var42 = new java.lang.Double((-1.0d)); java.lang.Double var43 = new java.lang.Double((-1.0d)); int var44 = org.apache.commons.math.util.MathUtils.compareTo( (double) var41, (double) var42, (double) var43); org.apache.commons.math.linear.RealVector var45 = var34.mapDivide((double) var42); org.apache.commons.math.linear.RealVector var46 = var29.mapSubtractToSelf((double) var42); boolean var47 = var17.equals((java.lang.Object) var42); // Checks the contract: equals-hashcode on var15 and var45 assertTrue( "Contract failed: equals-hashcode on var15 and var45", var15.equals(var45) ? var15.hashCode() == var45.hashCode() : true); // Checks the contract: equals-hashcode on var45 and var15 assertTrue( "Contract failed: equals-hashcode on var45 and var15", var45.equals(var15) ? var45.hashCode() == var15.hashCode() : true); }
public void test4() throws Throwable { java.lang.Double var0 = new java.lang.Double((-1.0d)); double[] var1 = new double[] {var0}; org.apache.commons.math.linear.OpenMapRealVector var2 = new org.apache.commons.math.linear.OpenMapRealVector(var1); int var3 = var2.getDimension(); java.lang.Double var4 = new java.lang.Double((-1.0d)); java.lang.Double var5 = new java.lang.Double(0.0d); java.lang.Double var6 = new java.lang.Double((-1.0d)); double[] var7 = new double[] {var4, var5, var6}; org.apache.commons.math.linear.ArrayRealVector var8 = new org.apache.commons.math.linear.ArrayRealVector(var7); java.lang.Double var9 = new java.lang.Double((-1.0d)); java.lang.Double var10 = new java.lang.Double(0.0d); java.lang.Double var11 = new java.lang.Double((-1.0d)); double[] var12 = new double[] {var9, var10, var11}; org.apache.commons.math.linear.ArrayRealVector var13 = new org.apache.commons.math.linear.ArrayRealVector(var12); org.apache.commons.math.linear.RealVector var14 = var8.ebeDivide((org.apache.commons.math.linear.RealVector) var13); java.lang.Double var15 = new java.lang.Double((-1.0d)); java.lang.Double var16 = new java.lang.Double(10.0d); java.lang.Double var17 = new java.lang.Double(100.0d); int var18 = org.apache.commons.math.util.MathUtils.compareTo( (double) var15, (double) var16, (double) var17); org.apache.commons.math.linear.RealVector var19 = var13.mapPowToSelf((double) var17); org.apache.commons.math.linear.ArrayRealVector var20 = new org.apache.commons.math.linear.ArrayRealVector(var3, var17); java.lang.Double var21 = new java.lang.Double((-1.0d)); double[] var22 = new double[] {var21}; org.apache.commons.math.linear.OpenMapRealVector var23 = new org.apache.commons.math.linear.OpenMapRealVector(var22); java.lang.Double var24 = new java.lang.Double((-1.0d)); double[] var25 = new double[] {var24}; org.apache.commons.math.linear.OpenMapRealVector var26 = new org.apache.commons.math.linear.OpenMapRealVector(var25); org.apache.commons.math.linear.OpenMapRealVector var27 = var23.add(var26); org.apache.commons.math.linear.OpenMapRealVector var28 = new org.apache.commons.math.linear.OpenMapRealVector(var27); java.lang.Double var29 = new java.lang.Double((-1.0d)); java.lang.Double var30 = new java.lang.Double(0.0d); java.lang.Double var31 = new java.lang.Double((-1.0d)); double[] var32 = new double[] {var29, var30, var31}; org.apache.commons.math.linear.ArrayRealVector var33 = new org.apache.commons.math.linear.ArrayRealVector(var32); java.lang.Double var34 = new java.lang.Double((-1.0d)); java.lang.Double var35 = new java.lang.Double(0.0d); java.lang.Double var36 = new java.lang.Double((-1.0d)); double[] var37 = new double[] {var34, var35, var36}; org.apache.commons.math.linear.ArrayRealVector var38 = new org.apache.commons.math.linear.ArrayRealVector(var37); org.apache.commons.math.linear.RealVector var39 = var33.ebeDivide((org.apache.commons.math.linear.RealVector) var38); java.lang.Double var40 = new java.lang.Double(0.0d); java.lang.Double var41 = new java.lang.Double((-1.0d)); java.lang.Double var42 = new java.lang.Double((-1.0d)); int var43 = org.apache.commons.math.util.MathUtils.compareTo( (double) var40, (double) var41, (double) var42); org.apache.commons.math.linear.RealVector var44 = var33.mapDivide((double) var41); org.apache.commons.math.linear.RealVector var45 = var28.mapSubtractToSelf((double) var41); org.apache.commons.math.linear.RealVector var46 = var20.projection(var45); // Checks the contract: equals-hashcode on var19 and var44 assertTrue( "Contract failed: equals-hashcode on var19 and var44", var19.equals(var44) ? var19.hashCode() == var44.hashCode() : true); // Checks the contract: equals-hashcode on var44 and var19 assertTrue( "Contract failed: equals-hashcode on var44 and var19", var44.equals(var19) ? var44.hashCode() == var19.hashCode() : true); }
public void test13() throws Throwable { java.lang.Double var0 = new java.lang.Double((-1.0d)); double[] var1 = new double[] {var0}; org.apache.commons.math.linear.OpenMapRealVector var2 = new org.apache.commons.math.linear.OpenMapRealVector(var1); java.lang.Double var3 = new java.lang.Double((-1.0d)); double[] var4 = new double[] {var3}; org.apache.commons.math.linear.OpenMapRealVector var5 = new org.apache.commons.math.linear.OpenMapRealVector(var4); org.apache.commons.math.linear.OpenMapRealVector var6 = var2.add(var5); org.apache.commons.math.linear.OpenMapRealVector var7 = new org.apache.commons.math.linear.OpenMapRealVector(var6); java.lang.Double var8 = new java.lang.Double((-1.0d)); java.lang.Double var9 = new java.lang.Double(0.0d); java.lang.Double var10 = new java.lang.Double((-1.0d)); double[] var11 = new double[] {var8, var9, var10}; org.apache.commons.math.linear.ArrayRealVector var12 = new org.apache.commons.math.linear.ArrayRealVector(var11); java.lang.Double var13 = new java.lang.Double((-1.0d)); java.lang.Double var14 = new java.lang.Double(0.0d); java.lang.Double var15 = new java.lang.Double((-1.0d)); double[] var16 = new double[] {var13, var14, var15}; org.apache.commons.math.linear.ArrayRealVector var17 = new org.apache.commons.math.linear.ArrayRealVector(var16); org.apache.commons.math.linear.RealVector var18 = var12.ebeDivide((org.apache.commons.math.linear.RealVector) var17); java.lang.Double var19 = new java.lang.Double(0.0d); java.lang.Double var20 = new java.lang.Double((-1.0d)); java.lang.Double var21 = new java.lang.Double((-1.0d)); int var22 = org.apache.commons.math.util.MathUtils.compareTo( (double) var19, (double) var20, (double) var21); org.apache.commons.math.linear.RealVector var23 = var12.mapDivide((double) var20); org.apache.commons.math.linear.RealVector var24 = var7.mapSubtractToSelf((double) var20); double var25 = var7.getSparcity(); java.lang.Double var26 = new java.lang.Double((-1.0d)); double[] var27 = new double[] {var26}; org.apache.commons.math.linear.OpenMapRealVector var28 = new org.apache.commons.math.linear.OpenMapRealVector(var27); int var29 = var28.getDimension(); java.lang.Double var30 = new java.lang.Double((-1.0d)); java.lang.Double var31 = new java.lang.Double(0.0d); java.lang.Double var32 = new java.lang.Double((-1.0d)); double[] var33 = new double[] {var30, var31, var32}; org.apache.commons.math.linear.ArrayRealVector var34 = new org.apache.commons.math.linear.ArrayRealVector(var33); java.lang.Double var35 = new java.lang.Double((-1.0d)); java.lang.Double var36 = new java.lang.Double(0.0d); java.lang.Double var37 = new java.lang.Double((-1.0d)); double[] var38 = new double[] {var35, var36, var37}; org.apache.commons.math.linear.ArrayRealVector var39 = new org.apache.commons.math.linear.ArrayRealVector(var38); org.apache.commons.math.linear.RealVector var40 = var34.ebeDivide((org.apache.commons.math.linear.RealVector) var39); java.lang.Double var41 = new java.lang.Double((-1.0d)); java.lang.Double var42 = new java.lang.Double(10.0d); java.lang.Double var43 = new java.lang.Double(100.0d); int var44 = org.apache.commons.math.util.MathUtils.compareTo( (double) var41, (double) var42, (double) var43); org.apache.commons.math.linear.RealVector var45 = var39.mapPowToSelf((double) var43); org.apache.commons.math.linear.ArrayRealVector var46 = new org.apache.commons.math.linear.ArrayRealVector(var29, var43); java.lang.Double var47 = new java.lang.Double((-1.0d)); java.lang.Double var48 = new java.lang.Double(10.0d); java.lang.Double var49 = new java.lang.Double(1.0d); java.lang.Double var50 = new java.lang.Double(1.0d); boolean var51 = org.apache.commons.math.util.MathUtils.equals((double) var49, (double) var50); int var52 = org.apache.commons.math.util.MathUtils.compareTo( (double) var47, (double) var48, (double) var49); java.lang.Double var53 = new java.lang.Double((-1.0d)); java.lang.Double var54 = new java.lang.Double(0.0d); java.lang.Double var55 = new java.lang.Double((-1.0d)); double[] var56 = new double[] {var53, var54, var55}; org.apache.commons.math.linear.ArrayRealVector var57 = new org.apache.commons.math.linear.ArrayRealVector(var56); java.lang.Double var58 = new java.lang.Double((-1.0d)); java.lang.Double var59 = new java.lang.Double(0.0d); java.lang.Double var60 = new java.lang.Double((-1.0d)); double[] var61 = new double[] {var58, var59, var60}; org.apache.commons.math.linear.ArrayRealVector var62 = new org.apache.commons.math.linear.ArrayRealVector(var61); org.apache.commons.math.linear.RealVector var63 = var57.ebeDivide((org.apache.commons.math.linear.RealVector) var62); org.apache.commons.math.linear.RealVector var64 = var57.mapLog10ToSelf(); java.lang.Double var65 = new java.lang.Double(1.0d); org.apache.commons.math.linear.RealVector var66 = var57.mapMultiplyToSelf((double) var65); double var67 = org.apache.commons.math.util.MathUtils.indicator((double) var65); java.lang.Double var68 = new java.lang.Double((-1.0d)); java.lang.Double var69 = new java.lang.Double(10.0d); java.lang.Double var70 = new java.lang.Double(100.0d); int var71 = org.apache.commons.math.util.MathUtils.compareTo( (double) var68, (double) var69, (double) var70); double var72 = org.apache.commons.math.util.MathUtils.normalizeAngle((double) var65, (double) var69); java.lang.Integer var73 = new java.lang.Integer(10); java.lang.Integer var74 = new java.lang.Integer(10); double var75 = org.apache.commons.math.util.MathUtils.binomialCoefficientLog((int) var73, (int) var74); java.lang.Integer var76 = new java.lang.Integer(0); java.lang.Long var77 = new java.lang.Long(100L); int var78 = org.apache.commons.math.util.MathUtils.pow((int) var76, (long) var77); double var79 = org.apache.commons.math.util.MathUtils.binomialCoefficientLog((int) var74, (int) var76); boolean var80 = org.apache.commons.math.util.MathUtils.equalsIncludingNaN( (double) var49, (double) var69, (int) var76); org.apache.commons.math.linear.RealVector var81 = var46.mapMultiplyToSelf((double) var49); org.apache.commons.math.linear.RealVector var82 = var7.mapPow((double) var49); // Checks the contract: equals-hashcode on var23 and var45 assertTrue( "Contract failed: equals-hashcode on var23 and var45", var23.equals(var45) ? var23.hashCode() == var45.hashCode() : true); // Checks the contract: equals-hashcode on var45 and var23 assertTrue( "Contract failed: equals-hashcode on var45 and var23", var45.equals(var23) ? var45.hashCode() == var23.hashCode() : true); }