use of org.ojalgo.array.BigArray in project ojAlgo by optimatika.
the class BigDenseStore method divideAndCopyColumn.
public void divideAndCopyColumn(final int row, final int column, final BasicArray<BigDecimal> destination) {
final BigDecimal[] tmpData = data;
final int tmpRowDim = myRowDim;
final BigDecimal[] tmpDestination = ((BigArray) destination).data;
int tmpIndex = row + (column * tmpRowDim);
final BigDecimal tmpDenominator = tmpData[tmpIndex];
for (int i = row + 1; i < tmpRowDim; i++) {
tmpIndex++;
tmpDestination[i] = tmpData[tmpIndex] = BigFunction.DIVIDE.invoke(tmpData[tmpIndex], tmpDenominator);
}
}
use of org.ojalgo.array.BigArray in project ojAlgo by optimatika.
the class BigDenseStore method applyCholesky.
public void applyCholesky(final int iterationPoint, final BasicArray<BigDecimal> multipliers) {
final BigDecimal[] tmpData = data;
final BigDecimal[] tmpColumn = ((BigArray) multipliers).data;
if ((myColDim - iterationPoint - 1) > ApplyCholesky.THRESHOLD) {
final DivideAndConquer tmpConquerer = new DivideAndConquer() {
@Override
protected void conquer(final int aFirst, final int aLimit) {
ApplyCholesky.invoke(tmpData, myRowDim, aFirst, aLimit, tmpColumn);
}
};
tmpConquerer.invoke(iterationPoint + 1, myColDim, ApplyCholesky.THRESHOLD);
} else {
ApplyCholesky.invoke(tmpData, myRowDim, iterationPoint + 1, myColDim, tmpColumn);
}
}
use of org.ojalgo.array.BigArray in project ojAlgo by optimatika.
the class BigDenseStore method applyLU.
public void applyLU(final int iterationPoint, final BasicArray<BigDecimal> multipliers) {
final BigDecimal[] tmpData = data;
final BigDecimal[] tmpColumn = ((BigArray) multipliers).data;
if ((myColDim - iterationPoint - 1) > ApplyLU.THRESHOLD) {
final DivideAndConquer tmpConquerer = new DivideAndConquer() {
@Override
protected void conquer(final int aFirst, final int aLimit) {
ApplyLU.invoke(tmpData, myRowDim, aFirst, aLimit, tmpColumn, iterationPoint);
}
};
tmpConquerer.invoke(iterationPoint + 1, myColDim, ApplyLU.THRESHOLD);
} else {
ApplyLU.invoke(tmpData, myRowDim, iterationPoint + 1, myColDim, tmpColumn, iterationPoint);
}
}
use of org.ojalgo.array.BigArray in project ojAlgo by optimatika.
the class LinearProblems method testP20180314_70.
/**
* https://github.com/optimatika/ojAlgo/issues/70
*/
@Test
public void testP20180314_70() {
Variable x = Variable.make("x").lower(0).weight(-2);
Variable y = Variable.make("y").lower(0).weight(-2);
ExpressionsBasedModel model = new ExpressionsBasedModel();
model.addVariable(x);
model.addVariable(y);
model.addExpression().set(x, 3).set(y, 0).lower(2);
model.addExpression().set(x, 1).set(y, 2).lower(-5);
model.addExpression().set(x, 3).set(y, 1).upper(2);
final BigArray expected = BigArray.wrap(BigMath.TWO.multiply(BigMath.THIRD), BigMath.ZERO);
TestUtils.assertTrue(model.validate(expected));
Optimisation.Result solution = model.maximise();
TestUtils.assertTrue(model.validate(solution));
TestUtils.assertStateNotLessThanOptimal(solution);
}
use of org.ojalgo.array.BigArray in project ojAlgo by optimatika.
the class LinearProblems method testP20180310_61.
/**
* https://github.com/optimatika/ojAlgo/issues/61
*/
@Test
public void testP20180310_61() {
final Variable x = Variable.make("x").lower(0);
final Variable y = Variable.make("y").lower(0);
final ExpressionsBasedModel model = new ExpressionsBasedModel();
model.addVariable(x);
model.addVariable(y);
model.addExpression("first").set(x, 2).set(y, 3).upper(1);
model.addExpression("second").set(x, -2).set(y, 3).lower(1);
final BigArray expected = BigArray.wrap(BigMath.ZERO, BigMath.THIRD);
final Optimisation.Result result = model.maximise();
TestUtils.assertEquals(expected, result);
TestUtils.assertStateNotLessThanOptimal(result);
}
Aggregations