當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair.getFirst方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.util.Pair.getFirst方法的典型用法代碼示例。如果您正苦於以下問題:Java Pair.getFirst方法的具體用法?Java Pair.getFirst怎麽用?Java Pair.getFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.util.Pair的用法示例。


在下文中一共展示了Pair.getFirst方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendTupleToActuator

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
protected void sendTupleToActuator(Tuple tuple){
	/*for(Pair<Integer, Double> actuatorAssociation : getAssociatedActuatorIds()){
		int actuatorId = actuatorAssociation.getFirst();
		double delay = actuatorAssociation.getSecond();
		if(actuatorId == tuple.getActuatorId()){
			send(actuatorId, delay, FogEvents.TUPLE_ARRIVAL, tuple);
			return;
		}
	}
	int childId = getChildIdForTuple(tuple);
	if(childId != -1)
		sendDown(tuple, childId);*/
	for(Pair<Integer, Double> actuatorAssociation : getAssociatedActuatorIds()){
		int actuatorId = actuatorAssociation.getFirst();
		double delay = actuatorAssociation.getSecond();
		String actuatorType = ((Actuator)CloudSim.getEntity(actuatorId)).getActuatorType();
		if(tuple.getDestModuleName().equals(actuatorType)){
			send(actuatorId, delay, FogEvents.TUPLE_ARRIVAL, tuple);
			return;
		}
	}
	for(int childId : getChildrenIds()){
		sendDown(tuple, childId);
	}
}
 
開發者ID:gmartinezramirez,項目名稱:Fog-Computing-Mobile-Architecture,代碼行數:26,代碼來源:FogDevice.java

示例2: handleEventChange

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Adds the keys we can display in the camera window to the dropdown list.
 *
 * @param itemKeyPair the current data item we want to display
 */
@Override
@Subscribe
public void handleEventChange(Pair<Data, String> itemKeyPair) {
    this.dataItem = itemKeyPair.getFirst();
    String selectedKey = (String) keyComboBox.getSelectedItem();
    keyComboBox.removeAllItems();
    for (String key : dataItem.keySet()) {
        double[] data = Utils.toDoubleArray(dataItem.get(key));
        if (data != null && data.length > 0 && data.length % Constants.N_PIXELS == 0) {
            keyComboBox.addItem(key);
            if (key.equals(selectedKey)) {
                keyComboBox.setSelectedItem(key);
            }
        }
    }
}
 
開發者ID:fact-project,項目名稱:fact-tools,代碼行數:22,代碼來源:CameraWindow.java

示例3: handleEventChange

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
@Subscribe
public void handleEventChange(Pair<Data, String> itemKeyPair) {
    log.debug("hexmap got a new item");

    String key;
    if (defaultKey != null) {
        key = defaultKey;
    } else {
        key = itemKeyPair.getSecond();
    }

    this.dataItem = itemKeyPair.getFirst();
    minValueInData = 0;
    maxValueInData = 0;
    overlays = updateOverlays(overlayKeys, dataItem);
    if (dataItem.containsKey(key)) {
        updateMapDisplay(dataItem, key);
    } else {
        log.error("The key: " + key
                + " was not found in the data item. Nothing to display.");
    }

}
 
開發者ID:fact-project,項目名稱:fact-tools,代碼行數:24,代碼來源:FactHexMapDisplay.java

示例4: handleEventChange

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
@Override
@Subscribe
public void handleEventChange(Pair<Data, String> itemKeyPair) {
    Data item = itemKeyPair.getFirst();
    Integer roi = (Integer) item.get("ROI");
    if (roi != null) {
        slider.setMaximum(roi - 1);
    }
    Serializable eventNum = item.get("EventNum");
    if (eventNum != null) {
        eventNumber.setText(eventNum.toString());
    }
    Serializable trigger = item.get("TriggerType");
    if (trigger != null) {
        triggerTypeField.setText(trigger.toString());
    }
    Serializable file = item.get("@source");
    if (file != null) {
        fileField.setText(file.toString());
    }
}
 
開發者ID:fact-project,項目名稱:fact-tools,代碼行數:22,代碼來源:StreamNavigationPanel.java

