Example usage for java.lang Double POSITIVE_INFINITY

List of usage examples for java.lang Double POSITIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Double POSITIVE_INFINITY.

Prototype

double POSITIVE_INFINITY

To view the source code for java.lang Double POSITIVE_INFINITY.

Click Source Link

Document

A constant holding the positive infinity of type double .

Usage

From source file:org.jfree.data.general.DefaultHeatMapDatasetTest.java

/**
 * Some tests for the equals() method./*from   w ww  . jav a2s.  c o m*/
 */
@Test
public void testEquals() {
    DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0);
    DefaultHeatMapDataset d2 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, 3.0, 4.0);
    assertEquals(d1, d2);

    d1 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0);
    assertTrue(d1.equals(d2));

    d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0);
    assertFalse(d1.equals(d2));
    d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0);
    assertTrue(d1.equals(d2));

    d1.setZValue(1, 2, 3.0);
    assertFalse(d1.equals(d2));
    d2.setZValue(1, 2, 3.0);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 0, Double.NEGATIVE_INFINITY);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 0, Double.NEGATIVE_INFINITY);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 1, Double.POSITIVE_INFINITY);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 1, Double.POSITIVE_INFINITY);
    assertTrue(d1.equals(d2));

    d1.setZValue(0, 2, Double.NaN);
    assertFalse(d1.equals(d2));
    d2.setZValue(0, 2, Double.NaN);
    assertTrue(d1.equals(d2));
}

From source file:it.units.malelab.ege.core.listener.PropertiesListener.java

@Override
public void listen(EvolutionEvent<G, T, F> event) {
    synchronized (this) {
        if (resetData) {
            resetData = false;//w ww .j a v  a  2 s  .co m
            //reset data
            counts.get(NO_OPERATOR).clear();
            for (String operatorName : operatorNames.values()) {
                counts.get(operatorName).clear();
                partialDistances.get(operatorName).clear();
            }
        }
    }
    if (event instanceof MappingEvent) {
        MappingEvent<G, T, F> mappingEvent = (MappingEvent<G, T, F>) event;
        counts.get(NO_OPERATOR).add(CountType.MAPPING);
        if (Node.EMPTY_TREE.equals(mappingEvent.getPhenotype())) {
            counts.get(NO_OPERATOR).add(CountType.INVALID);
        }
    }
    if (event instanceof OperatorApplicationEvent) {
        OperatorApplicationEvent<G, T, F> operatorApplicationEvent = (OperatorApplicationEvent<G, T, F>) event;
        String operatorName = getOperatorName(operatorApplicationEvent.getOperator());
        if (operatorName != null) {
            counts.get(operatorName).add(CountType.OPERATOR_APPLICATION);
            boolean differentPhenotype = false;
            boolean differentGenotype = false;
            boolean allInvalid = true;
            //compute distances
            for (Individual<G, T, F> child : operatorApplicationEvent.getChildren()) {
                if (Node.EMPTY_TREE.equals(child.getPhenotype())) {
                    continue;
                }
                double minGenotypeDistance = Double.POSITIVE_INFINITY;
                double minPhenotypeDistance = Double.POSITIVE_INFINITY;
                for (Individual<G, T, F> parent : operatorApplicationEvent.getParents()) {
                    if (Node.EMPTY_TREE.equals(parent.getPhenotype())) {
                        continue;
                    }
                    allInvalid = false;
                    double localGenotypeDistance = genotypeDistance.d(parent.getGenotype(),
                            child.getGenotype());
                    if (minGenotypeDistance > localGenotypeDistance) {
                        minGenotypeDistance = localGenotypeDistance;
                    }
                    double localPhenotypeDistance = phenotypeDistance.d(parent.getPhenotype(),
                            child.getPhenotype());
                    if (minPhenotypeDistance > localPhenotypeDistance) {
                        minPhenotypeDistance = localPhenotypeDistance;
                    }
                }
                //add sample for locality
                if (minPhenotypeDistance < Double.POSITIVE_INFINITY) {
                    partialDistances.get(operatorName)
                            .add(new Pair<>(minGenotypeDistance, minPhenotypeDistance));
                    cumulativeDistances.get(operatorName)
                            .add(new Pair<>(minGenotypeDistance, minPhenotypeDistance));
                }
                //check difference
                differentGenotype = differentGenotype || (minGenotypeDistance > 0);
                differentPhenotype = differentPhenotype || (minPhenotypeDistance > 0);
            }
            //check redundancy
            if (!allInvalid) {
                counts.get(operatorName).add(CountType.VALID_OPERATOR_APPLICATION);
                if (differentGenotype && !differentPhenotype) {
                    counts.get(operatorName).add(CountType.REDUNDANT);
                }
            }
            //compute best fitnesses
            F bestParentFitness = null;
            for (Individual<G, T, F> parent : operatorApplicationEvent.getParents()) {
                if ((bestParentFitness == null)
                        || (fitnessComparator.compare(parent.getFitness(), bestParentFitness) < 0)) {
                    bestParentFitness = parent.getFitness();
                }
            }
            F bestChildFitness = null;
            for (Individual<G, T, F> child : operatorApplicationEvent.getChildren()) {
                if ((bestChildFitness == null)
                        || (fitnessComparator.compare(child.getFitness(), bestChildFitness) < 0)) {
                    bestChildFitness = child.getFitness();
                }
            }
            //check evolvability
            if (fitnessComparator.compare(bestChildFitness, bestParentFitness) < 0) {
                counts.get(operatorName).add(CountType.BETTER_FITNESS);
            }
        }
    }
}

