Example usage for java.lang Double MAX_VALUE

List of usage examples for java.lang Double MAX_VALUE

Introduction

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

Prototype

double MAX_VALUE

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

Click Source Link

Document

A constant holding the largest positive finite value of type double , (2-2-52)·21023.

Usage

From source file:com.netflix.priam.aws.S3FileSystem.java

@Inject
public S3FileSystem(Provider<AbstractBackupPath> pathProvider, ICompression compress,
        final IConfiguration config, ICredential cred) {
    this.pathProvider = pathProvider;
    this.compress = compress;
    this.config = config;
    int threads = config.getMaxBackupUploadThreads();
    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(threads);
    this.executor = new BlockingSubmitThreadPoolExecutor(threads, queue, UPLOAD_TIMEOUT);
    double throttleLimit = config.getUploadThrottle();
    rateLimiter = RateLimiter.create(throttleLimit < 1 ? Double.MAX_VALUE : throttleLimit);

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    String mbeanName = MBEAN_NAME;
    try {/*  ww  w  .  j  a va  2s  .com*/
        mbs.registerMBean(this, new ObjectName(mbeanName));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    s3Client = new AmazonS3Client(cred.getAwsCredentialProvider());
    s3Client.setEndpoint(getS3Endpoint());
}

From source file:edu.utexas.cs.tactex.tariffoptimization.OptimizerWrapperGradientAscent.java

@Override
public TreeMap<Double, TariffSpecification> findOptimum(TariffUtilityEstimate tariffUtilityEstimate,
        int NUM_RATES, int numEval) {

    double[] startingVertex = new double[NUM_RATES]; // start from the fixed-rate tariff's offset
    Arrays.fill(startingVertex, 0.0);

    // temporary solution - getting fixed rate tariff to determine step size and scaling STEP_SIZE proportionally
    TariffSpecification bestFixedRateSpec = tariffUtilityEstimate.getCorrespondingSpec(startingVertex);
    double bestFixedRate = bestFixedRateSpec.getRates().get(0).getValue();
    double rateRatio = bestFixedRate / REFERENCE_RATE;
    // Note: using rateRatio has not been good enough, so trying powers of it (remember it's > 1)
    //STEP_SIZE = Math.max(REFERENCE_STEP_SIZE, (rateRatio * rateRatio) * REFERENCE_STEP_SIZE);
    STEP_SIZE = Math.max(REFERENCE_STEP_SIZE, Math.abs(rateRatio) * REFERENCE_STEP_SIZE);
    log.debug("STEP_SIZE = " + STEP_SIZE + " REFERENCE_STEP_SIZE=" + REFERENCE_STEP_SIZE + " bestFixedRate="
            + bestFixedRate + " REFERENCE_RATE=" + REFERENCE_RATE);

    evaluations = 0;// www  . j a va 2s  . co m
    TreeMap<Double, TariffSpecification> eval2TOUTariff = new TreeMap<Double, TariffSpecification>();

    // OUTER LOOP
    //for( STEP_SIZE = 0.005; STEP_SIZE < 0.100; STEP_SIZE += 0.005) {
    //  log.info("STARTING A LOOP: STEP_SIZE=" + STEP_SIZE);

    // first compute numerical gradient
    RealVector gradient = new ArrayRealVector(NUM_RATES);
    for (int i = 0; i < NUM_RATES; ++i) {
        gradient.setEntry(i, computePartialDerivative(i, tariffUtilityEstimate, NUM_RATES, eval2TOUTariff));
    }
    gradient = gradient.unitVector();

    // taking steps in the gradient direction
    double previousPointValue = -Double.MAX_VALUE;
    final double alpha = STEP_SIZE;
    RealVector rateOffsets = new ArrayRealVector(NUM_RATES); // initializes with 0s?
    double currentPointValue = evaluatePoint(tariffUtilityEstimate, rateOffsets.toArray());
    eval2TOUTariff.put(currentPointValue, tariffUtilityEstimate.getCorrespondingSpec(rateOffsets.toArray()));
    while (!converged(currentPointValue, previousPointValue) && evaluations < MAX_EVALUATIONS) {
        previousPointValue = currentPointValue;
        rateOffsets = rateOffsets.add(gradient.mapMultiply(alpha));
        currentPointValue = evaluatePoint(tariffUtilityEstimate, rateOffsets.toArray());
        eval2TOUTariff.put(currentPointValue,
                tariffUtilityEstimate.getCorrespondingSpec(rateOffsets.toArray()));
    }

    log.info("gradient ascent finished after " + evaluations + " evaluations");

    //}

    // return map
    return eval2TOUTariff;
}

From source file:io.wcm.testing.mock.jcr.MockPropertyTest.java

@Test
public void testDouble() throws RepositoryException {
    this.node1.setProperty("prop1", 1.5d);
    Property prop1 = this.node1.getProperty("prop1");
    assertEquals(1.5d, prop1.getDouble(), 0.001d);
    assertEquals(1.5d, prop1.getValue().getDouble(), 0.001d);

    prop1.setValue(Double.MAX_VALUE);
    assertEquals(Double.MAX_VALUE, prop1.getDouble(), 0.001d);
    assertEquals(Double.MAX_VALUE, prop1.getValue().getDouble(), 0.001d);
}

From source file:edu.stanford.cfuller.imageanalysistools.clustering.DEGaussianMixtureModelClustering.java

/**
 * Performs Gaussian mixture model clustering on the given inputs using a differential evolution algorithm for maximization of the likelihood of having observed the data.
 * @param singleCluster     An Image mask with each object to be clustered labeled with a unique greylevel value.  (Note that the name stems from this method's original use to recursively divide existing single clusters; this need not actually correspond to a single cluster).
 * @param clusterObjects    A Vector containing an initialized ClusterObject for each object present in the Image passed as singleCluster.
 * @param clusters          A Vector containing an initialized Cluster (guess) for each of the k clusters that will be determined.
 * @param k                 The number of clusters to end up with.
 * @param n                 The number of cluster objects.
 * @return                  The negative log likelihood of observing the objects at their locations, given the maximally likely clustering scheme found.  On return, clusterObjects and clusters will have been updated to reflect this maximally likely scheme.
 *//*from w  ww.  jav a2s.  c  om*/
public static double go(Image singleCluster, java.util.Vector<ClusterObject> clusterObjects,
        java.util.Vector<Cluster> clusters, int k, int n) {

    final int numParametersEach = 5;

    int numParameters = k * numParametersEach;

    int populationSize = numParameters;

    double tol = 1.0e-3;
    double scaleFactor = 0.9;
    double crFrq = 0.05;
    int maxIterations = 10;

    RealVector parameterLowerBounds = new ArrayRealVector(numParameters);
    RealVector parameterUpperBounds = new ArrayRealVector(numParameters);

    for (int i = 0; i < k; i++) {

        parameterLowerBounds.setEntry(numParametersEach * i,
                -0.1 * singleCluster.getDimensionSizes().get(ImageCoordinate.X));
        parameterLowerBounds.setEntry(numParametersEach * i + 1,
                -0.1 * singleCluster.getDimensionSizes().get(ImageCoordinate.Y));
        parameterLowerBounds.setEntry(numParametersEach * i + 2, tol);
        parameterLowerBounds.setEntry(numParametersEach * i + 3, -1);
        parameterLowerBounds.setEntry(numParametersEach * i + 4, tol);

        parameterUpperBounds.setEntry(numParametersEach * i,
                1.1 * singleCluster.getDimensionSizes().get(ImageCoordinate.X));
        parameterUpperBounds.setEntry(numParametersEach * i + 1,
                1.1 * singleCluster.getDimensionSizes().get(ImageCoordinate.Y));
        parameterUpperBounds.setEntry(numParametersEach * i + 2,
                Math.pow(0.05 * singleCluster.getDimensionSizes().get(ImageCoordinate.X), 2));
        parameterUpperBounds.setEntry(numParametersEach * i + 3, 1);
        parameterUpperBounds.setEntry(numParametersEach * i + 4,
                Math.pow(0.05 * singleCluster.getDimensionSizes().get(ImageCoordinate.Y), 2));

    }

    ObjectiveFunction f = new GaussianLikelihoodObjectiveFunction(clusterObjects);

    DifferentialEvolutionMinimizer dem = new DifferentialEvolutionMinimizer();

    RealVector output = null;

    double L = Double.MAX_VALUE;

    while (L == Double.MAX_VALUE || output == null) {
        output = dem.minimize(f, parameterLowerBounds, parameterUpperBounds, populationSize, scaleFactor,
                maxIterations, crFrq, tol);
        L = f.evaluate(output);
    }

    //set up new clusters

    for (int i = 0; i < k; i++) {
        clusters.get(i).setCentroidComponents(output.getEntry(numParametersEach * i),
                output.getEntry(numParametersEach * i + 1), 0);
        clusters.get(i).setID(i + 1);
        clusters.get(i).getObjectSet().clear();
    }

    //assign objects to clusters

    for (ClusterObject c : clusterObjects) {
        c.setCurrentCluster(clusters.get(c.getMostProbableCluster()));
        c.getCurrentCluster().getObjectSet().add(c);
    }

    return L;

}

From source file:mastermind.RandomGenerator.java

public double getSecureRandomDouble() {
    return getSecureRandomDouble(Double.MIN_VALUE, Double.MAX_VALUE);
}

From source file:edu.utexas.cs.tactex.utils.ChargeEstimatorDefault.java

@Override
public double estimateCharge(ArrayRealVector customerEnergy, TariffSpecification spec) {

    TariffEvaluationHelper helper = new TariffEvaluationHelper();
    helper.init(); // init with no parameters since we don't know the customer's parameters(?)

    Tariff tariff = tariffRepoMgr.findTariffById(spec.getId());
    if (null == tariff) {
        log.error("failed to find spec in repo, spec-id: " + spec.getId());
        return -Double.MAX_VALUE;
    }// w w  w.ja  v a2 s. com

    // evaluate
    double evaluation = helper.estimateCost(tariff, customerEnergy.toArray(), true);

    return evaluation;
}

From source file:com.basetechnology.s0.agentserver.field.FloatField.java

public JSONObject toJson() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("type", "float");
    if (symbol.name != null)
        json.put("name", symbol.name);
    if (label != null)
        json.put("label", label);
    if (description != null)
        json.put("description", description);
    if (defaultValue != 0)
        json.put("default_value", defaultValue);
    if (minValue != Double.MIN_VALUE)
        json.put("min_value", minValue);
    if (minValue != Double.MAX_VALUE)
        json.put("max_value", maxValue);
    if (nominalWidth != 0)
        json.put("nominal_width", nominalWidth);
    if (compute != null)
        json.put("compute", compute);
    return json;/*from  w ww. java2s.  co  m*/
}

