Search in sources :

Example 26 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class UCLAee236aCase method testRelaxedNodeP07.

/**
 * P7
 */
@Test
public void testRelaxedNodeP07() {
    final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
    tmpModel.getVariable(0).lower(THREE);
    tmpModel.getVariable(1).upper(ONE);
    tmpModel.getVariable(0).upper(THREE);
    final Optimisation.Result tmpResult = tmpModel.minimise();
    TestUtils.assertEquals(State.OPTIMAL, tmpResult.getState());
    final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 3.00 }, { 1.00 } });
    TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
    TestUtils.assertEquals(-9.00, tmpModel.minimise().getValue(), PRECISION);
}
Also used : Optimisation(org.ojalgo.optimisation.Optimisation) ExpressionsBasedModel(org.ojalgo.optimisation.ExpressionsBasedModel) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Test(org.junit.jupiter.api.Test)

Example 27 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class UCLAee236aCase method testRelaxedNodeP04.

/**
 * P4
 */
@Test
public void testRelaxedNodeP04() {
    final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
    tmpModel.getVariable(0).upper(TWO);
    tmpModel.getVariable(1).lower(THREE);
    // tmpModel.options.debug_stream = BasicLogger.DEBUG;
    // tmpModel.options.debug_solver = LinearSolver.class;
    // tmpModel.options.validate = true;
    final Optimisation.Result tmpResult = tmpModel.minimise();
    TestUtils.assertStateNotLessThanOptimal(tmpResult);
    final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 0.00 }, { 3.00 } });
    TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
    TestUtils.assertEquals(-9.00, tmpModel.minimise().getValue(), PRECISION);
}
Also used : Optimisation(org.ojalgo.optimisation.Optimisation) ExpressionsBasedModel(org.ojalgo.optimisation.ExpressionsBasedModel) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Test(org.junit.jupiter.api.Test)

Example 28 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class UCLAee236aCase method testFullMIP.

/**
 * http://www.ee.ucla.edu/ee236a/lectures/intlp.pdf
 */
@Test
public void testFullMIP() {
    final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel();
    final Optimisation.Result tmpResult = tmpModel.minimise();
    TestUtils.assertEquals(State.OPTIMAL, tmpResult.getState());
    final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 2.0 }, { 2.0 } });
    TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
}
Also used : Optimisation(org.ojalgo.optimisation.Optimisation) ExpressionsBasedModel(org.ojalgo.optimisation.ExpressionsBasedModel) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Test(org.junit.jupiter.api.Test)

Example 29 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class UCLAee236aCase method testRelaxedNodeP02.

/**
 * P2
 */
@Test
public void testRelaxedNodeP02() {
    final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
    tmpModel.getVariable(0).lower(THREE);
    final Optimisation.Result tmpResult = tmpModel.minimise();
    TestUtils.assertEquals(State.OPTIMAL, tmpResult.getState());
    final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 3.00 }, { 1.33 } });
    TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
    TestUtils.assertEquals(-10.00, tmpModel.minimise().getValue(), PRECISION);
}
Also used : Optimisation(org.ojalgo.optimisation.Optimisation) ExpressionsBasedModel(org.ojalgo.optimisation.ExpressionsBasedModel) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Test(org.junit.jupiter.api.Test)

Example 30 with PrimitiveDenseStore

use of org.ojalgo.matrix.store.PrimitiveDenseStore in project ojAlgo by optimatika.

the class DecompositionProblems method testP20160419.

/**
 * A user reported problems related to calculating the pseudoinverse for large (2000x2000) matrices.
 */
@Test
@Tag("slow")
public void testP20160419() {
    final PrimitiveDenseStore tmpOrg = PrimitiveDenseStore.FACTORY.makeFilled(2000, 2000, new Normal());
    final SingularValue<Double> tmpRaw = new RawSingularValue();
    try {
        final MatrixStore<Double> tmpInv = tmpRaw.invert(tmpOrg);
        TestUtils.assertEquals(tmpOrg, tmpOrg.multiply(tmpInv).multiply(tmpOrg), NumberContext.getGeneral(6, 6));
    } catch (final RecoverableCondition exception) {
        exception.printStackTrace();
    }
}
Also used : RecoverableCondition(org.ojalgo.RecoverableCondition) Normal(org.ojalgo.random.Normal) PrimitiveDenseStore(org.ojalgo.matrix.store.PrimitiveDenseStore) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Aggregations

PrimitiveDenseStore (org.ojalgo.matrix.store.PrimitiveDenseStore)72 Test (org.junit.jupiter.api.Test)37 Optimisation (org.ojalgo.optimisation.Optimisation)16 NumberContext (org.ojalgo.type.context.NumberContext)15 ExpressionsBasedModel (org.ojalgo.optimisation.ExpressionsBasedModel)12 ComparableToDouble (org.ojalgo.type.keyvalue.ComparableToDouble)7 Result (org.ojalgo.optimisation.Optimisation.Result)6 ComplexNumber (org.ojalgo.scalar.ComplexNumber)4 SimultaneousPrimitive (org.ojalgo.matrix.decomposition.HermitianEvD.SimultaneousPrimitive)3 PhysicalStore (org.ojalgo.matrix.store.PhysicalStore)3 Builder (org.ojalgo.optimisation.convex.ConvexSolver.Builder)3 IntRowColumn (org.ojalgo.access.Structure2D.IntRowColumn)2 ComplexDenseStore (org.ojalgo.matrix.store.ComplexDenseStore)2 LinearSolver (org.ojalgo.optimisation.linear.LinearSolver)2 Normal (org.ojalgo.random.Normal)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Disabled (org.junit.jupiter.api.Disabled)1 Tag (org.junit.jupiter.api.Tag)1 ProgrammingError (org.ojalgo.ProgrammingError)1