示例5: evaluate

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/** {@inheritDoc} */
public Evaluation evaluate(final RealVector point) {
    // Copy so optimizer can change point without changing our instance.
    final RealVector p = paramValidator == null ?
        point.copy() :
        paramValidator.validate(point.copy());

    if (lazyEvaluation) {
        return new LazyUnweightedEvaluation((ValueAndJacobianFunction) model,
                                            target,
                                            p);
    } else {
        // Evaluate value and jacobian in one function call.
        final Pair<RealVector, RealMatrix> value = model.value(p);
        return new UnweightedEvaluation(value.getFirst(),
                                        value.getSecond(),
                                        target,
                                        p);
    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:21,代碼來源:LeastSquaresFactory.java

示例6: transform

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Performs a change of variable so that the integration can be performed
 * on an arbitrary interval {@code [a, b]}.
 * It is assumed that the natural interval is {@code [-1, 1]}.
 *
 * @param rule Original points and weights.
 * @param a Lower bound of the integration interval.
 * @param b Lower bound of the integration interval.
 * @return the points and weights adapted to the new interval.
 */
private static Pair<double[], double[]> transform(Pair<double[], double[]> rule,
                                                  double a,
                                                  double b) {
    final double[] points = rule.getFirst();
    final double[] weights = rule.getSecond();

    // Scaling
    final double scale = (b - a) / 2;
    final double shift = a + scale;

    for (int i = 0; i < points.length; i++) {
        points[i] = points[i] * scale + shift;
        weights[i] *= scale;
    }

    return new Pair<double[], double[]>(points, weights);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:28,代碼來源:GaussIntegratorFactory.java

示例7: convertToDouble

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Converts the from the actual {@code Number} type to {@code double}
 *
 * @param <T> Type of the number used to represent the points and
 * weights of the quadrature rules.
 * @param rule Points and weights.
 * @return points and weights as {@code double}s.
 */
private static <T extends Number> Pair<double[], double[]> convertToDouble(Pair<T[], T[]> rule) {
    final T[] pT = rule.getFirst();
    final T[] wT = rule.getSecond();

    final int len = pT.length;
    final double[] pD = new double[len];
    final double[] wD = new double[len];

    for (int i = 0; i < len; i++) {
        pD[i] = pT[i].doubleValue();
        wD[i] = wT[i].doubleValue();
    }

    return new Pair<double[], double[]>(pD, wD);
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:24,代碼來源:BaseRuleFactory.java

示例8: getBySlug

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
private <T> T getBySlug(MaprDbDao<T> dbDao, String slug) {

        Pair<String, Long> slugPostfixPair = getSlugPostfixPair(slug);
        String slugWithoutPostfix = slugPostfixPair.getFirst();
        Long postfix = slugPostfixPair.getSecond();

        if (postfix == null) {
            throw new IllegalArgumentException("Slug name must contain numeric postfix");
        }

        return dbDao.processStore((connection, store) -> {

            QueryCondition condition = connection.newCondition()
                    .and()
                    .is("slug_name", QueryCondition.Op.EQUAL, slugWithoutPostfix)
                    .is("slug_postfix", QueryCondition.Op.EQUAL, postfix)
                    .close();


            Query query = connection.newQuery()
                    .select("*")
                    .where(condition.build())
                    .build();

            Iterator<Document> iterator = store.findQuery(query).iterator();
            if (!iterator.hasNext()) {
                return null;
            }

            return dbDao.mapOjaiDocument(iterator.next());
        });
    }
 
開發者ID:mapr-demos,項目名稱:mapr-music,代碼行數:33,代碼來源:SlugService.java

示例9: assertStateCompleted

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Given the result of {@link WaitUntilCompleteListener#waitForCompletion}, this method fails if the completed state
 * is not as expected, or if an exception is thrown. The completed state could be COMPLETED or CANCELED. This state
 * is set when {@link WaitUntilCompleteListener#queryCompleted} is called.
 */
private static void assertStateCompleted(final Pair<QueryState, Exception> result, final QueryState expectedState) {
  final QueryState actualState = result.getFirst();
  final Exception exception = result.getSecond();
  if (actualState != expectedState || exception != null) {
    fail(String.format("Query state is incorrect (expected: %s, actual: %s) AND/OR \nException thrown: %s",
      expectedState, actualState, exception == null ? "none." : exception));
  }
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:14,代碼來源:TestDrillbitResilience.java

示例10: assertFailsWithException

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
/**
 * Given a set of controls, this method ensures TEST_QUERY fails with the given class and desc.
 */
private static void assertFailsWithException(final String controls, final Class<? extends Throwable> exceptionClass,
                                             final String exceptionDesc, final String query) {
  setControls(controls);
  final WaitUntilCompleteListener listener = new WaitUntilCompleteListener();
  QueryTestUtil.testWithListener(drillClient, QueryType.SQL, query, listener);
  final Pair<QueryState, Exception> result = listener.waitForCompletion();
  final QueryState state = result.getFirst();
  assertTrue(String.format("Query state should be FAILED (and not %s).", state), state == QueryState.FAILED);
  assertExceptionMessage(result.getSecond(), exceptionClass, exceptionDesc);
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:14,代碼來源:TestDrillbitResilience.java

示例11: gini

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
private static <T> double gini(final T[] preds, final Object[] expected, final boolean doPerfect) {
	final List<Pair<Object, T>> sortedByPdesc = new LinkedList<>();
	for (int i = 0; i < preds.length; ++i) {
		sortedByPdesc.add(new Pair<>(expected[i], preds[i]));
	}
	final boolean isBinary = sortedByPdesc.get(0).getSecond() instanceof Boolean;
	Collections.sort(sortedByPdesc, (o1, o2) -> {
		if (doPerfect) {
			if (isBinary) {
				return ((Boolean) o1.getFirst()).booleanValue() ? -1 : 1;
			}
			return ((Number) o1.getFirst()).doubleValue() >= ((Number) o2.getFirst()).doubleValue() ? -1 : 1;
		}
		return ((Number) o1.getSecond()).doubleValue() >= ((Number) o2.getSecond()).doubleValue() ? -1 : 1;
	});

	double sum = 0;
	double giniSum = 0;
	for (final Pair<Object, T> prediction : sortedByPdesc) {
		if (isBinary) {
			sum += (Boolean) prediction.getFirst() ? 1 : 0;
		} else {
			sum += (Double) prediction.getFirst();
		}
		giniSum += sum;
	}

	giniSum = giniSum / sum - (sortedByPdesc.size() + 1.0) / 2;
	return giniSum / sortedByPdesc.size();
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:31,代碼來源:Gini.java

示例12: run

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
@Override
public ModelPipeline<S, O> run(final Iterable<S> data, final Iterable<S> unlabled,
		final FeaturesConfig<? extends S, O> config, final int labelIndex) {
	final Pair<Iterable<S>, PreprocessingPipeline<S>> modelAndPipe = modelAndPipe(data,
			config,
			learner.getOriginalArguments());
	final Iterable<S> samples = modelAndPipe.getFirst();
	final PreprocessingPipeline<S> pipe = modelAndPipe.getSecond();
	final File cacheFile = new File("cache/samples_" + samples.hashCode() + "_" + pipe.hashCode());
	final IModel<S, O> model = (IModel<S, O>) learner
			.run(createSamples(samples, pipe, cacheFile), null, config, labelIndex);
	return new ModelPipeline<>(model, pipe, config == null ? null : config.getPostProcessor(), labelIndex);
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:14,代碼來源:LearnerPipeline.java

示例13: modelAndPipe

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
public Pair<Iterable<S>, PreprocessingPipeline<S>> modelAndPipe(final Iterable<S> data,
		final FeaturesConfig<? extends S, O> origConfig, final @Nonnull IArguments arguments) {
	final Pair<Iterable<S>, List<S>> split = SplitSimulation.split(data, trainRatio, null);
	final Iterable<S> train = split.getFirst();
	List<S> valid = split.getSecond();
	if (trainRatio < 1) {
		logger.info("Learning on " + ((List<?>) train).size() + " samples, " + valid.size() + " ignored.");
	}

	FeaturesConfig<? extends S, O> config = null;
	PreprocessingPipeline<S> pipe = null;
	if (preprocess) {
		if (selection != null) {
			final DoublePair<Set<String>> result = selection.run(train, origConfig, learner);
			if (result != null) {
				config = new SimpleFeatureConfig<>(origConfig.newFeatureProvider(),
						new ManualSelectionFilter(result.getKey(), true), null);
			}
		}
		if (config == null) {
			config = origConfig;
		}
		pipe = new PreprocessingPipelineSupplier<>(train, (FeaturesConfig<S, O>) config, serializer, arguments)
				.get();
	} else {
		config = origConfig;
	}
	valid = null;

	return new Pair<>(train, pipe);
}
 
開發者ID:ProfilingIO,項目名稱:insight-ml,代碼行數:32,代碼來源:LearnerPipeline.java

示例14: handleEventChange

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
@Override
@Subscribe
public void handleEventChange(Pair<Data, String> itemKeyPair) {
    this.item = itemKeyPair.getFirst();
    if (item.containsKey("NROI")) {
        this.roi = (Integer) item.get("NROI");
    }
    drawPlot();
}
 
開發者ID:fact-project,項目名稱:fact-tools,代碼行數:10,代碼來源:MainPlotPanel.java

示例15: solve

import org.apache.commons.math3.util.Pair; //導入方法依賴的package包/類
@Override
protected RealVector solve(final RealMatrix jacobian,
                           final RealVector residuals) {
    try {
        final Pair<RealMatrix, RealVector> normalEquation =
                computeNormalMatrix(jacobian, residuals);
        final RealMatrix normal = normalEquation.getFirst();
        final RealVector jTr = normalEquation.getSecond();
        return new CholeskyDecomposition(
                normal, SINGULARITY_THRESHOLD, SINGULARITY_THRESHOLD)
                .getSolver()
                .solve(jTr);
    } catch (NonPositiveDefiniteMatrixException e) {
        throw new ConvergenceException(LocalizedFormats.UNABLE_TO_SOLVE_SINGULAR_PROBLEM, e);
    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:17,代碼來源:GaussNewtonOptimizer.java


注:本文中的org.apache.commons.math3.util.Pair.getFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。