From source file:gov.va.isaac.sync.view.SyncView.java

private void initGui() {
    root_ = new BorderPane();
    root_.setPrefWidth(550);//from   w  ww .  j a v  a 2 s  . c  o m

    VBox titleBox = new VBox();

    Label title = new Label("Datastore Synchronization");
    title.getStyleClass().add("titleLabel");
    title.setAlignment(Pos.CENTER);
    title.setMaxWidth(Double.MAX_VALUE);
    title.setPadding(new Insets(10));
    titleBox.getChildren().add(title);
    titleBox.getStyleClass().add("headerBackground");

    url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl();
    String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName();

    String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername();
    if (StringUtils.isBlank(syncUsername)) {
        syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser();
    }

    url_ = syncService_.substituteURL(url_, syncUsername);

    Label info = new CopyableLabel("Sync using " + urlType + ": " + url_);
    info.setTooltip(new Tooltip(url_));

    titleBox.getChildren().add(info);

    titleBox.setPadding(new Insets(5, 5, 5, 5));
    root_.setTop(titleBox);

    VBox centerContent = new VBox();
    centerContent.setFillWidth(true);
    centerContent.setPrefWidth(Double.MAX_VALUE);
    centerContent.setPadding(new Insets(10));
    centerContent.getStyleClass().add("itemBorder");
    centerContent.setSpacing(10.0);

    centerContent.getChildren().add(new Label("Status:"));

    summary_ = new TextArea();
    summary_.setWrapText(true);
    summary_.setEditable(false);
    summary_.setMaxWidth(Double.MAX_VALUE);
    summary_.setMaxHeight(Double.MAX_VALUE);
    summary_.setPrefHeight(150.0);

    centerContent.getChildren().add(summary_);
    VBox.setVgrow(summary_, Priority.ALWAYS);

    pb_ = new ProgressBar(0.0);
    pb_.setPrefHeight(20);
    pb_.setMaxWidth(Double.MAX_VALUE);

    centerContent.getChildren().add(pb_);

    root_.setCenter(centerContent);

    //Bottom buttons
    HBox buttons = new HBox();
    buttons.setMaxWidth(Double.MAX_VALUE);
    buttons.setAlignment(Pos.CENTER);
    buttons.setPadding(new Insets(5));
    buttons.setSpacing(30);

    Button cancel = new Button("Close");
    cancel.setOnAction((action) -> {
        if (running_.get()) {
            addLine("Cancelling...");
            cancel.setDisable(true);
            cancelRequested_ = true;
        } else {
            cancel.getScene().getWindow().hide();
            root_ = null;
        }
    });
    buttons.getChildren().add(cancel);

    Button action = new Button("Synchronize");
    action.disableProperty().bind(running_);
    action.setOnAction((theAction) -> {
        summary_.setText("");
        pb_.setProgress(-1.0);
        running_.set(true);
        Utility.execute(() -> sync());
    });
    buttons.getChildren().add(action);

    cancel.minWidthProperty().bind(action.widthProperty());

    running_.addListener(change -> {
        if (running_.get()) {
            cancel.setText("Cancel");
        } else {
            cancel.setText("Close");
        }
        cancel.setDisable(false);
    });

    root_.setBottom(buttons);
}