From source file:com.rapidminer.gui.plotter.charts.ParallelPlotter2.java

private void prepareData() {
    this.dataset = new XYSeriesCollection();

    // calculate min and max
    int columns = this.dataTable.getNumberOfColumns();
    double[] min = new double[columns];
    double[] max = new double[columns];
    if (isLocalNormalized()) {
        for (int c = 0; c < columns; c++) {
            min[c] = Double.POSITIVE_INFINITY;
            max[c] = Double.NEGATIVE_INFINITY;
        }//ww w  . j  a v  a  2s.  c o  m

        synchronized (dataTable) {
            Iterator<DataTableRow> i = dataTable.iterator();
            while (i.hasNext()) {
                DataTableRow row = i.next();
                for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
                    double value = row.getValue(c);
                    min[c] = MathFunctions.robustMin(min[c], value);
                    max[c] = MathFunctions.robustMax(max[c], value);
                }
            }
        }
    }

    this.domainAxisMap = null;
    synchronized (dataTable) {
        this.colorMap = new double[dataTable.getNumberOfRows()];

        Iterator<DataTableRow> i = this.dataTable.iterator();
        int idCounter = 0;

        while (i.hasNext()) {
            DataTableRow row = i.next();
            String id = row.getId();
            if (id == null) {
                id = (idCounter + 1) + "";
            }

            XYSeries series = new XYSeries(id, false, false);
            int counter = 0;
            for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
                if ((!dataTable.isSpecial(column)) && (column != colorColumn)) {
                    double value = row.getValue(column);
                    if (isLocalNormalized()) {
                        value = (value - min[column]) / (max[column] - min[column]);
                    }
                    series.add(counter, value);
                    counter++;
                }
            }

            if (colorColumn >= 0) {
                this.colorMap[idCounter] = row.getValue(colorColumn);
            }

            this.dataset.addSeries(series);
            idCounter++;
        }
    }

    if (domainAxisMap == null) {
        List<String> domainValues = new LinkedList<>();
        for (int column = 0; column < dataTable.getNumberOfColumns(); column++) {
            if ((!dataTable.isSpecial(column)) && (column != colorColumn)) {
                domainValues.add(dataTable.getColumnName(column));
            }
        }
        this.domainAxisMap = new String[domainValues.size()];
        domainValues.toArray(this.domainAxisMap);
    }
}

From source file:edu.umd.cs.psl.model.kernel.setdefinition.GroundSetDefinition.java

@Override
public double getIncompatibility() {
    assert setAtom.getNumberOfValues() == 1;
    if (NumericUtilities.equals(setAtom.getSoftValue(0), getAggregateValue())) {
        return 0.0;
    } else/*from w w  w . ja va  2s  .  co  m*/
        return Double.POSITIVE_INFINITY;
}

