本文整理匯總了Java中org.ojalgo.function.aggregator.Aggregator類的典型用法代碼示例。如果您正苦於以下問題:Java Aggregator類的具體用法?Java Aggregator怎麽用?Java Aggregator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Aggregator類屬於org.ojalgo.function.aggregator包,在下文中一共展示了Aggregator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTest
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
@Override
void doTest(final BasicArray<Double> array) {
for (int i = 0; i < INDICES.length; i++) {
array.set(INDICES[i], 1.0);
}
final AggregatorFunction<Double> tmpVisitor = Aggregator.SUM.getFunction(PrimitiveAggregator.getSet());
array.visitAll(tmpVisitor);
TestUtils.assertTrue(1 <= tmpVisitor.intValue());
TestUtils.assertTrue(INDICES.length >= tmpVisitor.intValue());
}
示例2: doTest
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
@Override
void doTest(final BasicArray<Double> array) {
for (int i = 0; i < INDICES.length; i++) {
array.set(INDICES[i], 1.0);
}
final AggregatorFunction<Double> tmpVisitor = Aggregator.CARDINALITY.getFunction(PrimitiveAggregator.getSet());
array.visitAll(tmpVisitor);
TestUtils.assertTrue(1 <= tmpVisitor.intValue());
TestUtils.assertTrue(INDICES.length >= tmpVisitor.intValue());
}
示例3: calculateInfinityNorm
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
/**
* @return The inf-norm or maximum row sum
*/
public static double calculateInfinityNorm(final BasicMatrix matrix) {
double retVal = PrimitiveMath.ZERO;
final long tmpLimit = matrix.countRows();
for (long i = 0L; i < tmpLimit; i++) {
retVal = PrimitiveFunction.MAX.invoke(retVal, matrix.aggregateRow(i, Aggregator.NORM1).doubleValue());
}
return retVal;
}
示例4: calculateOneNorm
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
/**
* @return The 1-norm or maximum column sum
*/
public static double calculateOneNorm(final BasicMatrix matrix) {
double retVal = PrimitiveMath.ZERO;
final long tmpLimit = matrix.countColumns();
for (long j = 0L; j < tmpLimit; j++) {
retVal = PrimitiveFunction.MAX.invoke(retVal, matrix.aggregateColumn(j, Aggregator.NORM1).doubleValue());
}
return retVal;
}
示例5: tune
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
@Override
@Benchmark
public Object tune() {
for (final Aggregator tmpAggregator : Aggregator.values()) {
target.aggregateAll(tmpAggregator);
}
return target;
}
示例6: markInteger
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
protected synchronized void markInteger(final NodeKey key, final ExpressionsBasedModel model, final Optimisation.Result result) {
if (this.isProgress()) {
this.log("New integer solution {}", result);
this.log("\[email protected] node {}", key);
}
final Optimisation.Result tmpCurrentlyTheBest = myBestResultSoFar;
if (tmpCurrentlyTheBest == null) {
myBestResultSoFar = result;
} else if (myMinimisation && (result.getValue() < tmpCurrentlyTheBest.getValue())) {
myBestResultSoFar = result;
} else if (!myMinimisation && (result.getValue() > tmpCurrentlyTheBest.getValue())) {
myBestResultSoFar = result;
} else {
if (this.isDebug()) {
this.log("Previously best {}", myBestResultSoFar);
}
}
if (tmpCurrentlyTheBest != null) {
final double objDiff = ABS.invoke((result.getValue() - tmpCurrentlyTheBest.getValue()) / tmpCurrentlyTheBest.getValue());
for (int i = 0; i < myIntegerIndices.length; i++) {
final double varDiff = ABS.invoke(result.doubleValue(myIntegerIndices[i]) - tmpCurrentlyTheBest.doubleValue(myIntegerIndices[i]));
if (!options.feasibility.isZero(varDiff)) {
this.addIntegerSignificance(i, objDiff / varDiff);
}
}
} else {
final MatrixStore<Double> gradient = this.getGradient(Access1D.asPrimitive1D(result));
final double largest = gradient.aggregateAll(Aggregator.LARGEST);
if (largest > ZERO) {
for (int i = 0; i < myIntegerIndices.length; i++) {
this.addIntegerSignificance(i, ABS.invoke(gradient.doubleValue(myIntegerIndices[i])) / largest);
}
}
}
myIntegerSolutionsCount.incrementAndGet();
}
示例7: aggregateColumn
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
public N aggregateColumn(final long row, final long col, final Aggregator aggregator) {
return myStore.aggregateColumn(row, col, aggregator);
}
示例8: aggregateDiagonal
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
public N aggregateDiagonal(final long row, final long col, final Aggregator aggregator) {
return myStore.aggregateDiagonal(row, col, aggregator);
}
示例9: aggregateRange
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
public N aggregateRange(final long first, final long limit, final Aggregator aggregator) {
return myStore.aggregateRange(first, limit, aggregator);
}
示例10: aggregateRow
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
public N aggregateRow(final long row, final long col, final Aggregator aggregator) {
return myStore.aggregateRow(row, col, aggregator);
}
示例11: getVectorNorm
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
/**
* Treats [this] as if it is one dimensional (a vector) and calculates the vector norm. The interface only
* requires that implementations can handle arguments 0, 1, 2 and {@linkplain Integer#MAX_VALUE}.
*
* @deprecated v40 Use {@link #aggregateAll(org.ojalgo.function.aggregator.Aggregator)}
*/
@Deprecated
public Scalar<N> getVectorNorm(final int degree) {
switch (degree) {
case 0:
return myStore.physical().scalar().convert(myStore.aggregateAll(Aggregator.CARDINALITY));
case 1:
return myStore.physical().scalar().convert(myStore.aggregateAll(Aggregator.NORM1));
case 2:
return myStore.physical().scalar().convert(myStore.aggregateAll(Aggregator.NORM2));
default:
return myStore.physical().scalar().convert(myStore.aggregateAll(Aggregator.LARGEST));
}
}
示例12: solve
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public final MatrixStore<Double> solve(final Access2D<?> body, final Access2D<?> rhs, final PhysicalStore<Double> current) throws RecoverableCondition {
MatrixStore<Double> tmpBody = null;
if ((body instanceof MatrixStore<?>) && (body.get(0L) instanceof Double)) {
tmpBody = (MatrixStore<Double>) body;
} else {
tmpBody = MatrixStore.PRIMITIVE.makeWrapper(body).get();
}
final MatrixStore<Double> tmpBodyDiagonal = PrimitiveDenseStore.FACTORY.columns(tmpBody.sliceDiagonal(0L, 0L));
MatrixStore<Double> tmpRHS = null;
if ((rhs instanceof MatrixStore<?>) && (rhs.get(0L) instanceof Double)) {
tmpRHS = (MatrixStore<Double>) rhs;
} else {
tmpRHS = MatrixStore.PRIMITIVE.makeWrapper(rhs).get();
}
final PhysicalStore<Double> tmpIncrement = this.preallocate(body, rhs);
double tmpNormErr = POSITIVE_INFINITY;
final double tmpNormRHS = tmpRHS.aggregateAll(Aggregator.NORM2);
int tmpIterations = 0;
final int tmpLimit = this.getIterationsLimit();
final NumberContext tmpCntxt = this.getAccuracyContext();
final double tmpRelaxation = this.getRelaxationFactor();
do {
current.premultiply(tmpBody).operateOnMatching(tmpRHS, SUBTRACT).supplyTo(tmpIncrement);
tmpNormErr = tmpIncrement.aggregateAll(Aggregator.NORM2);
tmpIncrement.modifyMatching(DIVIDE, tmpBodyDiagonal);
if (this.getAccuracyContext().isDifferent(ONE, tmpRelaxation)) {
tmpIncrement.multiply(tmpRelaxation);
}
current.modifyMatching(ADD, tmpIncrement);
tmpIterations++;
if (this.isDebugPrinterSet()) {
this.debug(tmpIterations, current);
}
} while ((tmpIterations < tmpLimit) && !tmpCntxt.isSmall(tmpNormRHS, tmpNormErr));
return current;
}
示例13: norm
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
default double norm() {
return this.aggregateAll(Aggregator.NORM2).doubleValue();
}
示例14: aggregateAll
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
default N aggregateAll(final Aggregator aggregator) {
return this.aggregateRange(0L, this.count(), aggregator);
}
示例15: aggregateColumn
import org.ojalgo.function.aggregator.Aggregator; //導入依賴的package包/類
default N aggregateColumn(final long col, final Aggregator aggregator) {
return this.aggregateColumn(0L, col, aggregator);
}