當前位置: 首頁>>代碼示例>>Java>>正文


Java ProgrammingError類代碼示例

本文整理匯總了Java中org.ojalgo.ProgrammingError的典型用法代碼示例。如果您正苦於以下問題:Java ProgrammingError類的具體用法?Java ProgrammingError怎麽用?Java ProgrammingError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ProgrammingError類屬於org.ojalgo包,在下文中一共展示了ProgrammingError類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: from

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public static CalendarDate from(final TemporalAccessor temporal) {
    ProgrammingError.throwIfNull(temporal, "temporal");
    if (temporal instanceof CalendarDate) {
        return (CalendarDate) temporal;
    } else if (temporal instanceof Instant) {
        return new CalendarDate(((Instant) temporal).toEpochMilli());
    } else {
        try {
            final long tmpSeconds = temporal.getLong(ChronoField.INSTANT_SECONDS);
            final int tmpMillisOfSecond = temporal.get(ChronoField.MILLI_OF_SECOND);
            return new CalendarDate((tmpSeconds * MILLIS_PER_SECOND) + tmpMillisOfSecond);
        } catch (final DateTimeException ex) {
            throw new DateTimeException("Unable to obtain CalendarDate from TemporalAccessor: " + temporal + " of type " + temporal.getClass().getName(),
                    ex);
        }
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:18,代碼來源:CalendarDate.java

示例2: countVariables

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
@Override
public int countVariables() {

    int retVal = -1;

    if (this.getAE() != null) {
        retVal = (int) this.getAE().countColumns();
    } else if (this.getAI() != null) {
        retVal = (int) this.getAI().countColumns();
    } else if (this.getQ() != null) {
        retVal = (int) this.getQ().countRows();
    } else if (this.getC() != null) {
        retVal = (int) this.getC().countRows();
    } else {
        throw new ProgrammingError("Cannot deduce the number of variables!");
    }

    return retVal;
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:20,代碼來源:ConvexSolver.java

示例3: objective

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public Builder objective(final MatrixStore<Double> mtrxQ, final MatrixStore<Double> mtrxC) {

            ProgrammingError.throwIfNull(mtrxQ);

            if (mtrxQ == null) {
                throw new IllegalArgumentException();
            }

            if (mtrxQ instanceof PhysicalStore) {
                myQ = (PhysicalStore<Double>) mtrxQ;
            } else {
                myQ = mtrxQ.copy();
            }

            myC = mtrxC != null ? mtrxC : MatrixStore.PRIMITIVE.makeZero((int) mtrxQ.countRows(), 1).get();

            return this;
        }
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:19,代碼來源:ConvexSolver.java

示例4: addSpecialOrderedSet

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
/**
 * Creates a special ordered set (SOS) presolver instance and links that to the supplied expression.
 * When/if the presolver concludes that the SOS "constraints" are not possible the linked expression is
 * marked as infeasible.
 */
public void addSpecialOrderedSet(final Collection<Variable> orderedSet, final int type, final Expression linkedTo) {

    if (type <= 0) {
        throw new ProgrammingError("Invalid SOS type!");
    }

    if (!linkedTo.isConstraint()) {
        throw new ProgrammingError("The linked to expression needs to be a constraint!");
    }

    final IntIndex[] sequence = new IntIndex[orderedSet.size()];
    int index = 0;
    for (final Variable variable : orderedSet) {
        if ((variable == null) || (variable.getIndex() == null)) {
            throw new ProgrammingError("Variables must be already inserted in the model!");
        } else {
            sequence[index++] = variable.getIndex();
        }
    }

    ExpressionsBasedModel.addPresolver(new SpecialOrderedSet(sequence, type, linkedTo));
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:28,代碼來源:ExpressionsBasedModel.java

示例5: getEigenvalues

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
/**
 * @param realParts An array that will receive the real parts of the eigenvalues
 * @param imaginaryParts An optional array that, if present, will receive the imaginary parts of the
 *        eigenvalues
 */
default void getEigenvalues(final double[] realParts, final Optional<double[]> imaginaryParts) {

    ProgrammingError.throwIfNull(realParts, imaginaryParts);

    final Array1D<ComplexNumber> values = this.getEigenvalues();

    final int length = realParts.length;

    if (imaginaryParts.isPresent()) {
        final double[] imagParts = imaginaryParts.get();
        for (int i = 0; i < length; i++) {
            final ComplexNumber value = values.get(i);
            realParts[i] = value.getReal();
            imagParts[i] = value.getImaginary();
        }
    } else {
        for (int i = 0; i < length; i++) {
            realParts[i] = values.doubleValue(i);
        }
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:27,代碼來源:Eigenvalue.java

示例6: divide

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
final void divide(final int first, final int limit, final int threshold, final int workers) {

        final int count = limit - first;

        if ((count > threshold) && (workers > 1)) {

            final int split = first + (count / 2);
            final int nextWorkers = workers / 2;

            final Future<?> firstPart = DaemonPoolExecutor.INSTANCE.submit(() -> this.divide(first, split, threshold, nextWorkers));
            final Future<?> secondPart = DaemonPoolExecutor.INSTANCE.submit(() -> this.divide(split, limit, threshold, nextWorkers));

            try {
                firstPart.get();
                secondPart.get();
            } catch (final InterruptedException | ExecutionException exception) {
                exception.printStackTrace();
                throw new ProgrammingError(exception);
            }

        } else {

            this.conquer(first, limit);
        }
    }
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:26,代碼來源:DivideAndConquer.java

示例7: compute

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
@Override
public Iterator<double[]> compute(final Partition partition, final TaskContext context) {
    ProgrammingError.throwIfNull(partition, context);
    if (partition instanceof Partition2D) {
        return this.compute((Partition2D) partition, context);
    } else {
        throw new IllegalArgumentException();
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo-extensions,代碼行數:10,代碼來源:PrimitiveBlockMatrixRDD.java

示例8: compute

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
@Override
public Iterator<MatrixStore<N>> compute(final Partition partition, final TaskContext context) {
    ProgrammingError.throwIfNull(partition, context);
    if (partition instanceof Partition2D) {
        return this.compute((Partition2D) partition, context);
    } else {
        throw new IllegalArgumentException();
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo-extensions,代碼行數:10,代碼來源:OtherBlockMatrixRDD.java

示例9: mix

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public double mix(final long index, final BinaryFunction<N> mixer, final double addend) {
    ProgrammingError.throwIfNull(mixer);
    if (index >= myActualCount) {
        throw new ArrayIndexOutOfBoundsException();
    } else {
        synchronized (myStorage) {
            final double oldValue = myStorage.doubleValue(index);
            final double newValue = mixer.invoke(oldValue, addend);
            myStorage.set(index, newValue);
            return newValue;
        }
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:14,代碼來源:NumberList.java

示例10: mix

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public double mix(final long[] reference, final BinaryFunction<N> mixer, final double addend) {
    ProgrammingError.throwIfNull(mixer);
    synchronized (myDelegate) {
        final double oldValue = this.doubleValue(reference);
        final double newValue = mixer.invoke(oldValue, addend);
        this.set(reference, newValue);
        return newValue;
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:10,代碼來源:ArrayAnyD.java

示例11: mix

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public double mix(final long key, final BinaryFunction<N> mixer, final double addend) {
    ProgrammingError.throwIfNull(mixer);
    synchronized (myStorage) {
        final int tmpIndex = myStorage.index(key);
        final double oldValue = tmpIndex >= 0 ? myStorage.doubleValueInternally(tmpIndex) : PrimitiveMath.NaN;
        final double newValue = tmpIndex >= 0 ? mixer.invoke(oldValue, addend) : addend;
        myStorage.put(key, tmpIndex, newValue);
        return newValue;
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:11,代碼來源:LongToNumberMap.java

示例12: mix

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public double mix(final long index, final BinaryFunction<N> mixer, final double addend) {
    ProgrammingError.throwIfNull(mixer);
    synchronized (myDelegate) {
        final double oldValue = this.doubleValue(index);
        final double newValue = mixer.invoke(oldValue, addend);
        this.set(index, newValue);
        return newValue;
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:10,代碼來源:Array1D.java

示例13: mix

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
public double mix(final long row, final long col, final BinaryFunction<N> mixer, final double addend) {
    ProgrammingError.throwIfNull(mixer);
    synchronized (myDelegate) {
        final double oldValue = this.doubleValue(row, col);
        final double newValue = mixer.invoke(oldValue, addend);
        this.set(row, col, newValue);
        return newValue;
    }
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:10,代碼來源:Array2D.java

示例14: andThen

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
default NullaryFunction<N> andThen(final UnaryFunction<N> after) {
    ProgrammingError.throwIfNull(after);
    return new NullaryFunction<N>() {

        public double doubleValue() {
            return after.invoke(NullaryFunction.this.doubleValue());
        }

        public N invoke() {
            return after.invoke(NullaryFunction.this.invoke());
        }

    };
}
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:15,代碼來源:NullaryFunction.java

示例15: buildModel

import org.ojalgo.ProgrammingError; //導入依賴的package包/類
static ExpressionsBasedModel buildModel(final BasicMatrix covariances, final BasicMatrix returns, final BigDecimal riskAversion) {

        ProgrammingError.throwIfNotSquare(covariances);
        ProgrammingError.throwIfNotEqualRowDimensions(covariances, returns);

        final int numberOfVariables = (int) returns.countRows();

        final Variable[] tmpVariables = new Variable[numberOfVariables];
        for (int i = 0; i < numberOfVariables; i++) {
            tmpVariables[i] = Variable.make("Asset_" + Integer.toString(i)).lower(ZERO).upper(ONE).weight(-returns.doubleValue(i));
        }

        final ExpressionsBasedModel retVal = new ExpressionsBasedModel(tmpVariables);

        final Expression tmp100P = retVal.addExpression("Balance");
        for (int i = 0; i < numberOfVariables; i++) {
            tmp100P.set(i, ONE);
        }
        tmp100P.level(ONE);

        final Expression tmpVar = retVal.addExpression("Variance");
        for (int i = 0; i < numberOfVariables; i++) {
            for (int j = 0; j < numberOfVariables; j++) {
                tmpVar.set(i, j, covariances.doubleValue(i, j));
            }
        }
        tmpVar.weight(BigFunction.DIVIDE.invoke(riskAversion, TWO));

        return retVal;
    }
 
開發者ID:optimatika,項目名稱:ojAlgo,代碼行數:31,代碼來源:FinancePortfolioProblem.java


注:本文中的org.ojalgo.ProgrammingError類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。