use of org.ojalgo.optimisation.ExpressionsBasedModel in project ojAlgo by optimatika.
the class SpecificBranchCase method testVpm2FirstBranch.
@Test
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);
}
}
use of org.ojalgo.optimisation.ExpressionsBasedModel in project ojAlgo by optimatika.
the class UCLAee236aCase method testRelaxedNodeP06.
/**
* P6
*/
@Test
public void testRelaxedNodeP06() {
final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
tmpModel.getVariable(0).lower(THREE);
tmpModel.getVariable(1).lower(TWO);
final Optimisation.Result tmpResult = tmpModel.minimise();
TestUtils.assertEquals(State.INFEASIBLE, tmpResult.getState());
}
use of org.ojalgo.optimisation.ExpressionsBasedModel in project ojAlgo by optimatika.
the class UCLAee236aCase method testRelaxedNodeP01.
/**
* P1
*/
@Test
public void testRelaxedNodeP01() {
final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
tmpModel.getVariable(0).upper(TWO);
final Optimisation.Result tmpResult = tmpModel.minimise();
TestUtils.assertEquals(State.OPTIMAL, tmpResult.getState());
final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 2.00 }, { 2.14 } });
TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
TestUtils.assertEquals(-10.43, tmpModel.minimise().getValue(), PRECISION);
}
use of org.ojalgo.optimisation.ExpressionsBasedModel in project ojAlgo by optimatika.
the class UCLAee236aCase method testRelaxedNodeP09.
/**
* P9
*/
@Test
public void testRelaxedNodeP09() {
final ExpressionsBasedModel tmpModel = UCLAee236aCase.makeOriginalRootModel().relax(true);
tmpModel.getVariable(0).lower(THREE);
tmpModel.getVariable(1).upper(ONE);
tmpModel.getVariable(0).lower(FOUR);
tmpModel.getVariable(1).upper(ZERO);
final Optimisation.Result tmpResult = tmpModel.minimise();
TestUtils.assertEquals(State.OPTIMAL, tmpResult.getState());
final PrimitiveDenseStore tmpExpX = PrimitiveDenseStore.FACTORY.rows(new double[][] { { 4.50 }, { 0.00 } });
TestUtils.assertEquals(tmpExpX, tmpResult, PRECISION);
TestUtils.assertEquals(-9.00, tmpModel.minimise().getValue(), PRECISION);
}
use of org.ojalgo.optimisation.ExpressionsBasedModel 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);
}
Aggregations