Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:org.pentaho.platform.uifoundation.chart.PieDatasetChartDefinition.java

private void setStartAngle(final Node startAngleNode) {
    if (startAngleNode != null) {
        String gapNodeStr = startAngleNode.getText();
        Double doubleValue = new Double(gapNodeStr);
        setStartAngle(doubleValue.doubleValue());
    }//from   www. ja va2  s  . c o  m
}

From source file:org.pentaho.platform.uifoundation.chart.PieDatasetChartDefinition.java

private void setInteriorGap(final Node interiorGapNode) {
    if (interiorGapNode != null) {
        String gapNodeStr = interiorGapNode.getText();
        Double doubleValue = new Double(gapNodeStr);
        setInteriorGap(doubleValue.doubleValue());
    }/*from w ww.  j  a  va 2s.com*/
}

From source file:org.kalypso.model.wspm.pdb.internal.wspm.CrossSectionConverter.java

private void insertRecordsAs(final IProfileObject profileObject, final String asComponent) {
    final IWspmClassification classification = WspmClassifications.getClassification(m_profile);
    final IVegetationClass unknownVegetationClass = classification.findUnknownVegetationClass();
    final IRoughnessClass unknownRoughnessClass = classification.findUnknownRoughnessClass();

    final String unknownVegetation = unknownVegetationClass == null ? null : unknownVegetationClass.getName();
    final String unknownRoughness = unknownRoughnessClass == null ? null : unknownRoughnessClass.getName();

    final IProfileObjectRecords records = profileObject.getRecords();
    for (int i = 0; i < records.size(); i++) {
        final IProfileObjectRecord record = records.getRecord(i);
        final String id = record.getId();
        final String comment = record.getComment();
        final Double breite = record.getBreite();
        final Double hoehe = record.getHoehe();
        final Double rechtswert = record.getRechtswert();
        final Double hochwert = record.getHochwert();
        final String code = record.getCode();

        /* Find or insert point at 'width'. */
        final boolean insert = Objects.isNull(ProfileVisitors.findPoint(m_profile, breite.doubleValue()));
        final IProfileRecord pRecord = Profiles.addOrFindPoint(m_profile, breite);

        setValue(pRecord, asComponent, hoehe);

        // TODO: Check: If we have the same width, but different rw/hw, we just forget the old rw/hw here, which is bad...
        // TODO: Same holds for ID, Code, etc.
        if (insert) {
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_ID, id);
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_COMMENT, comment);
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_RECHTSWERT, rechtswert);
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_HOCHWERT, hochwert);
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_CODE, code);

            // HOTFIX: if a new point is inserted we need a roughness/vegetation class. Unfortunately, the class values
            // are not stored ni the corresponding profile object...
            // For now, we just set the 'unknown' classes here, assuming, that the buildings never have associated roughness values
            // TODO: either remember the real clases from the profile part; or a t least, use the class of the previous point.
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_ROUGHNESS_CLASS, unknownRoughness);
            setValue(pRecord, IWspmPointProperties.POINT_PROPERTY_BEWUCHS_CLASS, unknownVegetation);
        }// w w  w . j  a  va 2 s . co  m
    }
}

From source file:org.fhcrc.cpl.viewer.gui.SpectrumComponent.java

public void mzSpinner_stateChanged(ChangeEvent e) {
    Double Num = (Double) mzSpinner.getValue();
    if (null == Num) {
        clearChart();/*w ww .j  av  a  2 s.c  o m*/
        return;
    }
    if (_selectedMZ == Num.doubleValue())
        return;

    _selectedMZ = Num.doubleValue();
    _log.debug("_selectedMZ = " + _selectedMZ);
    updateChart(true);
}

From source file:ml.shifu.shifu.core.dtrain.nn.NNMaster.java