From source file:Navigation.Vertex.java

public static ArrayList<Point2D.Double> getMyDijkstra(Map<Point2D.Double, List<Point2D.Double>> adjacencyMatrix,
        Point2D.Double start, Point2D.Double end, Log log) {

    //      log.info("start: " + start.toString());
    //      end = new Point2D.Double(1.3595287799835205, 2.2231287956237793);
    //      log.info("END: " + end.toString());

    Iterator<Entry<Point2D.Double, List<Point2D.Double>>> it = adjacencyMatrix.entrySet().iterator();
    List<Vertex> vertices = new ArrayList<Vertex>();
    while (it.hasNext()) {
        Map.Entry<Point2D.Double, List<Point2D.Double>> pairs = it.next();
        Point2D.Double point1 = pairs.getKey();
        vertices.add(new Vertex(point1));

        //         log.info("added new vertex for " + point1.toString());
    }/*from  w  w w  . ja va  2s.c  o  m*/

    Iterator<Entry<Point2D.Double, List<Point2D.Double>>> pit = adjacencyMatrix.entrySet().iterator();
    while (pit.hasNext()) {
        Map.Entry<Point2D.Double, List<Point2D.Double>> pairs = pit.next();
        Point2D.Double point1 = pairs.getKey();
        Vertex v1 = findVertex(vertices, point1);

        for (Point2D.Double point2 : pairs.getValue()) {
            double cost = Math.sqrt(
                    Math.pow(Math.abs(point1.x - point2.x), 2) + Math.pow(Math.abs(point1.y - point2.y), 2));

            Vertex v2 = findVertex(vertices, point2);
            v1.adjacencies.add(new Edge(v2, cost));
            v2.adjacencies.add(new Edge(v1, cost));
        }
    }

    log.info("looking for start vertex " + start);
    DijkstraGood.computePaths(findVertex(vertices, start));
    //      for (Vertex v : vertices) {
    //         List<Edge> edges = v.adjacencies;
    //         String s = v + " {";
    //         for (Edge e : edges) {
    //            s += e.target.toString() + ", ";
    //         }
    //         log.info(s);

    //         log.info("Distance to " + v + ": " + v.minDistance);
    //         List<Vertex> path = DijkstraGood.getShortestPathTo(v);
    //         log.info("Path: " + path);
    //      }
    Vertex endV = findVertex(vertices, end);
    List<Vertex> path = DijkstraGood.getShortestPathTo(endV);
    ArrayList<Point2D.Double> fin = new ArrayList<Point2D.Double>();
    for (Vertex v : path) {
        if (v.minDistance == Double.POSITIVE_INFINITY) {
            return null;
        }
        fin.add(v.myPoint);
        log.info("FINAL PATH TO " + v.myPoint);
    }
    return fin;
}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.NetworkLikelihoodFromGTTBL.java

