Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

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

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:edu.cmu.tetrad.search.TestHippocampus.java

public void test10() {
    System.out.println(Double.MIN_VALUE);

    //        double beta = 1.3e-10;
    //        double beta = 1e-10;
    //        double beta = 2e-10;

    double beta = 1e-8;
    int numDays = 10;

    int[] _days = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 35, 36, 37, 38, 39,
            40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
            67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 91, 92,
            94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104 };

    String[] names = { "Lsub", "LCA1", "LCA32DG", "Lent", "Lprc", "Lphc", "Rsub", "RCA1", "RCA32DG", "Rent",
            "Rprc", "Rphc" };

    //        for (int numDays : new int[]{3, 4, 5, 6, 8, 9, 10, 15, 20, 25, 30, 40, 50, 60, 70, 84}) {
    //        for (int numDays : new int[]{30}) {
    int numGroups = _days.length / numDays;

    int[] varIndices = { 1, 2, 3, 4, 5, 6 };
    //            int[] varIndices = {1, 2, 3, 4};
    //            int[] varIndices = {7, 8, 9, 10, 11, 12};
    //            int[] varIndices = {1, 2, 3};

    //        int[] varIndices = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

    List<Node> nodes = new ArrayList<Node>();

    for (int i = 0; i < varIndices.length; i++) {
        Node node = new ContinuousVariable(names[varIndices[i] - 1]);
        nodes.add(node);/*from w  ww . j av a  2s.c o m*/
        System.out.println(node);
    }

    Graph complete = new EdgeListGraph(nodes);
    complete.fullyConnect(Endpoint.TAIL);

    List<Edge> completeEdges = complete.getEdges();

    for (Edge edge : new ArrayList<Edge>(completeEdges)) {
        Node n1 = edge.getNode1();
        Node n2 = edge.getNode2();

        if (n1.getName().startsWith("L") && n2.getName().startsWith("R")) {
            completeEdges.remove(edge);
        }
        if (n1.getName().startsWith("R") && n2.getName().startsWith("L")) {
            completeEdges.remove(edge);
        }
    }

    Collections.sort(completeEdges);

    //        Graph ground = getGround(complete);

    //        for (int r = 0; r < numGroups; r++) {
    for (int r = 0; r < 1; r++) {
        int[] days = new int[numDays];

        for (int j = 0; j < numDays; j++) {
            days[j] = _days[r * numDays + j];
        }

        DataReader reader = new DataReader();
        reader.setVariablesSupplied(false);

        try {
            System.out.println();
            System.out.println("# days = " + days.length + "days = " + Arrays.toString(days));

            List<DataSet> datasets = new ArrayList<DataSet>();

            for (int i : varIndices) {
                List<DataSet> d = new ArrayList<DataSet>();

                NumberFormat nf = new DecimalFormat("000");

                for (int j = 0; j < days.length; j++) {
                    DataSet f = reader.parseTabular(
                            new File("/Users/josephramsey/Documents/dropbox_stuff/mtl_data_regions/" + "sub"
                                    + nf.format(days[j]) + "_mtl_" + i + ".txt"));

                    System.out.println(
                            "var " + i + " " + days[j] + " " + f.getNumRows() + " x " + f.getNumColumns());

                    d.add(f);
                }

                DataSet c = DataUtils.concatenateData(d);
                datasets.add(c);
            }

            for (int i = 0; i < datasets.size(); i++) {
                List<Node> _nodes = datasets.get(i).getVariables();
                for (Node node : _nodes) {
                    node.setName((i + 1) + node.getName());
                }
            }

            DataSet data = DataUtils.collectVariables(datasets);

            System.out.println("Total:  " + data.getNumRows() + " x " + data.getNumColumns());

            CovarianceMatrix cov = new CovarianceMatrix(data);

            System.out.println("Calculated cov");

            if (true) {
                Map<Node, List<Integer>> nodeIndices = new HashMap<Node, List<Integer>>();
                int index = 0;

                for (int i = 0; i < varIndices.length; i++) {
                    List<Integer> _indices = new ArrayList<Integer>();

                    for (int j = 0; j < datasets.get(i).getVariables().size(); j++) {
                        _indices.add(index++);
                    }

                    nodeIndices.put(nodes.get(i), _indices);
                }

                Map<Node, List<Node>> nodeMap = new HashMap<Node, List<Node>>();

                for (int i = 0; i < varIndices.length; i++) {
                    nodeMap.put(nodes.get(i), datasets.get(i).getVariables());
                }

                //                    Map<Node, TetradMatrix> coords = new HashMap<Node, TetradMatrix>();
                //                    List<TetradMatrix> _coords = new ArrayList<TetradMatrix>();
                //
                //                    for (int i = 0; i < varIndices.length; i++) {
                //                        coords.put(nodes.get(i), loadCoords(i));
                //                        _coords.add(loadCoords(i));
                //                    }

                GesMulti ges = new GesMulti(nodeMap, cov);
                ges.setPenaltyDiscount(0.01);

                Graph graph = ges.search();

                System.out.println(graph);

            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.eclipse.dataset.AbstractDataset.java

/**
 * Calculate minimum and maximum for a dataset
 * @param ignoreNaNs if true, ignore NaNs
 * @param ignoreInfs if true, ignore infinities
 *///from  w ww.  ja  va2s  .c  o  m
protected void calculateMaxMin(final boolean ignoreNaNs, final boolean ignoreInfs) {
    IndexIterator iter = getIterator();
    double amax = Double.NEGATIVE_INFINITY;
    double amin = Double.POSITIVE_INFINITY;
    double pmax = Double.MIN_VALUE;
    double pmin = Double.POSITIVE_INFINITY;
    double hash = 0;
    boolean hasNaNs = false;

    while (iter.hasNext()) {
        final double val = getElementDoubleAbs(iter.index);
        if (Double.isNaN(val)) {
            hash = (hash * 19) % Integer.MAX_VALUE;
            if (ignoreNaNs)
                continue;
            hasNaNs = true;
        } else if (Double.isInfinite(val)) {
            hash = (hash * 19) % Integer.MAX_VALUE;
            if (ignoreInfs)
                continue;
        } else {
            hash = (hash * 19 + val) % Integer.MAX_VALUE;
        }

        if (val > amax) {
            amax = val;
        }
        if (val < amin) {
            amin = val;
        }
        if (val > 0) {
            if (val < pmin) {
                pmin = val;
            }
            if (val > pmax) {
                pmax = val;
            }
        }
    }

    int ihash = ((int) hash) * 19 + getDtype() * 17 + getElementsPerItem();
    setStoredValue(storeName(ignoreNaNs, ignoreInfs, STORE_SHAPELESS_HASH), ihash);
    storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_MAX),
            hasNaNs ? Double.NaN : fromDoubleToNumber(amax));
    storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_MIN),
            hasNaNs ? Double.NaN : fromDoubleToNumber(amin));
    storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_POS_MAX),
            hasNaNs ? Double.NaN : fromDoubleToNumber(pmax));
    storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_POS_MIN),
            hasNaNs ? Double.NaN : fromDoubleToNumber(pmin));
}