From source file:mx.unam.ecologia.gye.coalescence.app.EvaluateAncestry.java

protected static final void process(CompoundSequence mrca, List leaves) {
    try {/* ww  w  .  j a va 2  s.  c om*/

        PrintWriter pw = new PrintWriter(System.out);
        HaplotypeFreqSet len1 = new HaplotypeFreqSet(new CompoundSequenceLengthComparator());
        HaplotypeFreqSet len2 = new HaplotypeFreqSet(new CompoundSequenceLengthComparator());
        HaplotypeFreqSet ident = new HaplotypeFreqSet(new CompoundSequenceIdentityComparator());

        for (int i = 0; i < leaves.size(); i++) {
            UniParentalGene upgene = (UniParentalGene) leaves.get(i);
            CompoundSequence h = upgene.getCompoundSequence();
            len1.add(h);
            ident.add(h);
            CompoundSequence cs = h.getCopy();
            cs.setLocus(true);
            len2.add(cs);
        }

        //Identity
        pw.println("IDENTITY");
        ident.sort(new CSAncestryComparator());
        CompoundSequence cs = ident.get(0);
        pw.println("MA: " + ident.contains(cs));
        pw.println("MF: " + (ident.findMostFrequent() + 1));
        pw.println(ident.toFullString());

        pw.println();
        pw.println();
        pw.println("MULTILOCUS");
        pw.println("MA: " + len1.contains(cs));
        pw.println("MF: " + (len1.findMostFrequent() + 1));
        pw.println(len1.toResumeString());

        pw.println();
        pw.println();
        pw.println("LOCUS");
        cs.setLocus(true);
        pw.println("MA: " + len2.contains(cs));
        pw.println("MF: " + (len2.findMostFrequent() + 1));
        pw.println(len2.toResumeString());
        pw.flush();

        SparseGraph sg = new SparseGraph();

        List<CompoundSequence> ht = len1.getHaplotypes();
        //add vertices
        List<SparseVertex> vertices = new ArrayList<SparseVertex>(ht.size());

        for (Iterator<CompoundSequence> iter = ht.iterator(); iter.hasNext();) {
            CompoundSequence cseq = iter.next();
            SparseVertex sv = new SparseVertex();
            sv.addUserDatum("seq", cseq, UserData.SHARED);
            sv.addUserDatum("freq", len1.getFrequency(cseq), UserData.SHARED);
            if (cseq.equals(cs)) {
                sv.addUserDatum("mf", true, UserData.SHARED);
            }
            sg.addVertex(sv);
            vertices.add(sv);
        }
        //add edges
        for (int i = 0; i < ht.size(); i++) {
            for (int j = 0; j <= i; j++) {
                double d = DistanceCalculator.calculateMultilocusLengthDistance(ht.get(i), ht.get(j));
                UndirectedSparseEdge ue = new UndirectedSparseEdge(vertices.get(i), vertices.get(j));
                ue.setUserDatum(EDGE_WEIGHT_KEY, new Double(d), UserData.SHARED);
                if (d != 0) {
                    sg.addEdge(ue);
                }
            }
        }

        //System.out.println(sg.toString());
        //System.out.println(GraphMatrixOperations.graphToSparseMatrix(sg,EDGE_WEIGHT_KEY));
        visualizeGraph(sg);

        //Prim
        SparseGraph nsg = new SparseGraph();
        FibonacciHeap<Vertex, Double> q = new FibonacciHeap<Vertex, Double>();
        Map<Vertex, Vertex> pi = new HashMap<Vertex, Vertex>((int) (ht.size() * 1.3));
        //System.out.println("Have structures");
        Vertex r = null;
        for (SparseVertex u : vertices) {
            q.add(u, Double.MAX_VALUE);
            u.copy(nsg);
            if (r == null) {
                r = u;
            } else {
                //start from max freq
                r = (((Integer) r.getUserDatum("freq")).compareTo((Integer) u.getUserDatum("freq")) > 0) ? r
                        : u;
            }
        }
        q.decreaseKey(r, 0d);
        //System.out.println("initialized starting loop");
        do {
            Vertex u = (Vertex) q.popMin();
            Set<Vertex> s = u.getNeighbors();
            for (Vertex v : s) {
                Edge e = u.findEdge(v);
                double w = (Double) e.getUserDatum(EDGE_WEIGHT_KEY);
                if (q.contains(v) && w < q.getPriority(v)) {
                    pi.put(v, u);
                    q.decreaseKey(v, w);
                }
            }
        } while (q.size() > 0);

        //put edges

        for (Map.Entry<Vertex, Vertex> entry : pi.entrySet()) {
            Vertex v = entry.getKey();
            Vertex u = entry.getValue();
            u.findEdge(v).copy(nsg);
        }

        /*
        for(SparseVertex sv:vertices) {
          //edges
          Set s =  sv.getIncidentEdges();
          Edge[] edges = (Edge[])s.toArray(new Edge[s.size()]);
          //sort
          Arrays.sort(edges,new Comparator<Edge>() {
            public int compare(Edge o1, Edge o2) {
              return ((Double)o2.getUserDatum(EDGE_WEIGHT_KEY)).compareTo((Double)o1.getUserDatum(EDGE_WEIGHT_KEY));
            }
          });
          System.out.println(Arrays.toString(edges));
          //just leave the edge with the lowest weight
          for(Edge e:edges) {
            if(sv.degree() > 1 && e.getOpposite(sv).degree() > 1) {
              sg.removeEdge(e);
              System.out.println("Removing " + e.toString() + "::w="+e.getUserDatum(EDGE_WEIGHT_KEY));
            }
          }
                
          System.out.println(sv.toString());
        }
         */
        visualizeGraph(nsg);
    } catch (Exception ex) {
        log.error("process()", ex);
    }

}