private void initializeNetwork(Network<Object> speciesNetwork, Map<NetNode, Double> node2constraints,
        Map<NetNode<Object>, Double> node2height) {
    Map<NetNode, Integer> node2depth = new Hashtable<NetNode, Integer>();
    Map<NetNode, Integer> node2ID = new Hashtable<NetNode, Integer>();
    int id = 0;// ww  w.  j  a  va 2 s .  c om

    for (NetNode<Object> node : Networks.postTraversal(speciesNetwork)) {
        node2ID.put(node, id++);
        if (node.isLeaf()) {
            node2height.put(node, 0.0);
            node2depth.put(node, 0);
            continue;
        }
        double upperBound = -1;
        if (node2constraints.get(node) != Double.POSITIVE_INFINITY) {
            upperBound = node2constraints.get(node);
        }
        node2height.put(node, upperBound);
        int maxDepth = 0;
        for (NetNode child : node.getChildren()) {
            maxDepth = Math.max(maxDepth, node2depth.get(child));
        }
        node2depth.put(node, maxDepth + 1);
    }
    boolean updated;
    do {
        updated = false;
        for (NetNode<Object> node : speciesNetwork.bfs()) {
            double minParentHeight = Double.MAX_VALUE;
            for (NetNode<Object> parent : node.getParents()) {
                double parentHeight = node2height.get(parent);
                if (parentHeight > 0) {
                    minParentHeight = Math.min(minParentHeight, parentHeight);
                }
            }
            if (node2height.get(node) > minParentHeight) {
                node2height.put(node, minParentHeight);
                updated = true;
            }
        }

    } while (updated);

    boolean[][] M = computeM(speciesNetwork, node2ID);

    for (NetNode<Object> node : Networks.postTraversal(speciesNetwork)) {
        int nodeID = node2ID.get(node);
        double minParent = Double.MAX_VALUE;
        int maxParentDepth = 0;
        double maxChild = 0;
        for (NetNode<Object> relateNode : edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
                .postTraversal(speciesNetwork)) {
            int relateNodeID = node2ID.get(relateNode);
            if (M[relateNodeID][nodeID]) {
                double parentHeight = node2height.get(relateNode);
                if (parentHeight >= 0) {
                    if (minParent > parentHeight) {
                        minParent = parentHeight;
                        maxParentDepth = node2depth.get(relateNode);
                    } else if (minParent == parentHeight) {
                        maxParentDepth = Math.max(maxParentDepth, node2depth.get(relateNode));
                    }
                }
            } else if (M[nodeID][relateNodeID]) {
                double childHeight = node2height.get(relateNode);
                if (childHeight >= 0) {
                    maxChild = Math.max(maxChild, childHeight);
                } else {
                    throw new RuntimeException();
                }
            }
        }
        double currentHeight = node2height.get(node);
        if (currentHeight >= minParent || (currentHeight == -1 && minParent != Double.MAX_VALUE)) {
            int depthDiff = maxParentDepth - node2depth.get(node) + 1;
            currentHeight = maxChild + (minParent - maxChild) / depthDiff;
            //currentHeight = Math.round((maxChild + (minParent - maxChild)/depthDiff)*1000000)/1000000.0;
            node2height.put(node, currentHeight);
        } else if (currentHeight == -1 && minParent == Double.MAX_VALUE) {
            currentHeight = maxChild + 1;
            node2height.put(node, currentHeight);
        }
    }

    double overallMin = 0;

    for (NetNode<Object> node : edu.rice.cs.bioinfo.programs.phylonet.structs.network.util.Networks
            .postTraversal(speciesNetwork)) {
        if (node.isLeaf())
            continue;
        double updatedHeight = node2height.get(node) - overallMin;
        double maxChild = 0;
        for (NetNode child : node.getChildren()) {
            maxChild = Math.max(maxChild, node2height.get(child));
        }
        if (updatedHeight == maxChild) {
            updatedHeight = maxChild + overallMin;
        }
        node2height.put(node, updatedHeight);
        for (NetNode child : node.getChildren()) {
            child.setParentDistance(node, updatedHeight - node2height.get(child));
            if (child.isNetworkNode()) {
                child.setParentProbability(node, 0.5);
            }
        }
    }

    //System.out.println(speciesNetwork);

    for (NetNode<Object> node : speciesNetwork.bfs()) {
        double height = node2height.get(node);
        if (height < 0) {
            throw new RuntimeException();
        }
        for (NetNode child : node.getChildren()) {
            if (height < node2height.get(child)) {
                throw new RuntimeException();
            }
        }
    }

}

From source file:mase.spec.SafeHybridExchanger.java

