List of usage examples for java.lang Double NaN
double NaN
To view the source code for java.lang Double NaN.
Click Source Link
From source file:com.joptimizer.solvers.DiagonalHKKTSolver.java
/** * @FIXME: fix this method (wrong return) * try for example with H and A of the first iteration of the afiro netlib problem *//*from w w w . j a v a 2 s .com*/ private DoubleMatrix2D calculateSubdiagonalAHAT(final DoubleMatrix2D AA, final DoubleMatrix2D HH) { final DoubleMatrix2D ret = DoubleFactory2D.sparse.make(AA.rows(), AA.rows()); final int[] rowHolder = new int[] { -1 }; final int[] colHolder = new int[] { -1 }; final double[] valueHolder = new double[] { Double.NaN }; final IntIntDoubleFunction myFunc = new IntIntDoubleFunction() { public double apply(int r, int c, double AAColrc) { if (c < rowHolder[0] + 1) { //log.debug("sum " + AAColrc + "*" + HH.getQuick(colHolder[0], colHolder[0]) + " to AHAT(" + r + "," + rowHolder[0] + ")"); ret.setQuick(r, rowHolder[0], ret.getQuick(r, rowHolder[0]) + valueHolder[0] * AAColrc * HH.getQuick(colHolder[0], colHolder[0])); } return AAColrc; } }; AA.forEachNonZero(new IntIntDoubleFunction() { public double apply(final int i, final int j, final double aij) { rowHolder[0] = i; colHolder[0] = j; valueHolder[0] = aij; //log.debug("a(" + i + "," + j + "): " + aij); DoubleMatrix2D AACol = AA.viewPart(0, j, AA.rows(), 1); //log.debug("ACol(" + j + "): " + ArrayUtils.toString(AACol.toArray())); // ACol.forEachNonZero(new IntIntDoubleFunction() { // public double apply(int r, int c, double AColrc) { // if (c < r + 1) { // logger.debug("sum " + AColrc + "*" + H.getQuick(j, j) + " to AHAT(" + r + "," + i + ")"); // ret.setQuick(r, i, ret.getQuick(r, i) + aij * AColrc * H.getQuick(j, j)); // } // return AColrc; // } // }); AACol.forEachNonZero(myFunc); return aij; } }); return ret; }
From source file:com.microsoft.azure.storage.table.TableEntitySerializer.java
/** * Reserved for internal use. Writes an entity to the specified <code>JsonGenerator</code> as a JSON resource * // www.jav a 2 s. c o m * @param generator * The <code>JsonGenerator</code> to write the entity to. * @param options * The {@link TableRequestOptions} to use for serializing. * @param entity * The instance implementing {@link TableEntity} to write to the output stream. * @param isTableEntry * A flag indicating the entity is a reference to a table at the top level of the storage service when * <code>true<code> and a reference to an entity within a table when <code>false</code>. * @param opContext * An {@link OperationContext} object used to track the execution of the operation. * * @throws StorageException * if a Storage service error occurs. * @throws IOException * if an error occurs while accessing the stream. */ private static void writeJsonEntity(final JsonGenerator generator, final TableRequestOptions options, final TableEntity entity, final boolean isTableEntry, final OperationContext opContext) throws StorageException, IOException { Map<String, EntityProperty> properties = getPropertiesFromDictionary(entity, options, opContext); // start object generator.writeStartObject(); if (!isTableEntry) { Utility.assertNotNull(TableConstants.PARTITION_KEY, entity.getPartitionKey()); Utility.assertNotNull(TableConstants.ROW_KEY, entity.getRowKey()); Utility.assertNotNull(TableConstants.TIMESTAMP, entity.getTimestamp()); // PartitionKey generator.writeStringField(TableConstants.PARTITION_KEY, entity.getPartitionKey()); // RowKey generator.writeStringField(TableConstants.ROW_KEY, entity.getRowKey()); // Timestamp generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp())); } for (final Entry<String, EntityProperty> ent : properties.entrySet()) { if (ent.getKey().equals(TableConstants.PARTITION_KEY) || ent.getKey().equals(TableConstants.ROW_KEY) || ent.getKey().equals(TableConstants.TIMESTAMP) || ent.getKey().equals("Etag")) { continue; } EntityProperty currProp = ent.getValue(); if (currProp.getEdmType().mustAnnotateType()) { final String edmTypeString = currProp.getEdmType().toString(); // property type generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString); // property key and value generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString()); } else if (currProp.getEdmType() == EdmType.DOUBLE && currProp.getIsNull() == false) { final String edmTypeString = currProp.getEdmType().toString(); final Double value = currProp.getValueAsDouble(); // property type, if needed if (value.equals(Double.POSITIVE_INFINITY) || value.equals(Double.NEGATIVE_INFINITY) || value.equals(Double.NaN)) { generator.writeStringField(ent.getKey() + ODataConstants.ODATA_TYPE_SUFFIX, edmTypeString); // property key and value generator.writeStringField(ent.getKey(), ent.getValue().getValueAsString()); } else { writeJsonProperty(generator, ent); } } else { writeJsonProperty(generator, ent); } } // end object generator.writeEndObject(); }
From source file:com.rapidminer.operator.preprocessing.discretization.FrequencyDiscretization.java
@Override public PreprocessingModel createPreprocessingModel(ExampleSet exampleSet) throws OperatorException { HashMap<Attribute, double[]> ranges = new HashMap<Attribute, double[]>(); // Get and check parametervalues boolean useSqrt = getParameterAsBoolean(PARAMETER_USE_SQRT_OF_EXAMPLES); int numberOfBins = 0; if (!useSqrt) { // if not automatic sizing of bins, use parametervalue numberOfBins = getParameterAsInt(PARAMETER_NUMBER_OF_BINS); if (numberOfBins >= (exampleSet.size() - 1)) { throw new UserError(this, 116, PARAMETER_NUMBER_OF_BINS, "number of bins must be smaller than number of examples (here: " + exampleSet.size() + ")"); }// w ww .java 2s.co m } else { exampleSet.recalculateAllAttributeStatistics(); } for (Attribute currentAttribute : exampleSet.getAttributes()) { if (useSqrt) { numberOfBins = (int) Math.round(Math.sqrt( exampleSet.size() - (int) exampleSet.getStatistics(currentAttribute, Statistics.UNKNOWN))); } double[] attributeRanges = new double[numberOfBins]; ExampleSet sortedSet = new SortedExampleSet(exampleSet, currentAttribute, SortedExampleSet.INCREASING); // finding ranges double examplesPerBin = exampleSet.size() / (double) numberOfBins; double currentBinSpace = examplesPerBin; double lastValue = Double.NaN; int currentBin = 0; for (Example example : sortedSet) { double value = example.getValue(currentAttribute); if (!Double.isNaN(value)) { // change bin if full and not last if (currentBinSpace < 1 && currentBin < numberOfBins && value != lastValue) { if (!Double.isNaN(lastValue)) { attributeRanges[currentBin] = (lastValue + value) / 2; currentBin++; currentBinSpace += examplesPerBin; // adding because same values might // cause binspace to be negative if (currentBinSpace < 1) { throw new UserError(this, 944, currentAttribute.getName()); } } } currentBinSpace--; lastValue = value; } } attributeRanges[numberOfBins - 1] = Double.POSITIVE_INFINITY; ranges.put(currentAttribute, attributeRanges); } DiscretizationModel model = new DiscretizationModel(exampleSet); // determine number of digits int numberOfDigits = -1; if (getParameterAsBoolean(PARAMETER_AUTOMATIC_NUMBER_OF_DIGITS) == false) { numberOfDigits = getParameterAsInt(PARAMETER_NUMBER_OF_DIGITS); } model.setRanges(ranges, "range", getParameterAsInt(PARAMETER_RANGE_NAME_TYPE), numberOfDigits); return model; }
From source file:com.itemanalysis.psychometrics.irt.model.Irm4PL.java
public double itemInformationAt(double theta) { return Double.NaN; }
From source file:com.joptimizer.optimizers.PrimalDualMethod.java
@Override public int optimize() throws Exception { Log.i(MainActivity.JOPTIMIZER_LOGTAG, "optimize"); long tStart = System.currentTimeMillis(); OptimizationResponse response = new OptimizationResponse(); // @TODO: check assumptions!!! // if(getA()!=null){ // if(ALG.rank(getA())>=getA().rows()){ // throw new IllegalArgumentException("A-rank must be less than A-rows"); // }//from w w w . j av a2 s . c om // } DoubleMatrix1D X0 = getInitialPoint(); if (X0 == null) { DoubleMatrix1D X0NF = getNotFeasibleInitialPoint(); if (X0NF != null) { double rPriX0NFNorm = Math.sqrt(ALG.norm2(rPri(X0NF))); DoubleMatrix1D fiX0NF = getFi(X0NF); int maxIndex = Utils.getMaxIndex(fiX0NF.toArray()); double maxValue = fiX0NF.get(maxIndex); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriX0NFNorm : " + rPriX0NFNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0NF : " + ArrayUtils.toString(X0NF.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "fiX0NF : " + ArrayUtils.toString(fiX0NF.toArray())); } if (maxValue < 0 && rPriX0NFNorm <= getToleranceFeas()) { //the provided not-feasible starting point is already feasible Log.d(MainActivity.JOPTIMIZER_LOGTAG, "the provided initial point is already feasible"); X0 = X0NF; } } if (X0 == null) { BasicPhaseIPDM bf1 = new BasicPhaseIPDM(this); X0 = bf1.findFeasibleInitialPoint(); } } //check X0 feasibility DoubleMatrix1D fiX0 = getFi(X0); int maxIndex = Utils.getMaxIndex(fiX0.toArray()); double maxValue = fiX0.get(maxIndex); double rPriX0Norm = Math.sqrt(ALG.norm2(rPri(X0))); if (maxValue >= 0 || rPriX0Norm > getToleranceFeas()) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPriX0Norm : " + rPriX0Norm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "ineqX0 : " + ArrayUtils.toString(fiX0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq index: " + maxIndex); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "max ineq value: " + maxValue); throw new Exception("initial point must be strictly feasible"); } DoubleMatrix1D V0 = (getA() != null) ? F1.make(getA().rows()) : F1.make(0); DoubleMatrix1D L0 = getInitialLagrangian(); if (L0 != null) { for (int j = 0; j < L0.size(); j++) { // must be >0 if (L0.get(j) <= 0) { throw new IllegalArgumentException("initial lagrangian must be strictly > 0"); } } } else { //L0 = F1.make(getFi().length, 1.);// must be >0 L0 = F1.make(getFi().length, Math.min(1, (double) getDim() / getFi().length));// must be >0 } if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X0: " + ArrayUtils.toString(X0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V0: " + ArrayUtils.toString(V0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "L0: " + ArrayUtils.toString(L0.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "toleranceFeas: " + getToleranceFeas()); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "tolerance : " + getTolerance()); } DoubleMatrix1D X = X0; DoubleMatrix1D V = V0; DoubleMatrix1D L = L0; //double F0X; //DoubleMatrix1D gradF0X = null; //DoubleMatrix1D fiX = null; //DoubleMatrix2D GradFiX = null; //DoubleMatrix1D rPriX = null; //DoubleMatrix1D rCentXLt = null; //DoubleMatrix1D rDualXLV = null; //double rPriXNorm = Double.NaN; //double rCentXLtNorm = Double.NaN; //double rDualXLVNorm = Double.NaN; //double normRXLVt = Double.NaN; double previousF0X = Double.NaN; double previousRPriXNorm = Double.NaN; double previousRDualXLVNorm = Double.NaN; double previousSurrDG = Double.NaN; double t; int iteration = 0; while (true) { iteration++; // iteration limit condition if (iteration == getMaxIteration() + 1) { response.setReturnCode(OptimizationResponse.WARN); Log.w(MainActivity.JOPTIMIZER_LOGTAG, "Max iterations limit reached"); break; } double F0X = getF0(X); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "iteration: " + iteration); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "X=" + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "L=" + ArrayUtils.toString(L.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "V=" + ArrayUtils.toString(V.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "f0(X)=" + F0X); } // if(!Double.isNaN(previousF0X)){ // if (previousF0X < F0X) { // throw new Exception("critical minimization problem"); // } // } // previousF0X = F0X; // determine functions evaluations DoubleMatrix1D gradF0X = getGradF0(X); DoubleMatrix1D fiX = getFi(X); DoubleMatrix2D GradFiX = getGradFi(X); DoubleMatrix2D[] HessFiX = getHessFi(X); // determine t double surrDG = getSurrogateDualityGap(fiX, L); t = getMu() * getFi().length / surrDG; Log.d(MainActivity.JOPTIMIZER_LOGTAG, "t: " + t); // determine residuals DoubleMatrix1D rPriX = rPri(X); DoubleMatrix1D rCentXLt = rCent(fiX, L, t); DoubleMatrix1D rDualXLV = rDual(GradFiX, gradF0X, L, V); double rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); double rCentXLtNorm = Math.sqrt(ALG.norm2(rCentXLt)); double rDualXLVNorm = Math.sqrt(ALG.norm2(rDualXLV)); double normRXLVt = Math .sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rCentXLtNorm, 2) + Math.pow(rDualXLVNorm, 2)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rPri norm: " + rPriXNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rCent norm: " + rCentXLtNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "rDual norm: " + rDualXLVNorm); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "surrDG : " + surrDG); // custom exit condition if (checkCustomExitConditions(X)) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // exit condition if (rPriXNorm <= getToleranceFeas() && rDualXLVNorm <= getToleranceFeas() && surrDG <= getTolerance()) { response.setReturnCode(OptimizationResponse.SUCCESS); break; } // progress conditions if (isCheckProgressConditions()) { if (!Double.isNaN(previousRPriXNorm) && !Double.isNaN(previousRDualXLVNorm) && !Double.isNaN(previousSurrDG)) { if ((previousRPriXNorm <= rPriXNorm && rPriXNorm >= getToleranceFeas()) || (previousRDualXLVNorm <= rDualXLVNorm && rDualXLVNorm >= getToleranceFeas())) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved, exit iterations loop without desired accuracy"); response.setReturnCode(OptimizationResponse.WARN); break; } } previousRPriXNorm = rPriXNorm; previousRDualXLVNorm = rDualXLVNorm; previousSurrDG = surrDG; } // compute primal-dual search direction // a) prepare 11.55 system DoubleMatrix2D HessSum = getHessF0(X); for (int j = 0; j < getFi().length; j++) { if (HessFiX[j] != FunctionsUtils.ZEROES_MATRIX_PLACEHOLDER) { HessSum.assign(HessFiX[j].copy().assign(Mult.mult(L.get(j))), Functions.plus); } //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"HessSum : " + ArrayUtils.toString(HessSum.toArray())); } // DoubleMatrix2D GradSum = F2.make(getDim(), getDim()); // for (int j = 0; j < getFi().length; j++) { // DoubleMatrix1D g = GradFiX.viewRow(j); // GradSum.assign(ALG.multOuter(g, g, null).assign(Mult.mult(-L.get(j) / fiX.get(j))), Functions.plus); // //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"GradSum : " + ArrayUtils.toString(GradSum.toArray())); // } DoubleMatrix2D GradSum = F2.make(getDim(), getDim()); for (int j = 0; j < getFi().length; j++) { final double c = -L.getQuick(j) / fiX.getQuick(j); DoubleMatrix1D g = GradFiX.viewRow(j); SeqBlas.seqBlas.dger(c, g, g, GradSum); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"GradSum : " + ArrayUtils.toString(GradSum.toArray())); } DoubleMatrix2D Hpd = HessSum.assign(GradSum, Functions.plus); //DoubleMatrix2D Hpd = getHessF0(X).assign(HessSum, Functions.plus).assign(GradSum, Functions.plus); DoubleMatrix1D gradSum = F1.make(getDim()); for (int j = 0; j < getFi().length; j++) { gradSum.assign(GradFiX.viewRow(j).copy().assign(Mult.div(-t * fiX.get(j))), Functions.plus); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"gradSum : " + ArrayUtils.toString(gradSum.toArray())); } DoubleMatrix1D g = null; if (getAT() == null) { g = gradF0X.copy().assign(gradSum, Functions.plus); } else { g = gradF0X.copy().assign(gradSum, Functions.plus).assign(ALG.mult(getAT(), V), Functions.plus); } // b) solving 11.55 system if (this.kktSolver == null) { this.kktSolver = new BasicKKTSolver(); } //KKTSolver solver = new DiagonalKKTSolver(); if (isCheckKKTSolutionAccuracy()) { kktSolver.setCheckKKTSolutionAccuracy(true); kktSolver.setToleranceKKT(getToleranceKKT()); } kktSolver.setHMatrix(Hpd.toArray()); kktSolver.setGVector(g.toArray()); if (getA() != null) { kktSolver.setAMatrix(getA().toArray()); kktSolver.setATMatrix(getAT().toArray()); kktSolver.setHVector(rPriX.toArray()); } double[][] sol = kktSolver.solve(); DoubleMatrix1D stepX = F1.make(sol[0]); DoubleMatrix1D stepV = (sol[1] != null) ? F1.make(sol[1]) : F1.make(0); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepX: " + ArrayUtils.toString(stepX.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepV: " + ArrayUtils.toString(stepV.toArray())); } // c) solving for L DoubleMatrix1D stepL = null; DoubleMatrix2D diagFInv = F2.diagonal(fiX.copy().assign(Functions.inv)); DoubleMatrix2D diagL = F2.diagonal(L); stepL = ALG.mult(diagFInv, ALG.mult(diagL, ALG.mult(GradFiX, stepX))).assign(Mult.mult(-1)) .assign(ALG.mult(diagFInv, rCentXLt), Functions.plus); if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "stepL: " + ArrayUtils.toString(stepL.toArray())); } // line search and update // a) sMax computation double sMax = Double.MAX_VALUE; for (int j = 0; j < getFi().length; j++) { if (stepL.get(j) < 0) { sMax = Math.min(-L.get(j) / stepL.get(j), sMax); } } sMax = Math.min(1, sMax); double s = 0.99 * sMax; // b) backtracking with f DoubleMatrix1D X1 = F1.make(X.size()); DoubleMatrix1D L1 = F1.make(L.size()); DoubleMatrix1D V1 = F1.make(V.size()); DoubleMatrix1D fiX1 = null; DoubleMatrix1D gradF0X1 = null; DoubleMatrix2D GradFiX1 = null; DoubleMatrix1D rPriX1 = null; DoubleMatrix1D rCentX1L1t = null; DoubleMatrix1D rDualX1L1V1 = null; int cnt = 0; boolean areAllNegative = true; while (cnt < 500) { cnt++; // X1 = X + s*stepX X1 = stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus); DoubleMatrix1D ineqValueX1 = getFi(X1); areAllNegative = true; for (int j = 0; areAllNegative && j < getFi().length; j++) { areAllNegative = (Double.compare(ineqValueX1.get(j), 0.) < 0); } if (areAllNegative) { break; } s = getBeta() * s; } if (!areAllNegative) { //exited from the feasible region throw new Exception("Optimization failed: impossible to remain within the faesible region"); } Log.d(MainActivity.JOPTIMIZER_LOGTAG, "s: " + s); // c) backtracking with norm double previousNormRX1L1V1t = Double.NaN; cnt = 0; while (cnt < 500) { cnt++; X1 = stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus); L1 = stepL.copy().assign(Mult.mult(s)).assign(L, Functions.plus); V1 = stepV.copy().assign(Mult.mult(s)).assign(V, Functions.plus); // X1.assign(stepX.copy().assign(Mult.mult(s)).assign(X, Functions.plus)); // L1.assign(stepL.copy().assign(Mult.mult(s)).assign(L, Functions.plus)); // V1.assign(stepV.copy().assign(Mult.mult(s)).assign(V, Functions.plus)); if (isInDomainF0(X1)) { fiX1 = getFi(X1); gradF0X1 = getGradF0(X1); GradFiX1 = getGradFi(X1); rPriX1 = rPri(X1); rCentX1L1t = rCent(fiX1, L1, t); rDualX1L1V1 = rDual(GradFiX1, gradF0X1, L1, V1); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPriX1 : "+ArrayUtils.toString(rPriX1.toArray())); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rCentX1L1t : "+ArrayUtils.toString(rCentX1L1t.toArray())); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDualX1L1V1: "+ArrayUtils.toString(rDualX1L1V1.toArray())); double normRX1L1V1t = Math .sqrt(ALG.norm2(rPriX1) + ALG.norm2(rCentX1L1t) + ALG.norm2(rDualX1L1V1)); //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"normRX1L1V1t: "+normRX1L1V1t); if (normRX1L1V1t <= (1 - getAlpha() * s) * normRXLVt) { break; } if (!Double.isNaN(previousNormRX1L1V1t)) { if (previousNormRX1L1V1t <= normRX1L1V1t) { Log.w(MainActivity.JOPTIMIZER_LOGTAG, "No progress achieved in backtracking with norm"); break; } } previousNormRX1L1V1t = normRX1L1V1t; } s = getBeta() * s; //Log.d(MainActivity.JOPTIMIZER_LOGTAG,"s: " + s); } // update X = X1; V = V1; L = L1; // fiX = fiX1; // gradF0X = gradF0X1; // GradFiX = GradFiX1; // // rPriX = rPriX1; // rCentXLt = rCentX1L1t; // rDualXLV = rDualX1L1V1; // rPriXNorm = Math.sqrt(ALG.norm2(rPriX)); // rCentXLtNorm = Math.sqrt(ALG.norm2(rCentXLt)); // rDualXLVNorm = Math.sqrt(ALG.norm2(rDualXLV)); // normRXLVt = Math.sqrt(Math.pow(rPriXNorm, 2) + Math.pow(rCentXLtNorm, 2) + Math.pow(rDualXLVNorm, 2)); // if(Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)){ // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rPri norm: " + rPriXNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rCent norm: " + rCentXLtNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"rDual norm: " + rDualXLVNorm); // Log.d(MainActivity.JOPTIMIZER_LOGTAG,"surrDG : " + surrDG); // } } long tStop = System.currentTimeMillis(); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "time: " + (tStop - tStart)); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "sol : " + ArrayUtils.toString(X.toArray())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "ret code: " + response.getReturnCode()); response.setSolution(X.toArray()); setOptimizationResponse(response); return response.getReturnCode(); }
From source file:edu.cornell.med.icb.learning.tools.svmlight.EvaluationMeasure.java
public double getPerformanceValueStd(final String measureName) { final ZScoreCalculator calc = new ZScoreCalculator(); calc.reset();//from w ww . j a va 2 s . c o m final DoubleList values = name2Values.get(measureName.intern()); if (values == null || values.size() < 3) { return Double.NaN; } for (final double value : values) { calc.observe(value); } calc.calculateStats(); return calc.stdDev(); }
From source file:ml.shifu.shifu.util.JexlTest.java
@Test public void testDouble() { Double a = Double.NaN; Double b = Double.valueOf(a.toString()); Assert.assertEquals(a, b); }
From source file:eu.amidst.dynamic.inference.DynamicMAPInference.java
/** * {@inheritDoc}//from w w w . ja va 2 s.co m */ @Override public void reset() { seed = 125123; parallelMode = true; sampleSize = 1000; nMergedClassVars = 2; nTimeSteps = 2; model = null; unfoldedStaticModel = null; mergedClassVarModels = null; evidence = null; MAPvarName = null; MAPvariable = null; MAPestimate = null; MAPsequence = null; MAPestimateLogProbability = Double.NaN; }
From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset.java
/** * Adds a list of values relating to one Box and Whisker entity to the * table. The various median values are calculated. * * @param item a box and whisker item (<code>null</code> not permitted). * @param rowKey the row key (<code>null</code> not permitted). * @param columnKey the column key (<code>null</code> not permitted). * * @see #add(List, Comparable, Comparable) *//* ww w .j av a2 s . co m*/ public void add(BoxAndWhiskerItem item, Comparable rowKey, Comparable columnKey) { this.data.addObject(item, rowKey, columnKey); // update cached min and max values int r = this.data.getRowIndex(rowKey); int c = this.data.getColumnIndex(columnKey); if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn == c) || (this.minimumRangeValueRow == r && this.minimumRangeValueColumn == c)) { updateBounds(); } else { double minval = Double.NaN; if (item.getMinOutlier() != null) { minval = item.getMinOutlier().doubleValue(); } double maxval = Double.NaN; if (item.getMaxOutlier() != null) { maxval = item.getMaxOutlier().doubleValue(); } if (Double.isNaN(this.maximumRangeValue)) { this.maximumRangeValue = maxval; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } else if (maxval > this.maximumRangeValue) { this.maximumRangeValue = maxval; this.maximumRangeValueRow = r; this.maximumRangeValueColumn = c; } if (Double.isNaN(this.minimumRangeValue)) { this.minimumRangeValue = minval; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } else if (minval < this.minimumRangeValue) { this.minimumRangeValue = minval; this.minimumRangeValueRow = r; this.minimumRangeValueColumn = c; } } fireDatasetChanged(); }
From source file:model.DecomposableModel.java
public void performAction(GraphAction actionToPerform, DecomposableModel fromModel, MyPriorityQueue pq) { List<GraphAction> actionsToPerform = fromModel.actionsForInteraction.get(actionToPerform); for (GraphAction action : actionsToPerform) { switch (action.type) { case ADD: graph.addSecuredEdge(action.getV1(), action.getV2(), pq); break; case REMOVE: // graph.removeSecuredEdge(action.getV1(), // action.getV2(),pq,scorer); break; default:/*from w w w . ja va 2 s . c om*/ break; } } entropyComputed = false; entropy = Double.NaN; // invalidate the entropy nbParameters = -1; // invalidate the nb degrees of freedom }