当前位置: 首页>>代码示例>>Java>>正文


Java TestUtils.fail方法代码示例

本文整理汇总了Java中org.ojalgo.TestUtils.fail方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.fail方法的具体用法?Java TestUtils.fail怎么用?Java TestUtils.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ojalgo.TestUtils的用法示例。


在下文中一共展示了TestUtils.fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMPSadlittle

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
/**
 * Defines a problem of 57 rows and 97 columns. Seems to be the same model as adlittle at netlib. Netlib
 * also provides the solution.
 * <a href="http://www-new.mcs.anl.gov/otc/Guide/TestProblems/LPtest/netlib/adlittle.html" >
 * [email protected]</a> Found this info somewhere on the net: "With 56 constraints and 97 variables
 * adlittle is one of its smaller members. While being in fact feasible, adlittle suffers from
 * ill--posedness. Perturbing the right hand side of the equality constraints by subtracting a tiny
 * multiple of the 96th column of the equation matrix renders the linear program infeasible. Running this
 * problem through CPLEX and lp_solve does again return a solution without any warnings." FAIL: Hittar
 * bara en lösning 0.0, oavsett om jag minimerrar eller maximerar. 2010-04-19 lp_solve => 225494.96316238
 */
public void testMPSadlittle() {

    final File tmpFile = new File(PATH + "adlittle.mps");
    final MathProgSysModel tmpMPS = MathProgSysModel.make(tmpFile);
    final ExpressionsBasedModel tmpModel = tmpMPS.getExpressionsBasedModel();

    //tmpModel.options.debug(LinearSolver.class);

    TestUtils.assertTrue(tmpModel.validate());

    final BigDecimal tmpExpVal = new BigDecimal("225494.96316238446"); // Stated to be .22549496316e+6
    final double tmpActVal = tmpModel.minimise().getValue();

    TestUtils.assertEquals(tmpExpVal.doubleValue(), tmpActVal, PRECISION);

    if (!tmpModel.validate(PRECISION)) {
        TestUtils.fail(SOLUTION_NOT_VALID);
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:31,代码来源:BurkardtDatasetsMps.java

示例2: testMPSafiro

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
/**
 * Defines a problem of 28 rows and 32 columns. Seems to be the same model as afiro at netlib. Netlib also
 * provides the solution.
 * <a href="http://www-new.mcs.anl.gov/otc/Guide/TestProblems/LPtest/netlib/afiro.html">[email protected]</a>
 * OK! 2010-04-19 lp_solve => -464.75314286
 */
public void testMPSafiro() {

    final File tmpFile = new File(PATH + "afiro.mps");
    final MathProgSysModel tmpMPS = MathProgSysModel.make(tmpFile);
    final ExpressionsBasedModel tmpModel = tmpMPS.getExpressionsBasedModel();

    TestUtils.assertTrue(tmpModel.validate());

    final BigDecimal tmpExpVal = new BigDecimal("-.46475314286e+3");
    final double tmpActVal = tmpModel.minimise().getValue();
    TestUtils.assertEquals(tmpExpVal.doubleValue(), tmpActVal, PRECISION);

    if (!tmpModel.validate(PRECISION)) {
        TestUtils.fail(SOLUTION_NOT_VALID);
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:23,代码来源:BurkardtDatasetsMps.java

示例3: compare

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
static void compare(final String id, final double arg0, final double arg1) {

        if (arg0 == arg1) {
            if (NumberContext.compare(arg0, arg1) == 0) {
                ;
            } else {
                TestUtils.fail();
            }
        } else {
            if (NumberContext.compare(arg0, arg1) == 0) {
                TestUtils.fail();
            } else {
                TestUtils.fail();
            }
        }

    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:18,代码来源:PrimitiveMathTest.java

示例4: doCompare

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
void doCompare(final SolverTask<Double> fixed, final int dimension) {

        try {

            final MatrixStore<Double> tmpBody = this.makeSPD(dimension);
            final MatrixStore<Double> tmpRHS = this.makeRHS(dimension);

            final MatrixStore<Double> tmpExpSol = fixed.solve(tmpBody, tmpRHS);

            final List<MatrixDecomposition<Double>> tmpList = MatrixDecompositionTests.getAllPrimitive();
            for (final MatrixDecomposition<Double> tmpDecomp : tmpList) {
                if (tmpDecomp instanceof SolverTask) {
                    @SuppressWarnings("unchecked")
                    final SolverTask<Double> tmpTask = (SolverTask<Double>) tmpDecomp;
                    final MatrixStore<Double> tmpActSol = tmpTask.solve(tmpBody, tmpRHS);
                    TestUtils.assertEquals(tmpDecomp.getClass().getName(), tmpExpSol, tmpActSol);
                }
            }

        } catch (final RecoverableCondition exception) {
            TestUtils.fail(exception.getMessage());
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:24,代码来源:SolverTest.java

示例5: doCompare

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
void doCompare(final InverterTask<Double> fixed, final int dimension) {

        try {

            final MatrixStore<Double> tmpMatrix = this.makeSPD(dimension);

            final MatrixStore<Double> tmpExpInv = fixed.invert(tmpMatrix);

            final List<MatrixDecomposition<Double>> tmpList = MatrixDecompositionTests.getAllPrimitive();
            for (final MatrixDecomposition<Double> tmpDecomp : tmpList) {
                if (tmpDecomp instanceof InverterTask) {
                    @SuppressWarnings("unchecked")
                    final InverterTask<Double> tmpTask = (InverterTask<Double>) tmpDecomp;
                    final MatrixStore<Double> tmpActInv = tmpTask.invert(tmpMatrix);
                    TestUtils.assertEquals(tmpDecomp.getClass().getName(), tmpExpInv, tmpActInv);
                }
            }

        } catch (final RecoverableCondition exception) {
            TestUtils.fail(exception.getMessage());
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:23,代码来源:InverterTest.java

示例6: doTestCorrect

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
private void doTestCorrect(final PhysicalStore<Double> aMatrix) {

        final HessenbergDecomposition<Double> tmpDecomposition = (HessenbergDecomposition<Double>) Hessenberg.PRIMITIVE.make();
        tmpDecomposition.decompose(aMatrix);

        if (!Hessenberg.equals(aMatrix, tmpDecomposition, new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("Not equals!");
        }

        final MatrixStore<Double> tmpReconstructed = Hessenberg.reconstruct(tmpDecomposition);
        if (!Access2D.equals(aMatrix, tmpReconstructed, new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("Failed to reconstruct!");
        }

        if (!Access2D.equals(tmpDecomposition.getQ(),
                tmpDecomposition.doQ(this.makeEye((int) aMatrix.countRows(), (int) Math.min(aMatrix.countRows(), aMatrix.countColumns()))),
                new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("get and do Q are different!");
        }

        TestUtils.assertEquals(aMatrix, tmpDecomposition, new NumberContext(7, 6));
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:26,代码来源:HessenbergTest.java

示例7: doTestCorrect

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
private void doTestCorrect(final PhysicalStore<Double> aMatrix) {

        final BidiagonalDecomposition<Double> tmpDecomposition = (BidiagonalDecomposition<Double>) Bidiagonal.PRIMITIVE.make();
        tmpDecomposition.decompose(aMatrix);

        if (!Bidiagonal.equals(aMatrix, tmpDecomposition, new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("Not equals, easy!");
        }

        if (!Bidiagonal.equals(aMatrix, tmpDecomposition, new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("Not equals, hard!");
        }

        final MatrixStore<Double> tmpReconstructed = Bidiagonal.reconstruct(tmpDecomposition);
        if (!Access2D.equals(aMatrix, tmpReconstructed, new NumberContext(7, 6))) {
            this.doPrint(tmpDecomposition, aMatrix);
            TestUtils.fail("Failed to reconstruct!");
        }

        TestUtils.assertEquals(aMatrix, tmpDecomposition, new NumberContext(7, 6));
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:24,代码来源:BidiagonalTest.java

示例8: testSolveIdentity

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testSolveIdentity() {

        final Access2D<?> tmpIdentity = MatrixStore.PRIMITIVE.makeIdentity(9).get();
        final Access2D<?> tmpRandom = PrimitiveDenseStore.FACTORY.makeFilled(9, 1, new Uniform());

        final List<MatrixDecomposition<Double>> tmpAllDecomps = MatrixDecompositionTests.getAllPrimitive();
        for (final MatrixDecomposition<Double> tmpDecomp : tmpAllDecomps) {
            if (tmpDecomp instanceof SolverTask) {
                final SolverTask<Double> tmpSolverTask = (SolverTask<Double>) tmpDecomp;
                try {
                    TestUtils.assertEquals(tmpDecomp.getClass().toString(), tmpRandom, tmpSolverTask.solve(tmpIdentity, tmpRandom));
                } catch (final RecoverableCondition xcptn) {
                    TestUtils.fail(tmpDecomp.getClass().toString() + " " + xcptn.getMessage());
                }
            }
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:18,代码来源:DesignCase.java

示例9: testP20090115

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
/**
 * The user got, constraint breaking, negative portfolio weights. The model is "wrong" - should not have
 * negative excess returns - but he still should not get a constraint breaking solution.
 */
public void testP20090115() {

    final int assetNum = 7;

    final double[][] assets_return = {
            { -1.5905837442343828E-4, -0.03062360801781757, -0.029857534032853142, -0.011811692726036832, -0.017972310602803136, 0.017338003502626997,
                    0.0 },
            { -0.02757158006362653, -0.02562704471101405, -0.011751538891997735, -0.024915062287655786, -0.01684088269454123, 0.013585351447135364, 0.0 },
            { -0.00699300699300693, -0.033802816901408676, -0.04675196850393671, -0.021166752710376546, -0.007911392405063583, 0.03827751196172254, 0.0 },
            { -0.007626310772164015, 0.0038424591738713027, 0.02488038277511978, 0.025210084033613675, -0.02003642987249557, -0.09758364312267642, 0.0 },
            { -0.03965053763440893, 0.021693491952414375, 0.01643835616438392, -0.007412398921833087, 0.01765105227427014, -0.010006671114076025, 0.0 },
            { -0.017821782178217872, 0.005040322580645311, 0.006018054162487363, 9.008107296569024E-4, 0.002999999999999824, -0.01196410767696908, 0.0 },
            { 2.630552127527583E-4, 2.5867028174649627E-4, 2.3866431891514327E-4, 1.9564035993080523E-4, 2.351016690966669E-4, 1.9070675120065465E-4,
                    0.0 } };

    final P20090115 tm = new P20090115();
    final BasicMatrix covariances = tm.getCovariances(assets_return);
    final BasicMatrix expectedExcessReturns = tm.getExpectedExcessReturns(assets_return); // Why not negate?
    final BigDecimal riskAversion = new BigDecimal(1.0);

    final MarketEquilibrium marketEquilibrium = new MarketEquilibrium(covariances, riskAversion);
    final MarkowitzModel markowitzModel = new MarkowitzModel(marketEquilibrium, expectedExcessReturns);

    for (int i = 0; i < assetNum; i++) {
        markowitzModel.setLowerLimit(i, new BigDecimal(0.0));
        markowitzModel.setUpperLimit(i, new BigDecimal(1.0));
    }

    final List<BigDecimal> re = markowitzModel.getWeights();

    // TestUtils.assertTrue(markowitzModel.getOptimisationState().isOptimal());

    for (final BigDecimal tmpBigDecimal : re) {
        if ((tmpBigDecimal.compareTo(BigMath.ZERO) == -1) || (tmpBigDecimal.compareTo(BigMath.ONE) == 1)) {
            TestUtils.fail("!(0.0 <= " + tmpBigDecimal + " <= 1.0)");
        }
    }
}
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:43,代码来源:PortfolioProblems.java

示例10: testGoogleDaily

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testGoogleDaily() {

        final GoogleSymbol tmpGoogle = new GoogleSymbol("NASDAQ:AAPL", CalendarDateUnit.DAY);
        final List<? extends DatePrice> tmpRows = tmpGoogle.getHistoricalPrices();
        if (tmpRows.size() <= 1) {
            TestUtils.fail("No data!");
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:9,代码来源:SymbolDataTest.java

示例11: testGoogleWeekly

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testGoogleWeekly() {

        final GoogleSymbol tmpGoogle = new GoogleSymbol("NASDAQ:AAPL", CalendarDateUnit.WEEK);
        final List<? extends DatePrice> tmpRows = tmpGoogle.getHistoricalPrices();
        if (tmpRows.size() <= 1) {
            TestUtils.fail("No data!");
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:9,代码来源:SymbolDataTest.java

示例12: testYahooDaily

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testYahooDaily() {

        final YahooSymbol tmpYahoo = new YahooSymbol("AAPL", CalendarDateUnit.DAY);
        final List<? extends DatePrice> tmpRows = tmpYahoo.getHistoricalPrices();
        if (tmpRows.size() <= 1) {
            TestUtils.fail("No data!");
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:9,代码来源:SymbolDataTest.java

示例13: testYahooMonthly

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testYahooMonthly() {

        final YahooSymbol tmpYahoo = new YahooSymbol("AAPL", CalendarDateUnit.MONTH);
        final List<? extends DatePrice> tmpRows = tmpYahoo.getHistoricalPrices();
        if (tmpRows.size() <= 1) {
            TestUtils.fail("No data!");
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:9,代码来源:SymbolDataTest.java

示例14: testYahooWeekly

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testYahooWeekly() {

        final YahooSymbol tmpYahoo = new YahooSymbol("AAPL", CalendarDateUnit.WEEK);
        final List<? extends DatePrice> tmpRows = tmpYahoo.getHistoricalPrices();
        if (tmpRows.size() <= 1) {
            TestUtils.fail("No data!");
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo-finance,代码行数:9,代码来源:SymbolDataTest.java

示例15: testVpm2FirstBranch

import org.ojalgo.TestUtils; //导入方法依赖的package包/类
public void testVpm2FirstBranch() {

        final File tmpFile = new File(MipLibCase.PATH + "vpm2.mps");
        final MathProgSysModel tmpMPS = MathProgSysModel.make(tmpFile);
        final ExpressionsBasedModel tmpModel = tmpMPS.getExpressionsBasedModel();

        TestUtils.assertTrue(tmpModel.validate());

        final ExpressionsBasedModel tmpLowerBranchModel = tmpModel.relax(false);
        final ExpressionsBasedModel tmpUpperBranchModel = tmpModel.relax(false);

        tmpLowerBranchModel.getVariable(106).upper(BigMath.ZERO);
        tmpUpperBranchModel.getVariable(106).lower(BigMath.ONE);

        final Optimisation.Result tmpLowerResult = tmpLowerBranchModel.minimise();
        final Optimisation.Result tmpUpperResult = tmpUpperBranchModel.minimise();

        final State tmpLowerState = tmpLowerResult.getState();
        final State tmpUpperState = tmpUpperResult.getState();

        if (!tmpLowerState.isFeasible() && !tmpUpperState.isFeasible()) {
            TestUtils.fail("Both these branches cannot be infeasible!");
        }

        tmpLowerBranchModel.minimise();
        if (tmpLowerState.isFeasible() && !tmpLowerBranchModel.validate(MipLibCase.PRECISION)) {
            TestUtils.fail(MipLibCase.SOLUTION_NOT_VALID);
        }

        tmpUpperBranchModel.minimise();
        if (tmpUpperState.isFeasible() && !tmpUpperBranchModel.validate(MipLibCase.PRECISION)) {
            TestUtils.fail(MipLibCase.SOLUTION_NOT_VALID);
        }
    }
 
开发者ID:optimatika,项目名称:ojAlgo,代码行数:35,代码来源:SpecificBranchCase.java


注:本文中的org.ojalgo.TestUtils.fail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。