@SuppressWarnings("unchecked")
@Override/*w  w w. jav a  2s.  c  o m*/
public void init(MasterContext<NNParams, NNParams> context) {
    Properties props = context.getProps();
    try {
        SourceType sourceType = SourceType
                .valueOf(props.getProperty(CommonConstants.MODELSET_SOURCE_TYPE, SourceType.HDFS.toString()));

        this.modelConfig = CommonUtils.loadModelConfig(props.getProperty(CommonConstants.SHIFU_MODEL_CONFIG),
                sourceType);

        this.columnConfigList = CommonUtils
                .loadColumnConfigList(props.getProperty(CommonConstants.SHIFU_COLUMN_CONFIG), sourceType);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    int trainerId = Integer.valueOf(context.getProps().getProperty(CommonConstants.SHIFU_TRAINER_ID, "0"));
    GridSearch gs = new GridSearch(modelConfig.getTrain().getParams(),
            modelConfig.getTrain().getGridConfigFileContent());
    validParams = this.modelConfig.getTrain().getParams();
    if (gs.hasHyperParam()) {
        validParams = gs.getParams(trainerId);
        LOG.info("Start grid search master with params: {}", validParams);
    }

    Boolean enabledEarlyStop = DTrainUtils.getBoolean(validParams, CommonConstants.ENABLE_EARLY_STOP,
            Boolean.FALSE);
    if (enabledEarlyStop) {
        Double validTolerance = DTrainUtils.getDouble(validParams, CommonConstants.VALIDATION_TOLERANCE, null);
        if (validTolerance == null) {
            LOG.info("Early Stop is enabled. use WindowEarlyStop");
            // windowSize default 20, user should could adjust it
            this.earlyStopStrategy = new WindowEarlyStop(context, this.modelConfig, DTrainUtils
                    .getInt(context.getProps(), CommonConstants.SHIFU_TRAIN_EARLYSTOP_WINDOW_SIZE, 20));
        } else {
            LOG.info("Early Stop is enabled. use ConvergeAndValiToleranceEarlyStop");
            Double threshold = this.modelConfig.getTrain().getConvergenceThreshold();
            this.earlyStopStrategy = new ConvergeAndValidToleranceEarlyStop(
                    threshold == null ? Double.MIN_VALUE : threshold.doubleValue(), validTolerance);
        }
    }

    Object pObject = validParams.get(CommonConstants.PROPAGATION);
    this.propagation = pObject == null ? "Q" : (String) pObject;
    this.rawLearningRate = Double.valueOf(validParams.get(CommonConstants.LEARNING_RATE).toString());
    Object dropoutRateObj = validParams.get(CommonConstants.DROPOUT_RATE);
    if (dropoutRateObj != null) {
        this.dropoutRate = Double.valueOf(dropoutRateObj.toString());
    }
    LOG.info("'dropoutRate' in master is : {}", this.dropoutRate);

    Object learningDecayO = validParams.get(CommonConstants.LEARNING_DECAY);
    if (learningDecayO != null) {
        this.learningDecay = Double.valueOf(learningDecayO.toString());
    }
    LOG.info("'learningDecay' in master is :{}", learningDecay);

    Object momentumO = validParams.get("Momentum");
    if (momentumO != null) {
        this.momentum = Double.valueOf(momentumO.toString());
    }
    LOG.info("'momentum' in master is :{}", momentum);

    Object adamBeta1O = validParams.get("AdamBeta1");
    if (adamBeta1O != null) {
        this.adamBeta1 = Double.valueOf(adamBeta1O.toString());
    }
    LOG.info("'adamBeta1' in master is :{}", adamBeta1);

    Object adamBeta2O = validParams.get("AdamBeta2");
    if (adamBeta2O != null) {
        this.adamBeta2 = Double.valueOf(adamBeta2O.toString());
    }
    LOG.info("'adamBeta2' in master is :{}", adamBeta2);

    this.wgtInit = "default";
    Object wgtInitObj = validParams.get(CommonConstants.WEIGHT_INITIALIZER);
    if (wgtInitObj != null) {
        this.wgtInit = wgtInitObj.toString();
    }

    this.isContinuousEnabled = Boolean.TRUE.toString()
            .equalsIgnoreCase(context.getProps().getProperty(CommonConstants.CONTINUOUS_TRAINING));
    Object rconstant = validParams.get(CommonConstants.REGULARIZED_CONSTANT);
    this.regularizedConstant = NumberFormatUtils.getDouble(rconstant == null ? "" : rconstant.toString(), 0d);

    // We do not update weight in fixed layers so that we could fine tune other layers of NN
    Object fixedLayers2O = validParams.get(CommonConstants.FIXED_LAYERS);
    if (fixedLayers2O != null) {
        this.fixedLayers = (List<Integer>) fixedLayers2O;
    }
    LOG.info("Fixed layers in master is :{}", this.fixedLayers.toString());

    Object fixedBiasObj = validParams.getOrDefault(CommonConstants.FIXED_BIAS, true);
    this.fixedBias = (Boolean) fixedBiasObj;

    Object hiddenLayerNumObj = validParams.get(CommonConstants.NUM_HIDDEN_LAYERS);
    if (hiddenLayerNumObj != null && StringUtils.isNumeric(hiddenLayerNumObj.toString())) {
        this.hiddenLayerNum = Integer.valueOf(hiddenLayerNumObj.toString());
    }
    LOG.info("hiddenLayerNum in master is :{}", this.hiddenLayerNum);

    // check if variables are set final selected
    int[] inputOutputIndex = DTrainUtils.getNumericAndCategoricalInputAndOutputCounts(this.columnConfigList);
    this.isAfterVarSelect = (inputOutputIndex[3] == 1);
    // cache all feature list for sampling features
    this.allFeatures = NormalUtils.getAllFeatureList(columnConfigList, isAfterVarSelect);
    String subsetStr = context.getProps().getProperty(CommonConstants.SHIFU_NN_FEATURE_SUBSET);
    if (StringUtils.isBlank(subsetStr)) {
        this.subFeatures = this.allFeatures;
    } else {
        String[] splits = subsetStr.split(",");
        this.subFeatures = new ArrayList<Integer>(splits.length);
        for (String split : splits) {
            this.subFeatures.add(Integer.parseInt(split));
        }
    }

    // recover master states here is globalNNParams
    // not init but not first iteration, first recover from last master result set from guagua
    if (!context.isFirstIteration()) {
        NNParams params = context.getMasterResult();
        if (params != null && params.getWeights() != null) {
            this.globalNNParams.setWeights(params.getWeights());
        } else {
            // else read from checkpoint
            params = initOrRecoverParams(context);
            this.globalNNParams.setWeights(params.getWeights());
        }
    }
}

From source file:org.infoglue.cms.util.workflow.InfoGlueJDBCPropertySet.java

private void setValues(PreparedStatement ps, int type, String key, Object value)
        throws SQLException, PropertyException {
    // Patched by Edson Richter for MS SQL Server JDBC Support!
    String driverName;//from www. j a v a 2 s .c om

    try {
        driverName = ps.getConnection().getMetaData().getDriverName().toUpperCase();
    } catch (Exception e) {
        driverName = "";
    }

    ps.setNull(1, Types.VARCHAR);
    ps.setNull(2, Types.TIMESTAMP);

    // Patched by Edson Richter for MS SQL Server JDBC Support!
    // Oracle support suggestion also Michael G. Slack
    if ((driverName.indexOf("SQLSERVER") >= 0) || (driverName.indexOf("ORACLE") >= 0)) {
        ps.setNull(3, Types.BINARY);
    } else {
        ps.setNull(3, Types.BLOB);
    }

    ps.setNull(4, Types.FLOAT);
    ps.setNull(5, Types.NUMERIC);
    ps.setInt(6, type);
    ps.setString(7, globalKey);
    ps.setString(8, key);

    switch (type) {
    case PropertySet.BOOLEAN:

        Boolean boolVal = (Boolean) value;
        ps.setInt(5, boolVal.booleanValue() ? 1 : 0);

        break;

    case PropertySet.DATA:

        Data data = (Data) value;
        ps.setBytes(3, data.getBytes());

        break;

    case PropertySet.DATE:

        Date date = (Date) value;
        ps.setTimestamp(2, new Timestamp(date.getTime()));

        break;

    case PropertySet.DOUBLE:

        Double d = (Double) value;
        ps.setDouble(4, d.doubleValue());

        break;

    case PropertySet.INT:

        Integer i = (Integer) value;
        ps.setInt(5, i.intValue());

        break;

    case PropertySet.LONG:

        Long l = (Long) value;
        ps.setLong(5, l.longValue());

        break;

    case PropertySet.STRING:
        ps.setString(1, (String) value);

        break;

    default:
        throw new PropertyException("This type isn't supported!");
    }

    if (valueMap == null)
        valueMap = new HashMap();
    if (typeMap == null)
        typeMap = new HashMap();

    valueMap.put(key, value);
    typeMap.put(key, new Integer(type));
}

From source file:BayesianAnalyzer.java

/**
 * Compute the spamminess probability of the interesting tokens in
 * the tokenProbabilities SortedSet./*from  w w w .  j  ava2  s.  c  om*/
 *
 * @param tokenProbabilities
 * @param workCorpus
 * @return  Computed spamminess.
 */
private double computeOverallProbability(SortedSet tokenProbabilityStrengths, Map workCorpus) {
    double p = 1.0;
    double np = 1.0;
    double tempStrength = 0.5;
    int count = MAX_INTERESTING_TOKENS;
    Iterator iterator = tokenProbabilityStrengths.iterator();
    while ((iterator.hasNext()) && (count-- > 0 || tempStrength >= INTERESTINGNESS_THRESHOLD)) {
        TokenProbabilityStrength tps = (TokenProbabilityStrength) iterator.next();
        tempStrength = tps.strength;

        //      System.out.println(tps);

        double theDoubleValue = DEFAULT_TOKEN_PROBABILITY; // initialize it to the default
        Double theDoubleObject = (Double) workCorpus.get(tps.token);
        // if either the original token or a degeneration was found use the double value, otherwise use the default
        if (theDoubleObject != null) {
            theDoubleValue = theDoubleObject.doubleValue();
        }
        p *= theDoubleValue;
        np *= (1.0 - theDoubleValue);
        // System.out.println("Token:" + tps.token + ", p=" + theDoubleValue + ", overall p=" + p / (p + np));
    }

    return (p / (p + np));
}

From source file:com.nagarro.core.v2.helper.StoresHelper.java

@Cacheable(value = "storeCache", key = "T(de.hybris.platform.commercewebservicescommons.cache.CommerceCacheKeyGenerator).generateKey(false,false,'Data',#query,#latitude,#longitude,#currentPage,#pageSize,#sort,#radius,#accuracy)")
public StoreFinderSearchPageData<PointOfServiceData> locationSearch(final String query, final Double latitude,
        final Double longitude, final int currentPage, final int pageSize, final String sort,
        final double radius, final double accuracy) {
    if (radius > EARTH_PERIMETER) {
        throw new RequestParameterException("Radius cannot be greater than Earth's perimeter",
                RequestParameterException.INVALID, "radius");
    }//from  w w w. j  av a  2  s. c  o  m

    final double radiusToSearch = getInKilometres(radius, accuracy);
    final PageableData pageableData = createPageableData(currentPage, pageSize, sort);
    StoreFinderSearchPageData<PointOfServiceData> result = null;
    if (StringUtils.isNotBlank(query)) {
        result = storeFinderFacade.locationSearch(query, pageableData, radiusToSearch);
    } else if (latitude != null && longitude != null) {
        final GeoPoint geoPoint = new GeoPoint();
        geoPoint.setLatitude(latitude.doubleValue());
        geoPoint.setLongitude(longitude.doubleValue());
        result = storeFinderFacade.positionSearch(geoPoint, pageableData, radiusToSearch);
    } else {
        result = storeFinderFacade.getAllPointOfServices(pageableData);
    }
    return result;
}

From source file:org.egov.works.web.actions.tender.SearchTenderResponseActivitiesAction.java

private double getAssignedQuantity(final Long activityId, final String negotiationNumber) {
    Object[] params = new Object[] { negotiationNumber, WorksConstants.CANCELLED_STATUS, activityId };
    Double assignedQty = (Double) getPersistenceService().findByNamedQuery("getAssignedQuantityForActivity",
            params);/*  w  w w.j  av  a2  s .  c  o  m*/
    params = new Object[] { negotiationNumber, WorksConstants.NEW, activityId };
    final Double assignedQtyForNew = (Double) getPersistenceService()
            .findByNamedQuery("getAssignedQuantityForActivityForNewWO", params);

    if (assignedQty != null && assignedQtyForNew != null)
        assignedQty = assignedQty + assignedQtyForNew;
    if (assignedQty == null && assignedQtyForNew != null)
        assignedQty = assignedQtyForNew;
    if (assignedQty == null)
        return 0.0d;
    else
        return assignedQty.doubleValue();
}

From source file:com.exxonmobile.ace.hybris.storefront.controllers.pages.StorePageController.java

@RequestMapping(value = STORE_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
public String storeDetail(@PathVariable("storeCode") final String storeCode,
        @RequestParam(value = "lat", required = false) final Double sourceLatitude,
        @RequestParam(value = "long", required = false) final Double sourceLongitude,
        @RequestParam(value = "q", required = false) final String locationQuery, final Model model,
        final RedirectAttributes redirectModel) throws CMSItemNotFoundException {
    final StoreFinderForm storeFinderForm = new StoreFinderForm();
    model.addAttribute("storeFinderForm", storeFinderForm);
    final StorePositionForm storePositionForm = new StorePositionForm();
    model.addAttribute("storePositionForm", storePositionForm);

    if (sourceLatitude != null && sourceLongitude != null) {
        final GeoPoint geoPoint = new GeoPoint();
        geoPoint.setLatitude(sourceLatitude.doubleValue());
        geoPoint.setLongitude(sourceLongitude.doubleValue());

        // Get the point of service data with the formatted distance
        try {/* w  w w  .ja v a 2  s. c o  m*/
            final PointOfServiceData pointOfServiceData = storeFinderFacade
                    .getPointOfServiceForNameAndPosition(storeCode, geoPoint);
            if (pointOfServiceData == null) {
                return handlePOSNotFoundCase(redirectModel);
            }
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);

            if (locationQuery != null && !locationQuery.isEmpty()) {
                model.addAttribute("locationQuery", locationQuery);

                // Build URL to location query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder")
                        .queryParam("q", locationQuery).build().toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                        storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
            } else {
                // Build URL to position query
                final String storeFinderSearchUrl = UriComponentsBuilder.fromPath("/store-finder/position")
                        .queryParam("lat", sourceLatitude).queryParam("long", sourceLongitude).build()
                        .toString();
                model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                        storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData, storeFinderSearchUrl));
            }
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handlePOSNotFoundCase(redirectModel);
        }
    } else {
        // No source point specified - just lookup the POS by name
        try {
            final PointOfServiceData pointOfServiceData = storeFinderFacade.getPointOfServiceForName(storeCode);
            pointOfServiceData.setUrl("/store/" + pointOfServiceData.getName());
            model.addAttribute("store", pointOfServiceData);
            model.addAttribute(WebConstants.BREADCRUMBS_KEY,
                    storeBreadcrumbBuilder.getBreadcrumbs(pointOfServiceData));
            setUpMetaData(model, pointOfServiceData);
        } catch (final ModelNotFoundException e) {
            return handlePOSNotFoundCase(redirectModel);
        }
    }

    storeCmsPageInModel(model, getStoreFinderPage());
    return ControllerConstants.Views.Pages.StoreFinder.StoreFinderDetailsPage;
}