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);
}
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);
}
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);
}
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);
}
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();
}
}
Aggregations