本文整理汇总了Java中org.apache.commons.math3.exception.MathIllegalStateException类的典型用法代码示例。如果您正苦于以下问题:Java MathIllegalStateException类的具体用法?Java MathIllegalStateException怎么用?Java MathIllegalStateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MathIllegalStateException类属于org.apache.commons.math3.exception包,在下文中一共展示了MathIllegalStateException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: LocalLeastSquaresProblem
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Create a {@link LeastSquaresProblem} from the given data.
*
* @param model the model function
* @param target the observed data
* @param start the initial guess
* @param checker the convergence checker
* @param maxEvaluations the allowed evaluations
* @param maxIterations the allowed iterations
* @param lazyEvaluation Whether the call to {@link Evaluation#evaluate(RealVector)}
* will defer the evaluation until access to the value is requested.
* @param paramValidator Model parameters validator.
*/
LocalLeastSquaresProblem(final MultivariateJacobianFunction model,
final RealVector target,
final RealVector start,
final ConvergenceChecker<Evaluation> checker,
final int maxEvaluations,
final int maxIterations,
final boolean lazyEvaluation,
final ParameterValidator paramValidator) {
super(maxEvaluations, maxIterations, checker);
this.target = target;
this.model = model;
this.start = start;
this.lazyEvaluation = lazyEvaluation;
this.paramValidator = paramValidator;
if (lazyEvaluation &&
!(model instanceof ValueAndJacobianFunction)) {
// Lazy evaluation requires that value and Jacobian
// can be computed separately.
throw new MathIllegalStateException(LocalizedFormats.INVALID_IMPLEMENTATION,
model.getClass().getName());
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:LeastSquaresFactory.java
示例2: getObjectiveFunctionValue
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Get the value of the objective function.
* @return the objective function evaluation as double value
* @throws MathIllegalStateException if {@link #cluster(Collection)} has not been called before
*/
public double getObjectiveFunctionValue() {
if (points == null || clusters == null) {
throw new MathIllegalStateException();
}
int i = 0;
double objFunction = 0.0;
for (final T point : points) {
int j = 0;
for (final CentroidCluster<T> cluster : clusters) {
final double dist = distance(point, cluster.getCenter());
objFunction += (dist * dist) * FastMath.pow(membershipMatrix[i][j], fuzziness);
j++;
}
i++;
}
return objFunction;
}
开发者ID:biocompibens,项目名称:SME,代码行数:24,代码来源:FuzzyKMeansClusterer.java
示例3: getPercentile
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Returns an estimate for the pth percentile of the stored values.
* <p>
* The implementation provided here follows the first estimation procedure presented
* <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>
* </p><p>
* <strong>Preconditions</strong>:<ul>
* <li><code>0 < p ≤ 100</code> (otherwise an
* <code>MathIllegalArgumentException</code> is thrown)</li>
* <li>at least one value must be stored (returns <code>Double.NaN
* </code> otherwise)</li>
* </ul></p>
*
* @param p the requested percentile (scaled from 0 - 100)
* @return An estimate for the pth percentile of the stored data
* @throws MathIllegalStateException if percentile implementation has been
* overridden and the supplied implementation does not support setQuantile
* @throws MathIllegalArgumentException if p is not a valid quantile
*/
public double getPercentile(double p) throws MathIllegalStateException, MathIllegalArgumentException {
if (percentileImpl instanceof Percentile) {
((Percentile) percentileImpl).setQuantile(p);
} else {
try {
percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME,
new Class[] {Double.TYPE}).invoke(percentileImpl,
new Object[] {Double.valueOf(p)});
} catch (NoSuchMethodException e1) { // Setter guard should prevent
throw new MathIllegalStateException(
LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD,
percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME);
} catch (IllegalAccessException e2) {
throw new MathIllegalStateException(
LocalizedFormats.PERCENTILE_IMPLEMENTATION_CANNOT_ACCESS_METHOD,
SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName());
} catch (InvocationTargetException e3) {
throw new IllegalStateException(e3.getCause());
}
}
return apply(percentileImpl);
}
开发者ID:biocompibens,项目名称:SME,代码行数:42,代码来源:DescriptiveStatistics.java
示例4: toString
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Generates a text report displaying univariate statistics from values
* that have been added. Each statistic is displayed on a separate
* line.
*
* @return String with line feeds displaying statistics
*/
@Override
public String toString() {
StringBuilder outBuffer = new StringBuilder();
String endl = "\n";
outBuffer.append("DescriptiveStatistics:").append(endl);
outBuffer.append("n: ").append(getN()).append(endl);
outBuffer.append("min: ").append(getMin()).append(endl);
outBuffer.append("max: ").append(getMax()).append(endl);
outBuffer.append("mean: ").append(getMean()).append(endl);
outBuffer.append("std dev: ").append(getStandardDeviation())
.append(endl);
try {
// No catch for MIAE because actual parameter is valid below
outBuffer.append("median: ").append(getPercentile(50)).append(endl);
} catch (MathIllegalStateException ex) {
outBuffer.append("median: unavailable").append(endl);
}
outBuffer.append("skewness: ").append(getSkewness()).append(endl);
outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl);
return outBuffer.toString();
}
开发者ID:biocompibens,项目名称:SME,代码行数:29,代码来源:DescriptiveStatistics.java
示例5: optimize
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** {@inheritDoc} */
public PointValuePair optimize(final LinearObjectiveFunction f,
final Collection<LinearConstraint> constraints,
final GoalType goalType, final boolean restrictToNonNegative)
throws MathIllegalStateException {
// store linear problem characteristics
this.function = f;
this.linearConstraints = constraints;
this.goal = goalType;
this.nonNegative = restrictToNonNegative;
iterations = 0;
// solve the problem
return doOptimize();
}
开发者ID:biocompibens,项目名称:SME,代码行数:19,代码来源:AbstractLinearOptimizer.java
示例6: getReal
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Get the real part of the {@code k}-th {@code n}-th root of unity.
*
* @param k index of the {@code n}-th root of unity
* @return real part of the {@code k}-th {@code n}-th root of unity
* @throws MathIllegalStateException if no roots of unity have been
* computed yet
* @throws MathIllegalArgumentException if {@code k} is out of range
*/
public synchronized double getReal(int k)
throws MathIllegalStateException, MathIllegalArgumentException {
if (omegaCount == 0) {
throw new MathIllegalStateException(
LocalizedFormats.ROOTS_OF_UNITY_NOT_COMPUTED_YET);
}
if ((k < 0) || (k >= omegaCount)) {
throw new OutOfRangeException(
LocalizedFormats.OUT_OF_RANGE_ROOT_OF_UNITY_INDEX,
Integer.valueOf(k),
Integer.valueOf(0),
Integer.valueOf(omegaCount - 1));
}
return omegaReal[k];
}
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:RootsOfUnity.java
示例7: getImaginary
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Get the imaginary part of the {@code k}-th {@code n}-th root of unity.
*
* @param k index of the {@code n}-th root of unity
* @return imaginary part of the {@code k}-th {@code n}-th root of unity
* @throws MathIllegalStateException if no roots of unity have been
* computed yet
* @throws OutOfRangeException if {@code k} is out of range
*/
public synchronized double getImaginary(int k)
throws MathIllegalStateException, OutOfRangeException {
if (omegaCount == 0) {
throw new MathIllegalStateException(
LocalizedFormats.ROOTS_OF_UNITY_NOT_COMPUTED_YET);
}
if ((k < 0) || (k >= omegaCount)) {
throw new OutOfRangeException(
LocalizedFormats.OUT_OF_RANGE_ROOT_OF_UNITY_INDEX,
Integer.valueOf(k),
Integer.valueOf(0),
Integer.valueOf(omegaCount - 1));
}
return isCounterClockWise ? omegaImaginaryCounterClockwise[k] :
omegaImaginaryClockwise[k];
}
开发者ID:biocompibens,项目名称:SME,代码行数:28,代码来源:RootsOfUnity.java
示例8: getNext
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Returns the next generated value, generated according
* to the mode value (see MODE constants).
*
* @return generated value
* @throws IOException in REPLAY_MODE if a file I/O error occurs
* @throws MathIllegalStateException if mode is not recognized
* @throws MathIllegalArgumentException if the underlying random generator thwrows one
*/
public double getNext() throws IOException, MathIllegalStateException, MathIllegalArgumentException {
switch (mode) {
case DIGEST_MODE: return getNextDigest();
case REPLAY_MODE: return getNextReplay();
case UNIFORM_MODE: return getNextUniform();
case EXPONENTIAL_MODE: return getNextExponential();
case GAUSSIAN_MODE: return getNextGaussian();
case CONSTANT_MODE: return mu;
default: throw new MathIllegalStateException(
LocalizedFormats.UNKNOWN_MODE,
mode,
"DIGEST_MODE", DIGEST_MODE, "REPLAY_MODE", REPLAY_MODE,
"UNIFORM_MODE", UNIFORM_MODE, "EXPONENTIAL_MODE", EXPONENTIAL_MODE,
"GAUSSIAN_MODE", GAUSSIAN_MODE, "CONSTANT_MODE", CONSTANT_MODE);
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:ValueServer.java
示例9: testMath844
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
@Test(expected=MathIllegalStateException.class)
public void testMath844() {
final double[] y = { 0, 1, 2, 3, 2, 1,
0, -1, -2, -3, -2, -1,
0, 1, 2, 3, 2, 1,
0, -1, -2, -3, -2, -1,
0, 1, 2, 3, 2, 1, 0 };
final int len = y.length;
final WeightedObservedPoint[] points = new WeightedObservedPoint[len];
for (int i = 0; i < len; i++) {
points[i] = new WeightedObservedPoint(1, i, y[i]);
}
// The guesser fails because the function is far from an harmonic
// function: It is a triangular periodic function with amplitude 3
// and period 12, and all sample points are taken at integer abscissae
// so function values all belong to the integer subset {-3, -2, -1, 0,
// 1, 2, 3}.
new HarmonicFitter.ParameterGuesser(points);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:21,代码来源:HarmonicFitterTest.java
示例10: testMath844
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
@Test(expected=MathIllegalStateException.class)
public void testMath844() {
final double[] y = { 0, 1, 2, 3, 2, 1,
0, -1, -2, -3, -2, -1,
0, 1, 2, 3, 2, 1,
0, -1, -2, -3, -2, -1,
0, 1, 2, 3, 2, 1, 0 };
final List<WeightedObservedPoint> points = new ArrayList<WeightedObservedPoint>();
for (int i = 0; i < y.length; i++) {
points.add(new WeightedObservedPoint(1, i, y[i]));
}
// The guesser fails because the function is far from an harmonic
// function: It is a triangular periodic function with amplitude 3
// and period 12, and all sample points are taken at integer abscissae
// so function values all belong to the integer subset {-3, -2, -1, 0,
// 1, 2, 3}.
new HarmonicCurveFitter.ParameterGuesser(points);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:HarmonicCurveFitterTest.java
示例11: getNextValue
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Generates a random value from this distribution.
* <strong>Preconditions:</strong><ul>
* <li>the distribution must be loaded before invoking this method</li></ul>
* @return the random value.
* @throws MathIllegalStateException if the distribution has not been loaded
*/
public double getNextValue() throws MathIllegalStateException {
if (!loaded) {
throw new MathIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
}
// Start with a uniformly distributed random number in (0,1)
final double x = randomData.nextUniform(0,1);
// Use this to select the bin and generate a Gaussian within the bin
for (int i = 0; i < binCount; i++) {
if (x <= upperBounds[i]) {
SummaryStatistics stats = binStats.get(i);
if (stats.getN() > 0) {
if (stats.getStandardDeviation() > 0) { // more than one obs
return getKernel(stats).sample();
} else {
return stats.getMean(); // only one obs in bin
}
}
}
}
throw new MathIllegalStateException(LocalizedFormats.NO_BIN_SELECTED);
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:EmpiricalDistribution.java
示例12: Network
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Constructor with restricted access, solely used for deserialization.
*
* @param nextId Next available identifier.
* @param featureSize Number of features.
* @param neuronList Neurons.
* @param neighbourIdList Links associated to each of the neurons in
* {@code neuronList}.
* @throws MathIllegalStateException if an inconsistency is detected
* (which probably means that the serialized form has been corrupted).
*/
Network(long nextId,
int featureSize,
Neuron[] neuronList,
long[][] neighbourIdList) {
final int numNeurons = neuronList.length;
if (numNeurons != neighbourIdList.length) {
throw new MathIllegalStateException();
}
for (int i = 0; i < numNeurons; i++) {
final Neuron n = neuronList[i];
final long id = n.getIdentifier();
if (id >= nextId) {
throw new MathIllegalStateException();
}
neuronMap.put(id, n);
linkMap.put(id, new HashSet<Long>());
}
for (int i = 0; i < numNeurons; i++) {
final long aId = neuronList[i].getIdentifier();
final Set<Long> aLinks = linkMap.get(aId);
for (Long bId : neighbourIdList[i]) {
if (neuronMap.get(bId) == null) {
throw new MathIllegalStateException();
}
addLinkToLinkSet(aLinks, bId);
}
}
this.nextId = new AtomicLong(nextId);
this.featureSize = featureSize;
}
开发者ID:biocompibens,项目名称:SME,代码行数:45,代码来源:Network.java
示例13: LocationFinder
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Builds a finder to retrieve the locations of neurons that
* belong to the given {@code map}.
*
* @param map Map.
*
* @throws MathIllegalStateException if the network contains non-unique
* identifiers. This indicates an inconsistent state due to a bug in
* the construction code of the underlying
* {@link org.apache.commons.math3.ml.neuralnet.Network network}.
*/
public LocationFinder(NeuronSquareMesh2D map) {
final int nR = map.getNumberOfRows();
final int nC = map.getNumberOfColumns();
for (int r = 0; r < nR; r++) {
for (int c = 0; c < nC; c++) {
final Long id = map.getNeuron(r, c).getIdentifier();
if (locations.get(id) != null) {
throw new MathIllegalStateException();
}
locations.put(id, new Location(r, c));
}
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:LocationFinder.java
示例14: start
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** Start the integration.
* <p>This method computes one step using the underlying starter integrator,
* and initializes the Nordsieck vector at step start. The starter integrator
* purpose is only to establish initial conditions, it does not really change
* time by itself. The top level multistep integrator remains in charge of
* handling time propagation and events handling as it will starts its own
* computation right from the beginning. In a sense, the starter integrator
* can be seen as a dummy one and so it will never trigger any user event nor
* call any user step handler.</p>
* @param equations complete set of differential equations to integrate
* @param initialState initial state (time, primary and secondary state vectors)
* @param t target time for the integration
* (can be set to a value smaller than <code>t0</code> for backward integration)
* @exception DimensionMismatchException if arrays dimension do not match equations settings
* @exception NumberIsTooSmallException if integration step is too small
* @exception MaxCountExceededException if the number of functions evaluations is exceeded
* @exception NoBracketingException if the location of an event cannot be bracketed
*/
protected void start(final FieldExpandableODE<T> equations, final FieldODEState<T> initialState, final T t)
throws DimensionMismatchException, NumberIsTooSmallException,
MaxCountExceededException, NoBracketingException {
// make sure NO user event nor user step handler is triggered,
// this is the task of the top level integrator, not the task
// of the starter integrator
starter.clearEventHandlers();
starter.clearStepHandlers();
// set up one specific step handler to extract initial Nordsieck vector
starter.addStepHandler(new FieldNordsieckInitializer(equations.getMapper(), (nSteps + 3) / 2));
// start integration, expecting a InitializationCompletedMarkerException
try {
starter.integrate(equations, initialState, t);
// we should not reach this step
throw new MathIllegalStateException(LocalizedFormats.MULTISTEP_STARTER_STOPPED_EARLY);
} catch (InitializationCompletedMarkerException icme) { // NOPMD
// this is the expected nominal interruption of the start integrator
// count the evaluations used by the starter
getEvaluationsCounter().increment(starter.getEvaluations());
}
// remove the specific step handler
starter.clearStepHandlers();
}
开发者ID:biocompibens,项目名称:SME,代码行数:52,代码来源:MultistepFieldIntegrator.java
示例15: getFollowingEdge
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** Get the edge that should naturally follow another one.
* @param previous edge to be continued
* @return other edge, starting where the previous one ends (they
* have not been connected yet)
* @exception MathIllegalStateException if there is not a single other edge
*/
private Edge getFollowingEdge(final Edge previous)
throws MathIllegalStateException {
// get the candidate nodes
final S2Point point = previous.getEnd().getLocation();
final List<BSPTree<Sphere2D>> candidates = root.getCloseCuts(point, tolerance);
// the following edge we are looking for must start from one of the candidates nodes
double closest = tolerance;
Edge following = null;
for (final BSPTree<Sphere2D> node : candidates) {
for (final Edge edge : nodeToEdgesList.get(node)) {
if (edge != previous && edge.getStart().getIncoming() == null) {
final Vector3D edgeStart = edge.getStart().getLocation().getVector();
final double gap = Vector3D.angle(point.getVector(), edgeStart);
if (gap <= closest) {
closest = gap;
following = edge;
}
}
}
}
if (following == null) {
final Vector3D previousStart = previous.getStart().getLocation().getVector();
if (Vector3D.angle(point.getVector(), previousStart) <= tolerance) {
// the edge connects back to itself
return previous;
}
// this should never happen
throw new MathIllegalStateException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN);
}
return following;
}
开发者ID:biocompibens,项目名称:SME,代码行数:45,代码来源:EdgesBuilder.java
示例16: getEdges
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** Get the boundary edges.
* @return boundary edges
* @exception MathIllegalStateException if there is not a single other edge
*/
public List<Edge> getEdges() throws MathIllegalStateException {
// connect the edges
for (final Edge previous : edgeToNode.keySet()) {
previous.setNextEdge(getFollowingEdge(previous));
}
return new ArrayList<Edge>(edgeToNode.keySet());
}
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:EdgesBuilder.java
示例17: computeGeometricalProperties
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** {@inheritDoc}
* @exception MathIllegalStateException if the tolerance setting does not allow to build
* a clean non-ambiguous boundary
*/
@Override
protected void computeGeometricalProperties() throws MathIllegalStateException {
final BSPTree<Sphere2D> tree = getTree(true);
if (tree.getCut() == null) {
// the instance has a single cell without any boundaries
if (tree.getCut() == null && (Boolean) tree.getAttribute()) {
// the instance covers the whole space
setSize(4 * FastMath.PI);
setBarycenter(new S2Point(0, 0));
} else {
setSize(0);
setBarycenter(S2Point.NaN);
}
} else {
// the instance has a boundary
final PropertiesComputer pc = new PropertiesComputer(getTolerance());
tree.visit(pc);
setSize(pc.getArea());
setBarycenter(pc.getBarycenter());
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:SphericalPolygonsSet.java
示例18: insertInTree
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/** Insert the instance into another tree.
* <p>The instance itself is modified so its former parent should
* not be used anymore.</p>
* @param parentTree parent tree to connect to (may be null)
* @param isPlusChild if true and if parentTree is not null, the
* resulting tree should be the plus child of its parent, ignored if
* parentTree is null
* @see LeafMerger
* @deprecated as of 3.4, replaced with {@link #insertInTree(BSPTree, boolean, VanishingCutHandler)}
*/
@Deprecated
public void insertInTree(final BSPTree<S> parentTree, final boolean isPlusChild) {
insertInTree(parentTree, isPlusChild, new VanishingCutHandler<S>() {
/** {@inheritDoc} */
public BSPTree<S> fixNode(BSPTree<S> node) {
// the cut should not be null
throw new MathIllegalStateException(LocalizedFormats.NULL_NOT_ALLOWED);
}
});
}
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:BSPTree.java
示例19: checkEmpty
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Throws MathIllegalStateException if n > 0.
* @throws MathIllegalStateException if data has been added to this statistic
*/
private void checkEmpty() throws MathIllegalStateException {
if (getN() > 0) {
throw new MathIllegalStateException(
LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,
getN());
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:12,代码来源:GeometricMean.java
示例20: removeMostRecentValue
import org.apache.commons.math3.exception.MathIllegalStateException; //导入依赖的package包/类
/**
* Removes the most recent value from the dataset.
*
* @throws MathIllegalStateException if there are no elements stored
*/
public void removeMostRecentValue() throws MathIllegalStateException {
try {
eDA.discardMostRecentElements(1);
} catch (MathIllegalArgumentException ex) {
throw new MathIllegalStateException(LocalizedFormats.NO_DATA);
}
}
开发者ID:biocompibens,项目名称:SME,代码行数:13,代码来源:DescriptiveStatistics.java
注:本文中的org.apache.commons.math3.exception.MathIllegalStateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论