From source file:org.eclipse.dataset.AbstractDataset.java

/**
 * Calculate summary statistics for a dataset
 * @param ignoreNaNs if true, ignore NaNs
 * @param ignoreInfs if true, ignore infinities
 * @param name//w  ww .j a v  a2s .  co  m
 */
protected void calculateSummaryStats(final boolean ignoreNaNs, final boolean ignoreInfs, final String name) {
    final IndexIterator iter = getIterator();
    final SummaryStatistics stats = new SummaryStatistics();

    if (storedValues == null || !storedValues.containsKey(STORE_HASH)) {
        boolean hasNaNs = false;
        double hash = 0;
        double pmax = Double.MIN_VALUE;
        double pmin = Double.POSITIVE_INFINITY;

        while (iter.hasNext()) {
            final double val = getElementDoubleAbs(iter.index);
            if (Double.isNaN(val)) {
                hash = (hash * 19) % Integer.MAX_VALUE;
                if (ignoreNaNs)
                    continue;
                hasNaNs = true;
            } else if (Double.isInfinite(val)) {
                hash = (hash * 19) % Integer.MAX_VALUE;
                if (ignoreInfs)
                    continue;
            } else {
                hash = (hash * 19 + val) % Integer.MAX_VALUE;
            }
            if (val > 0) {
                if (val < pmin) {
                    pmin = val;
                }
                if (val > pmax) {
                    pmax = val;
                }
            }
            stats.addValue(val);
        }

        int ihash = ((int) hash) * 19 + getDtype() * 17 + getElementsPerItem();
        setStoredValue(storeName(ignoreNaNs, ignoreInfs, STORE_SHAPELESS_HASH), ihash);
        storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_MAX),
                hasNaNs ? Double.NaN : fromDoubleToNumber(stats.getMax()));
        storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_MIN),
                hasNaNs ? Double.NaN : fromDoubleToNumber(stats.getMin()));
        storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_POS_MAX),
                hasNaNs ? Double.NaN : fromDoubleToNumber(pmax));
        storedValues.put(storeName(ignoreNaNs, ignoreInfs, STORE_POS_MIN),
                hasNaNs ? Double.NaN : fromDoubleToNumber(pmin));
        storedValues.put(name, stats);
    } else {
        while (iter.hasNext()) {
            final double val = getElementDoubleAbs(iter.index);
            if (ignoreNaNs && Double.isNaN(val)) {
                continue;
            }
            if (ignoreInfs && Double.isInfinite(val)) {
                continue;
            }

            stats.addValue(val);
        }

        storedValues.put(name, stats);
    }
}