private double fitnessDifference(MetaPopulation reference, MetaPopulation other, EvolutionState state) {
    // search foreign of reference in other
    Foreign f = null;/*from   w  w  w. j  av  a2  s.c  o  m*/
    for (Foreign fOther : other.foreigns) {
        if (fOther.origin == reference) {
            f = fOther;
            break;
        }
    }
    if (f == null || f.inds == null) {
        return Double.POSITIVE_INFINITY;
    }

    // pick individuals from the reference population, using the same method used to pick the foreign individuals
    Individual[] refInds = pickIndividuals(reference.inds, f.inds.length, foreignMode, state);

    if (differenceMode == DifferenceMode.mean) {
        double refFit = 0;
        for (Individual i : refInds) {
            refFit += i.fitness.fitness();
        }
        double foreignFit = 0;
        for (Individual i : f.inds) {
            foreignFit += i.fitness.fitness();
        }
        return refFit == 0 ? Double.POSITIVE_INFINITY : Math.abs(refFit - foreignFit) / Math.abs(refFit);
    } else if (differenceMode == DifferenceMode.max) {
        double refFit = Double.NEGATIVE_INFINITY;
        for (Individual i : refInds) {
            refFit = Math.max(refFit, i.fitness.fitness());
        }
        double foreignFit = Double.NEGATIVE_INFINITY;
        for (Individual i : f.inds) {
            foreignFit = Math.max(foreignFit, i.fitness.fitness());
        }
        return refFit == 0 ? Double.POSITIVE_INFINITY : Math.abs(refFit - foreignFit) / Math.abs(refFit);
    } else if (differenceMode == DifferenceMode.utest) {
        double[] refFits = new double[refInds.length];
        double[] forFits = new double[f.inds.length];
        for (int i = 0; i < refFits.length; i++) {
            refFits[i] = refInds[i].fitness.fitness();
        }
        for (int i = 0; i < forFits.length; i++) {
            forFits[i] = f.inds[i].fitness.fitness();
        }
        MannWhitneyUTest test = new MannWhitneyUTest();
        return test.mannWhitneyU(refFits, forFits) / (refFits.length * forFits.length);
    } else {
        return Double.NaN;
    }
}

From source file:com.rapidminer.operator.preprocessing.filter.InfiniteValueReplenishment.java

/**
 * Replaces the values//from ww w .j av a 2s .  c o  m
 *
 * @throws UndefinedParameterError
 */
@Override
public double getReplenishmentValue(int functionIndex, ExampleSet exampleSet, Attribute attribute)
        throws UndefinedParameterError {
    int chosen = getParameterAsInt(PARAMETER_REPLENISHMENT_WHAT);
    switch (functionIndex) {
    case NONE:
        return Double.POSITIVE_INFINITY;
    case ZERO:
        return 0.0;
    case MAX_BYTE:
        return (chosen == 0) ? Byte.MAX_VALUE : Byte.MIN_VALUE;
    case MAX_INT:
        return (chosen == 0) ? Integer.MAX_VALUE : Integer.MIN_VALUE;
    case MAX_DOUBLE:
        return (chosen == 0) ? Double.MAX_VALUE : -Double.MAX_VALUE;
    case MISSING:
        return Double.NaN;
    case VALUE:
        return getParameterAsDouble(PARAMETER_REPLENISHMENT_VALUE);
    default:
        throw new RuntimeException("Illegal value functionIndex: " + functionIndex);
    }
}

From source file:de.tudarmstadt.lt.ltbot.postprocessor.DecesiveLoggerTest.java

@Test
public void b_content6() throws InterruptedException, JSONException, IOException {
    System.out.println("10");
    curi.getExtraInfo().put(SharedConstants.EXTRA_INFO_PERPLEXITY,
            String.format("%012g", Double.POSITIVE_INFINITY));
    l.process(curi);//from  w  w w . j ava2 s  . com
    checkContentLastLine(true);
}

From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCXYItemRenderer.java

/**
 * create a wrapped renderer/*from  w  ww  .  j  a  va2s .c  o  m*/
 *
 * @param out
 *          the output renderer
 */
_JFCXYItemRenderer(final XYItemRenderer out) {
    this.m_out = out;
    // this.m_maxX = Double.MAX_VALUE;
    // this.m_maxY = Double.MAX_VALUE;
    // this.m_minX = Double.NEGATIVE_INFINITY;
    // this.m_minY = Double.NEGATIVE_INFINITY;

    this.m_maxX = Double.NEGATIVE_INFINITY;
    this.m_maxY = Double.NEGATIVE_INFINITY;
    this.m_minX = Double.POSITIVE_INFINITY;
    this.m_minY = Double.POSITIVE_INFINITY;

    // this.m_src = new double[8];
    // this.m_dst = new double[8];
}