From source file:edu.oregonstate.eecs.mcplan.domains.voyager.policies.KillPolicy.java

@Override
public VoyagerAction getAction() {
    final ArrayList<Planet> friendly = Voyager.playerPlanets(s_, self_);
    final ArrayList<Planet> enemy = Voyager.playerPlanets(s_, self_.enemy());
    if (enemy.isEmpty()) {
        return new NothingAction();
    }//from w  w w. j  a v a 2 s .c o  m
    Planet target = null;
    double weight = 0;
    for (final Planet t : enemy) {
        final double tw = targetWeight(t, friendly);
        if (tw > weight) {
            weight = tw;
            target = t;
        }
    }
    if (target == null) {
        return new NothingAction();
    }
    while (friendly.size() > 0) {
        Planet src = null;
        double dist = Double.MAX_VALUE;
        for (final Planet s : friendly) {
            final double sd = Voyager.distance(s, target);
            if (sd < dist) {
                dist = sd;
                src = s;
            }
        }
        if (src != null) {
            final int spare_soldiers = src.population(Unit.Soldier) - garrison_;
            if (spare_soldiers > 0) {
                final int[] pop = new int[Unit.values().length];
                pop[Unit.Soldier.ordinal()] = spare_soldiers;
                return new LaunchAction(src, target, pop);
            } else {
                friendly.remove(src);
            }
        }
    }

    return new NothingAction();
}