List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:edu.oregonstate.eecs.mcplan.ml.KMeans.java
@Override public void run() { initCenters();// ww w. j a v a 2 s . c o m boolean progress = false; while (true) { // Expectation progress = false; for (int i = 0; i < data_.length; ++i) { double d = Double.MAX_VALUE; int c = 0; for (int j = 0; j < k_; ++j) { final double dp = distance(centers_[j], data_[i]); if (dp < d) { d = dp; c = j; } } if (c != c_[i]) { c_[i] = c; progress = true; } } if (!progress) { break; } // Maximization for (int j = 0; j < k_; ++j) { centers_[j] = centerOfMass(j); } debug(); } }
From source file:uk.ac.ebi.ep.parser.parsers.DiseaseParser.java
private void LoadToDB(String[] fields) throws InterruptedException { double[] scores = new double[1]; if (fields.length >= 4) { String[] scoresCell = fields[4].split(" ?/ ?"); String accession = fields[0]; String[] omimCell = fields[1].split("\\s"); String[] meshIdsCell = fields[2].split(" ?/ ?"); String[] meshHeadsCell = fields[3].split(" / "); if (fields[4].contains("/")) { scores = new double[scoresCell.length]; for (int i = 0; i < scoresCell.length; i++) { final String scoreString = scoresCell[i].trim(); if (scoreString.equals("exact")) { scores[i] = Double.MAX_VALUE; } else { scores[i] = Double.valueOf(scoreString); }/* www.ja v a 2s.co m*/ } } else { if (scoresCell[0].equals("exact")) { scores[0] = Double.MAX_VALUE; } else { scores[0] = Double.valueOf(scoresCell[0]); } } String definition = ""; String url = "#"; for (int i = 0; i < scores.length; i++) { //check to see if accession is an enzyme Optional<UniprotEntry> enzyme = uniprotEntryService.findByAccession(accession); if (enzyme.isPresent()) { if (!meshHeadsCell[i].contains(" ")) { definition = bioPortalService.getDiseaseDescription(meshHeadsCell[i]); } else { definition = bioPortalService.getDiseaseDescription(meshIdsCell[i].trim()); } Optional<EnzymePortalSummary> summary = enzymeSummaryRepository.findDiseaseEvidence(accession); EnzymePortalDisease disease = new EnzymePortalDisease(); String diseaseName = resolveSpecialCharacters(meshHeadsCell[i].toLowerCase(Locale.ENGLISH)); disease.setDiseaseName(diseaseName.replaceAll(",", "").trim()); disease.setMeshId(meshIdsCell[i].trim()); disease.setOmimNumber(omimCell[0]); disease.setScore(Double.toString(scores[i])); disease.setDefinition(definition); disease.setUniprotAccession(enzyme.get()); if (summary.isPresent()) { disease.setEvidence(summary.get().getCommentText()); } if (!StringUtils.isEmpty(omimCell[0]) && !omimCell[0].equals("-")) { url = "http://purl.bioontology.org/ontology/OMIM/" + omimCell[0]; } else { url = "http://purl.bioontology.org/ontology/MESH/" + meshIdsCell[i]; } disease.setUrl(url); diseaseList.add(disease); // LOGGER.debug(accession + " mim : " + omimCell[0] + " mesh :" + meshIdsCell[i] // + " name: " + meshHeadsCell[i] + " score : " + scores[i]); // // System.out.println(accession + " mim : " + omimCell[0] + " mesh :" + meshIdsCell[i] // + " name: " + meshHeadsCell[i] + " score : " + scores[i] +"evidence "+ disease.getEvidence()); } } } else { LOGGER.fatal("ArrayIndexOutOfBoundsException. The size of fields is " + fields.length); // throw new ArrayIndexOutOfBoundsException(); } }
From source file:com.spoiledmilk.ibikecph.search.FoursquareData.java
public static double distance(Location loc, JsonNode jsonNode) { double ret = Double.MAX_VALUE; if (jsonNode.has("location") && jsonNode.get("location").has("lat") && jsonNode.get("location").has("lng")) { double latitude = jsonNode.get("location").get("lat").asDouble(); double longitude = jsonNode.get("location").get("lng").asDouble(); ret = loc.distanceTo(Util.locationFromCoordinates(latitude, longitude)); }/* w w w . ja v a 2 s . c o m*/ return ret; }
From source file:eu.crisis_economics.abm.contracts.DepositAccount.java
public void deposit(final double amount) { if (amount < 0) { throw new IllegalArgumentException("Cannot deposit negative money: " + amount); }/*w w w . j a v a 2 s . com*/ if (getValue() + amount > Double.MAX_VALUE) { throw new ArithmeticException( "Cannot add " + amount + ", the result is too large to represent as a double number"); } getDepositHolder().increaseCashReserves(amount); incrementValue(amount); setFaceValue(getValue()); }
From source file:es.udc.gii.common.eaf.stoptest.PerformanceFitnessStopTest.java
/** * Implements the method <tt>isReach</tt>. Test if the best individual of the * current algorithm reach a fitness value that is specified on the configuration * file.//w ww. j av a2 s . c o m * @param algorithm The algorithm wich has to reach the objective * @return <tt>true</tt> if the algorithm reach the desired fitness value, <tt>false</tt> * in other case. */ @Override public boolean isReach(EvolutionaryAlgorithm algorithm) { BestIndividualSpecification bestSpec = new BestIndividualSpecification(); Individual best = IndividualsProductTrader .get(bestSpec, algorithm.getPopulation().getIndividuals(), 1, algorithm.getComparator()).get(0); Individual individual_goal = (Individual) best.clone(); individual_goal.setFitness(this.goal); boolean reach = false; double problemFitness = best.getFitness(); if (problemFitness == Double.MAX_VALUE) { return false; } int compare = algorithm.getComparator().compare(best, individual_goal); // return this.goal <= Math.abs(problemFitness); reach = (compare > 0 ? false : true); return reach; }
From source file:com.sillelien.dollar.api.types.DollarInfinity.java
@Override public var $as(@NotNull Type type) { if (type.equals(Type.BOOLEAN)) { return DollarStatic.$(true); } else if (type.equals(Type.STRING)) { return DollarStatic.$(positive ? "infinity" : "-infinity"); } else if (type.equals(Type.LIST)) { return DollarStatic.$(Arrays.asList(this)); } else if (type.equals(Type.MAP)) { return DollarStatic.$("value", this); } else if (type.equals(Type.DECIMAL)) { return DollarStatic.$(positive ? Double.MAX_VALUE : Double.MIN_VALUE); } else if (type.equals(Type.INTEGER)) { return DollarStatic.$(positive ? Long.MAX_VALUE : Long.MIN_VALUE); } else if (type.equals(Type.VOID)) { return $void(); } else if (type.equals(Type.DATE)) { return this; } else if (type.equals(Type.RANGE)) { return DollarFactory.fromValue(new Range($(0), $(0))); } else {//from w w w . j a va2s .c o m return DollarFactory.failure(ErrorType.INVALID_CAST, type.toString(), false); } }
From source file:com.act.lcms.db.analysis.HitOrMissReplicateFilterAndTransformer.java
/** * This function takes in a list of molecules from multiple replicates over the same time and alignes the peaks across * these replicates. If the peaks can be aligned, the function reports the min statistic across those peaks, else it * defaults to a low statistic./*from www. j a v a 2 s . c om*/ * @param oneOrMoreReplicates * @return A pair of transformed HitOrMiss molecule and whether to save the result in the final model. */ public Pair<IonAnalysisInterchangeModel.HitOrMiss, Boolean> apply( List<IonAnalysisInterchangeModel.HitOrMiss> oneOrMoreReplicates) { List<Double> intensityValues = oneOrMoreReplicates.stream().map(molecule -> molecule.getIntensity()) .collect(Collectors.toList()); List<Double> snrValues = oneOrMoreReplicates.stream().map(molecule -> molecule.getSnr()) .collect(Collectors.toList()); List<Double> timeValues = oneOrMoreReplicates.stream().map(molecule -> molecule.getTime()) .collect(Collectors.toList()); IonAnalysisInterchangeModel.HitOrMiss result = new IonAnalysisInterchangeModel.HitOrMiss(); result.setInchi(oneOrMoreReplicates.get(REPRESENTATIVE_INDEX).getInchi()); result.setIon(oneOrMoreReplicates.get(REPRESENTATIVE_INDEX).getIon()); result.setPlot(NIL_PLOT); // We get the min and max time to calculate how much do the replicates deviate in time for the same signal. If // the deviation in the time axis is greater than our tolerance, we know the signal is bad. Double minTime = timeValues.stream().reduce(Double.MAX_VALUE, (accum, newVal) -> Math.min(accum, newVal)); Double maxTime = timeValues.stream().reduce(Double.MIN_VALUE, (accum, newVal) -> Math.max(accum, newVal)); if (maxTime - minTime < TIME_TOLERANCE_IN_SECONDS) { Double minIntensity = intensityValues.stream().reduce(Double.MAX_VALUE, (accum, newVal) -> Math.min(accum, newVal)); Integer indexOfMinIntensityReplicate = intensityValues.indexOf(minIntensity); // The SNR and Time values will be the copy of the replicate with the lowest intensity value. result.setSnr(snrValues.get(indexOfMinIntensityReplicate)); result.setIntensity(minIntensity); result.setTime(timeValues.get(indexOfMinIntensityReplicate)); return Pair.of(result, DO_NOT_THROW_OUT_MOLECULE); } else { // TODO: We can just throw out such molecules. result.setSnr(LOWEST_POSSIBLE_VALUE_FOR_PEAK_STATISTIC); result.setIntensity(LOWEST_POSSIBLE_VALUE_FOR_PEAK_STATISTIC); result.setTime(LOWEST_POSSIBLE_VALUE_FOR_PEAK_STATISTIC); return Pair.of(result, DO_NOT_THROW_OUT_MOLECULE); } }
From source file:com.redhat.lightblue.metadata.types.StringTypeTest.java
@Test public void testEqualsFalse() { assertFalse(stringType.equals(Double.MAX_VALUE)); }
From source file:geogebra.kernel.implicit.PolynomialUtils.java
private static boolean rootPolishing(double[] pair, GeoImplicitPoly p1, GeoImplicitPoly p2, double[] line) { double x = pair[0], y = pair[1]; double p, q;// w w w . j a v a 2 s. co m if (p1 == null) { return false; } if (p2 == null && (line == null || line.length != 3)) { return false; } p = p1.evalPolyAt(x, y); if (p2 != null) q = p2.evalPolyAt(x, y); else q = line[0] + x * line[1] + y * line[2]; double lastErr = Double.MAX_VALUE; double err = Math.abs(p) + Math.abs(q); while (err < lastErr && err > Kernel.STANDARD_PRECISION) { double px, py; double qx, qy; px = p1.evalDiffXPolyAt(x, y); py = p1.evalDiffYPolyAt(x, y); if (p2 != null) { qx = p2.evalDiffXPolyAt(x, y); qy = p2.evalDiffYPolyAt(x, y); } else { qx = line[1]; qy = line[2]; } double det = px * qy - py * qx; if (Kernel.isZero(det)) { break; } x -= (p * qy - q * py) / det; y -= (q * px - p * qx) / det; lastErr = err; p = p1.evalPolyAt(x, y); if (p2 != null) { q = p2.evalPolyAt(x, y); } else { q = line[0] + x * line[1] + y * line[2]; } err = Math.abs(p) + Math.abs(q); } pair[0] = x; pair[1] = y; return err < Kernel.STANDARD_PRECISION; }
From source file:com.l2jfree.gameserver.instancemanager.FortManager.java
public final int findNearestFortIndex(L2Object obj) { int index = getFortIndex(obj); if (index < 0) { double closestDistance = Double.MAX_VALUE; double distance; for (Fort fort : getForts()) { if (fort == null) continue; distance = fort.getDistanceToZone(obj.getX(), obj.getY()); if (closestDistance > distance) { closestDistance = distance; index = getFortIndex(fort.getFortId()); }// ww w . j a v a 2s .c o m } } return index; }