From source file:edu.ku.brc.specify.web.SpecifyExplorer.java

/**
 * @param out//from   w  w  w  . j  a v  a 2s .  co m
 * @param pointsStr
 * @param sortByCE
 */
protected void createMap(final PrintWriter out, final String pointsStr, final boolean sortByCE) {
    DataProviderSessionIFace session = null;
    try {
        session = DataProviderFactory.getInstance().createSession();

        String mapTemplate = "";
        try {
            File templateFile = new File(
                    UIRegistry.getDefaultWorkingPath() + File.separator + "site/map_template.html");
            mapTemplate = FileUtils.readFileToString(templateFile);

        } catch (IOException ex) {
            ex.printStackTrace();
            out.println(ex.toString());
        }

        if (StringUtils.isEmpty(template)) {
            out.println("The template file is empty!");
        }

        int inx = mapTemplate.indexOf(contentTag);
        String subContent = mapTemplate.substring(0, inx);
        out.println(StringUtils.replace(subContent, "<!-- Title -->", "Mapping Collection Objects"));

        String[] points = StringUtils.splitPreserveAllTokens(pointsStr, ';');
        /*System.out.println("["+pointsStr+"]");
        for (int i=0;i<points.length;i++)
        {
        System.out.println("i["+i+"]Loc["+points[i]+"] CO["+points[i+1]+"]");
        i++;
        }*/

        double maxLat = Double.MIN_VALUE;
        double minLat = Double.MAX_VALUE;

        double maxLon = Double.MIN_VALUE;
        double minLon = Double.MAX_VALUE;

        //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        Hashtable<Locality, CollectingEvent> locToCE = new Hashtable<Locality, CollectingEvent>();

        boolean drawLines = false;

        Hashtable<CollectingEvent, CEForPoly> hash = new Hashtable<CollectingEvent, CEForPoly>();
        StringBuilder locStr = new StringBuilder();

        int locCnt = 0;
        for (int i = 0; i < points.length; i++) {
            //System.out.println("i["+i+"]Loc["+points[i]+"]");
            if (StringUtils.isEmpty(points[i])) {
                break;
            }

            //String title = "";
            Locality locality = (Locality) session.createQuery("from Locality WHERE id = " + points[i], false)
                    .list().get(0);
            if (locality != null) {
                StringBuilder sb = new StringBuilder();
                String[] colObjsIds = StringUtils.splitPreserveAllTokens(points[i + 1], ',');
                for (String id : colObjsIds) {
                    //System.out.println("co["+id+"]");
                    if (StringUtils.isNotEmpty(id)) {
                        CollectionObject co = (CollectionObject) session
                                .createQuery("from CollectionObject WHERE id = " + id, false).list().get(0);
                        if (co != null) {
                            CollectingEvent ce = co.getCollectingEvent();
                            if (ce != null) {
                                CollectingEvent colEv = locToCE.get(locality);
                                if (colEv == null) {
                                    locToCE.put(locality, ce);

                                } else if (!ce.getCollectingEventId().equals(colEv.getCollectingEventId())) {
                                    drawLines = false;
                                }
                                //sb.append("<h3>"+sdf.format(ce.getStartDate().getTime())+"</h3>");
                                Locality loc = ce.getLocality();
                                if (loc != null && loc.getLatitude1() != null && loc.getLongitude1() != null) {
                                    CEForPoly cep = hash.get(ce);
                                    if (cep == null) {
                                        cep = new CEForPoly(ce.getStartDate(), loc.getLatitude1().doubleValue(),
                                                loc.getLongitude1().doubleValue(), "");
                                        hash.put(ce, cep);
                                    }
                                    cep.getColObjs().add(co);
                                }
                            }
                            for (Determination det : co.getDeterminations()) {
                                if (det.isCurrentDet()) {
                                    Taxon txn = det.getPreferredTaxon();
                                    if (txn != null) {
                                        sb.append("<a href='SpecifyExplorer?cls=CollectionObject&id="
                                                + co.getCollectionObjectId() + "'>" + txn.getFullName()
                                                + "</a>");
                                        sb.append("<br/>");
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                if (locality.getLatitude1() != null && locality.getLongitude1() != null) {
                    if (locCnt == 0) {
                        maxLat = locality.getLatitude1().doubleValue();
                        minLat = maxLat;

                        maxLon = locality.getLongitude1().doubleValue();
                        minLon = maxLon;

                    } else {
                        maxLat = Math.max(maxLat, locality.getLatitude1().doubleValue());
                        minLat = Math.min(minLat, locality.getLatitude1().doubleValue());

                        maxLon = Math.max(maxLon, locality.getLongitude1().doubleValue());
                        minLon = Math.min(minLon, locality.getLongitude1().doubleValue());
                    }

                    locStr.append("var point = new GLatLng(" + locality.getLatitude1() + ","
                            + locality.getLongitude1() + ");\n");
                    locStr.append("var marker = createMarker(point,\"" + locality.getLocalityName() + "\",\""
                            + sb.toString() + "\");\n");
                    locStr.append("map.addOverlay(marker);\n");
                    locCnt++;
                }

            }
            i++;
        }

        System.out.println("maxLat: " + maxLat);
        System.out.println("minLat: " + minLat);
        System.out.println("maxLon: " + maxLon);
        System.out.println("minLon: " + minLon);

        double halfLat = (maxLat - minLat) / 2;
        double halfLon = (maxLon - minLon) / 2;
        System.out.println("halfLat: " + halfLat);
        System.out.println("halfLon: " + halfLon);

        int zoom = 2;
        if (halfLat == 0.0 && halfLon == 0.0) {
            zoom = 12;

        } else if (halfLat < 0.5 && halfLon < 0.5) {
            zoom = 10;

        } else if (halfLat < 2.0 && halfLon < 2.0) {
            zoom = 8;

        } else if (halfLat < 7.0 && halfLon < 7.0) {
            zoom = 6;
        }

        out.println("        map.setCenter(new GLatLng( " + (minLat + halfLat) + "," + (minLon + halfLon)
                + "), " + zoom + ");\n");

        out.println(locStr.toString());

        if (drawLines) {
            if (hash.size() > 0) {
                out.println("var polyline = new GPolyline([");
                for (CEForPoly cep : hash.values()) {
                    out.println("new GLatLng(" + cep.getLat() + ", " + cep.getLon() + "),\n");
                }
            }
            out.println("], \"#FF0000\", 5);\n");
            out.println("map.addOverlay(polyline);\n");

        }

        if (false) {
            out.println("var polygon = new GPolygon([");
            for (CEForPoly cep : hash.values()) {
                out.println("new GLatLng(" + cep.getLat() + ", " + cep.getLon() + "),\n");
            }
            out.println("], \"#ff0000\", 5, 0.7, \"#0000ff\", 0.4);\n");
            out.println("map.addOverlay(polygon);\n");
        }

        out.println(mapTemplate.substring(inx + contentTag.length() + 1, mapTemplate.length()));

    } catch (Exception ex) {
        ex.printStackTrace();

    } finally {
        if (session != null) {
            session.close();
        }
    }
}

From source file:com.aurel.track.exchange.excel.ExcelImportBL.java

/**
 * Gets the string value of a cell//from  w w w.  j  a va2s .c  o m
 * 
 * @param cell
 * @return
 */
static String getStringCellValue(Cell cell) {
    try {
        int cellType = cell.getCellType();
        switch (cellType) {
        case Cell.CELL_TYPE_BLANK:
            return "";
        case Cell.CELL_TYPE_BOOLEAN:
            return String.valueOf(cell.getBooleanCellValue());
        case Cell.CELL_TYPE_ERROR:
            return String.valueOf(cell.getErrorCellValue());
        case Cell.CELL_TYPE_FORMULA:
            return cell.getCellFormula();
        case Cell.CELL_TYPE_NUMERIC:
            try {
                double doubleValue = cell.getNumericCellValue();
                int intValue = (int) doubleValue;
                double fracPart = doubleValue - intValue;
                if (Math.abs(fracPart) <= Double.MIN_VALUE) {
                    return String.valueOf(intValue);
                } else {
                    return String.valueOf(doubleValue);
                }
            } catch (Exception e) {
            }
        case Cell.CELL_TYPE_STRING:
            RichTextString richTextString = cell.getRichStringCellValue();
            if (richTextString != null) {
                return richTextString.getString();
            }
        }
    } catch (Exception e) {
        LOGGER.debug("Getting the string value failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    return "";
}

From source file:ffx.algorithms.RotamerOptimization.java

private boolean minMaxPairEnergy(Residue[] residues, double minMax[], int i, int ri, int j) {
    Residue residuej = residues[j];//  w w  w  .j av  a  2 s  .  co m
    Rotamer rotamersj[] = residuej.getRotamers(library);
    int lenrj = rotamersj.length;
    boolean valid = false;
    minMax[0] = Double.MAX_VALUE;
    minMax[1] = Double.MIN_VALUE;

    // Loop over the third residues' rotamers.
    for (int rj = 0; rj < lenrj; rj++) {
        // Check for an eliminated single or eliminated pair.
        if (check(i, ri) || check(j, rj) || check(i, ri, j, rj)) {
            continue;
        }
        double current = pair(i, ri, j, rj);
        if (threeBodyTerm) {
            double minMaxTriple[] = new double[2];
            // Loop over residue k to find the min/max triple energy.
            boolean validPair = minMax2BodySum(residues, minMaxTriple, i, ri, j, rj);
            if (!validPair) {
                // Eliminate Rotamer Pair
                Residue residuei = residues[i];
                logger.info(String.format(" Inconsistent Pair: %s %d, %s %d.", residuei, ri, residuej, rj));
                /*
                 eliminatedPairs[i][ri][j][rj] = true;
                 eliminateRotamerTriples(residues, i, ri, j, rj);
                 */
                continue;
            }
        }
        valid = true;
        if (current < minMax[0]) {
            minMax[0] = current;
        }
        if (current > minMax[1]) {
            minMax[1] = current;
        }
    }
    return valid;
}

From source file:ffx.algorithms.RotamerOptimization.java

private boolean minMaxTripleEnergy(Residue[] residues, double minMax[], int i, int ri, int j, int rj, int k) {
    Residue residuek = residues[k];/*w w  w .  j a  va  2s  .c o m*/
    Rotamer[] romatersk = residuek.getRotamers(library);
    int lenrk = romatersk.length;
    boolean valid = false;
    minMax[0] = Double.MAX_VALUE;
    minMax[1] = Double.MIN_VALUE;
    // Loop over the third residues' rotamers.
    for (int rk = 0; rk < lenrk; rk++) {
        // Check for an eliminated single or eliminated pair.
        if (check(k, rk) || check(i, ri, k, rk) || check(j, rj, k, rk)) {
            continue;
        }
        valid = true;
        double current = pair(i, ri, k, rk) + pair(j, rj, k, rk);
        if (threeBodyTerm) {
            current += triple(i, ri, j, rj, k, rk);
            double minMaxTriple[] = new double[2];
            /**
             * Loop over residue l to sum the min/max triple energy returns
             * Sum_l [ min_rl [E_3(i,ri,k,rk,l,rl) + E_3(j,rj,k,rk,l,rl)]]
             */
            boolean valid3Body = minMax3BodySum(residues, minMaxTriple, i, ri, j, rj, k, rk);
            if (!valid3Body) {
                // Eliminate Rotamer Pair
                //                    Residue residuei = residues[i];
                //                    logger.info(String.format(" Eliminating Inconsistent Pair: %s %d, %s %d.",
                //                            residuei, ri, residuek, rk));
                //                    eliminatedPairs[i][ri][k][rk] = true;
                //                    eliminateRotamerTriples(residues, i, ri, k, rk);
                continue;
            }
            double currentMin = current + minMaxTriple[0];
            double currentMax = current + minMaxTriple[1];

            if (currentMin < minMax[0]) {
                minMax[0] = currentMin;
            }
            if (currentMax > minMax[1]) {
                minMax[1] = currentMax;
            }
        } else {
            if (current < minMax[0]) {
                minMax[0] = current;
            }
            if (current > minMax[1]) {
                minMax[1] = current;
            }
        }
    }
    return valid;
}

From source file:ffx.algorithms.RotamerOptimization.java

/**
 * Find the min/max of the 2-body energy.
 *
 * @param residues The residue array.//from  ww w  .jav a2 s .  c  o m
 * @param minMax The bound on the 3-body energy (minMax[0] = min, minMax[1]
 * = max.
 * @param i Residue i
 * @param ri Rotamer ri of Residue i
 * @param j Residue j
 * @param rj Rotamer rj of Residue j
 * @param k Residue k
 *
 * @return true if this term is valid.
 */
private boolean minMax2BodySum(Residue[] residues, double minMax[], int i, int ri, int j, int rj) {
    int nres = residues.length;
    double minSum = 0.0;
    double maxSum = 0.0;
    for (int k = 0; k < nres; k++) {
        if (k == i || k == j) {
            continue;
        }
        Residue residuek = residues[k];
        Rotamer[] romatersk = residuek.getRotamers(library);
        int lenrk = romatersk.length;
        double currentMin = Double.MAX_VALUE;
        double currentMax = Double.MIN_VALUE;
        // Loop over the third residues' rotamers.
        boolean valid = false;
        for (int rk = 0; rk < lenrk; rk++) {
            // Check for an eliminated triple.
            if (check(i, ri, j, rj, k, rk)) {
                continue;
            }
            valid = true;
            double current = triple(i, ri, j, rj, k, rk);
            if (current < currentMin) {
                currentMin = current;
            }
            if (current > currentMax) {
                currentMax = current;
            }
        }
        // Must find at least 1 valid rotamer.
        if (!valid) {
            return false;
        }
        minSum += currentMin;
        maxSum += currentMax;
    }
    minMax[0] = minSum;
    minMax[1] = maxSum;
    return true;
}

From source file:ffx.algorithms.RotamerOptimization.java

/**
 * Find the min/max of the 3-body energy.
 *
 * @param residues The residue array.//from  w ww. java2  s  .c o  m
 * @param minMax The bound on the 3-body energy (minMax[0] = min, minMax[1]
 * = max.
 * @param i Residue i
 * @param ri Rotamer ri of Residue i
 * @param j Residue j
 * @param rj Rotamer rj of Residue j
 * @param k Residue k
 * @return true if this term is valid.
 */
private boolean minMax3BodySum(Residue[] residues, double minMax[], int i, int ri, int j, int rj, int k,
        int rk) {
    int nres = residues.length;
    double minSum = 0.0;
    double maxSum = 0.0;
    for (int l = 0; l < nres; l++) {
        if (l == i || l == j || l == k) {
            continue;
        }
        Residue residuel = residues[l];
        Rotamer[] romatersl = residuel.getRotamers(library);
        int lenrl = romatersl.length;
        double currentMin = Double.MAX_VALUE;
        double currentMax = Double.MIN_VALUE;
        // Loop over the third residues' rotamers.
        boolean valid = false;
        for (int rl = 0; rl < lenrl; rl++) {
            // Check for an eliminated triple.
            if (check(i, ri, k, rk, l, rl) || check(j, rj, k, rk, l, rl)) {
                continue;
            }
            valid = true;
            // Collect the 3-body energies and 4-body energy (TODO - returns 0.0 now)
            double current = triple(i, ri, k, rk, l, rl) + triple(j, rj, k, rk, l, rl)
                    + quad(i, ri, j, rj, k, rk, l, rl);
            if (current < currentMin) {
                currentMin = current;
            }
            if (current > currentMax) {
                currentMax = current;
            }
        }
        // Must find at least 1 valid rotamer.
        if (!valid) {
            return false;
        }
        minSum += currentMin;
        maxSum += currentMax;
    }
    minMax[0] = minSum;
    minMax[1] = maxSum;
    return true;
}