本文整理汇总了Java中org.apache.commons.lang3.mutable.MutableDouble类的典型用法代码示例。如果您正苦于以下问题:Java MutableDouble类的具体用法?Java MutableDouble怎么用?Java MutableDouble使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutableDouble类属于org.apache.commons.lang3.mutable包,在下文中一共展示了MutableDouble类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: progressInBoundsAndMonotonicallyIncreasing
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
@Test
public void progressInBoundsAndMonotonicallyIncreasing() {
final String[] content = {};
entityBag.add(new MockEntity("A_1", content));
entityBag.add(new MockEntity("A_2", content));
entityBag.add(new MockEntity("B", content));
entityBag.add(new MockEntity("C", content));
entityBag.add(new MockEntity("D", content));
final MutableDouble lastProgress = new MutableDouble(-Double.MAX_VALUE);
final AtomicReference<String> lastOperation = new AtomicReference<String>("");
entityBag.addProgressListener((progress, operation) -> {
assertThat(progress, is(lessThanOrEqualTo(1d)));
if (!StringUtils.equals(operation, lastOperation.get())) {
lastOperation.set(operation);
return;
}
assertThat(progress, greaterThanOrEqualTo(lastProgress.getValue()));
lastProgress.setValue(progress);
});
entityBag.mergeSimilars();
}
示例2: checkAndCreateDemand
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private void checkAndCreateDemand(long layerId, long demandId)
{
if (!accum_avgDemandOfferedTraffic.get(layerId).containsKey(demandId))
{
/* Initialize demand information */
accum_avgDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble());
minDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE));
maxDemandOfferedTraffic.get(layerId).put(demandId, new MutableDouble());
accum_avgDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble());
minDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE));
maxDemandCarriedTraffic.get(layerId).put(demandId, new MutableDouble());
accum_avgDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble());
minDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE));
maxDemandBlockedTraffic.get(layerId).put(demandId, new MutableDouble());
accum_avgExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble());
minDemandExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble(Double.MAX_VALUE));
maxDemandExcessCarriedTraffic.get(layerId).put(demandId, new MutableDouble());
accum_demandAvailabilityClassic.get(layerId).put(demandId, new MutableDouble());
accum_demandAvailabilityWeighted.get(layerId).put(demandId, new MutableDouble());
excessDemandCarriedTrafficTime.get(layerId).put(demandId, new MutableDouble());
demandTotalTime.get(layerId).put(demandId, new MutableDouble());
}
}
示例3: checkAndCreateLink
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private void checkAndCreateLink(long layerId, long linkId)
{
if (!accum_avgLinkLengthInKm.get(layerId).containsKey(linkId))
{
/* Initialize link information */
accum_avgLinkLengthInKm.get(layerId).put(linkId, new MutableDouble());
minLinkLengthInKm.get(layerId).put(linkId, new MutableDouble(Double.MAX_VALUE));
maxLinkLengthInKm.get(layerId).put(linkId, new MutableDouble());
accum_avgCapacity.get(layerId).put(linkId, new MutableDouble());
minCapacity.get(layerId).put(linkId, new MutableDouble(Double.MAX_VALUE));
maxCapacity.get(layerId).put(linkId, new MutableDouble());
accum_avgLinkOccupiedCapacity.get(layerId).put(linkId, new MutableDouble());
minLinkOccupiedCapacity.get(layerId).put(linkId, new MutableDouble(Double.MAX_VALUE));
maxLinkOccupiedCapacity.get(layerId).put(linkId, new MutableDouble());
accum_avgUtilization.get(layerId).put(linkId, new MutableDouble());
minUtilization.get(layerId).put(linkId, new MutableDouble(Double.MAX_VALUE));
maxUtilization.get(layerId).put(linkId, new MutableDouble());
accum_avgOversubscribedCapacity.get(layerId).put(linkId, new MutableDouble());
minOversubscribedCapacity.get(layerId).put(linkId, new MutableDouble(Double.MAX_VALUE));
maxOversubscribedCapacity.get(layerId).put(linkId, new MutableDouble());
accum_linkOversubscribedTime.get(layerId).put(linkId, new MutableDouble());
accum_linkUpTime.get(layerId).put(linkId, new MutableDouble());
accum_linkTotalTime.get(layerId).put(linkId, new MutableDouble());
}
}
示例4: checkAndCreateNode
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private void checkAndCreateNode(long layerId, long nodeId)
{
if (!accum_avgNodeInDegree.get(layerId).containsKey(nodeId))
{
accum_avgNodeInDegree.get(layerId).put(nodeId, new MutableDouble());
minNodeInDegree.get(layerId).put(nodeId, Integer.MAX_VALUE);
maxNodeInDegree.get(layerId).put(nodeId, 0);
accum_avgNodeOutDegree.get(layerId).put(nodeId, new MutableDouble());
minNodeOutDegree.get(layerId).put(nodeId, Integer.MAX_VALUE);
maxNodeOutDegree.get(layerId).put(nodeId, 0);
accum_avgNodeIngressTraffic.get(layerId).put(nodeId, new MutableDouble());
maxNodeIngressTraffic.get(layerId).put(nodeId, 0.0);
minNodeIngressTraffic.get(layerId).put(nodeId, Double.MAX_VALUE);
accum_avgNodeEgressTraffic.get(layerId).put(nodeId, new MutableDouble());
maxNodeEgressTraffic.get(layerId).put(nodeId, 0.0);
minNodeEgressTraffic.get(layerId).put(nodeId, Double.MAX_VALUE);
}
}
示例5: SumTest
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
@Test
public void SumTest()
{
SumInt si = new SumInt();
SumLong sl = new SumLong();
SumFloat sf = new SumFloat();
SumDouble sd = new SumDouble();
Assert.assertEquals(new MutableInt(10), si.accumulate(si.defaultAccumulatedValue(), 10));
Assert.assertEquals(new MutableInt(11), si.accumulate(new MutableInt(1), 10));
Assert.assertEquals(new MutableInt(22), si.merge(new MutableInt(1), new MutableInt(21)));
Assert.assertEquals(new MutableLong(10L), sl.accumulate(sl.defaultAccumulatedValue(), 10L));
Assert.assertEquals(new MutableLong(22L), sl.accumulate(new MutableLong(2L), 20L));
Assert.assertEquals(new MutableLong(41L), sl.merge(new MutableLong(32L), new MutableLong(9L)));
Assert.assertEquals(new MutableFloat(9.0F), sf.accumulate(sf.defaultAccumulatedValue(), 9.0F));
Assert.assertEquals(new MutableFloat(22.5F), sf.accumulate(new MutableFloat(2.5F), 20F));
Assert.assertEquals(new MutableFloat(41.0F), sf.merge(new MutableFloat(33.1F), new MutableFloat(7.9F)));
Assert.assertEquals(new MutableDouble(9.0), sd.accumulate(sd.defaultAccumulatedValue(), 9.0));
Assert.assertEquals(new MutableDouble(22.5), sd.accumulate(new MutableDouble(2.5), 20.0));
Assert.assertEquals(new MutableDouble(41.0), sd.merge(new MutableDouble(33.1), new MutableDouble(7.9)));
}
示例6: addObservation
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
/**
* Do gradient descent on the weights of each basis
*
* @param observation
* @param fisher
* @param model
*/
@Override
public void addObservation(
GeographicalObservation<Double> observation, Fisher fisher, FishState model)
{
//get x and y
double[] x = extractObservation(observation.getTile(), observation.getTime(),
fisher, model);
double y = observation.getValue();
//now get prediction
double prediction = predict(x);
//gradient descent!
double increment = learningRate * (y-prediction);
for(Pair<RBFBasis,MutableDouble> basis : network)
{
//todo you can make this faster by storing the evaluate from the predict call!
basis.getSecond().setValue(basis.getSecond().doubleValue() + increment * basis.getFirst().evaluate(x));
}
}
示例7: computeTotalUsingIterator
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
protected static double computeTotalUsingIterator(final ChronicleMap<LongValue, PortfolioAssetInterface> cache, int start, int end)
{
if (end > start)
{
final PortfolioAssetInterface asset = Values.newHeapInstance(PortfolioAssetInterface.class);
PortfolioValueAccumulator accumulator = new PortfolioValueAccumulator(new MutableDouble(), asset);
for (int s = start; s < end; s++)
{
try (MapSegmentContext<LongValue, PortfolioAssetInterface, ?> context = cache.segmentContext(s))
{
context.forEachSegmentEntry(accumulator);
}
}
return accumulator.total.doubleValue();
}
return 0;
}
示例8: findBestClusterToMerge
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private Pair<Integer, Double> findBestClusterToMerge(int origCluster, int minCluster, int maxCluster, ContextCounts clusterContextCounts) {
MutableDouble bestScore = new MutableDouble(-Double.MAX_VALUE);
MutableInt bestCluster = new MutableInt(-1);
Utils.fasterParallelStream(clusterContextCounts.getAllClusters()).forEach(cluster -> {
if (cluster >= minCluster && cluster < maxCluster && cluster != origCluster) {
double score = computeMergeScore(origCluster, 0.0, cluster, clusterContextCounts);
if (score > bestScore.doubleValue()) {
synchronized (bestScore) {
if (score > bestScore.doubleValue()) { //bestScore might have changed while acquiring lock
bestScore.setValue(score);
bestCluster.setValue(cluster);
}
}
}
}
});
return new Pair<>(bestCluster.intValue(), bestScore.doubleValue());
}
示例9: searchJams
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
public static StopModel searchJams(TrafficJamModel[] jams, String lineID, int direction, MutableInt jammedStopIndex, MutableDouble jammedStopDelay, String[] jammedStopTitle)
{
for(TrafficJamModel jam : jams)
{
for(int i = 0 ; i < jam.slowVehicles.length; i++)
{
if(jam.slowVehicles[i].lineID.equals(lineID))
{
if(jam.slowVehicles[i].direction == direction){
jammedStopIndex.setValue(i);
jammedStopDelay.setValue(jam.cumulativeDelays[i]);
jammedStopTitle[0] = jam.vehicleStops[i].name;
return jam.vehicleStops[i];
}
}
}
}
return null;
}
示例10: helpGradByFiniteDiffs
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private void helpGradByFiniteDiffs(Algebra tmpS) {
Tensor t1 = new Tensor(s, 4,4);
Identity<Tensor> id1 = new Identity<Tensor>(t1);
Identity<Tensor> temp = new Identity<Tensor>(Tensor.getScalarTensor(s, 2));
SoftmaxMbrDepParse ea = new SoftmaxMbrDepParse(id1, temp, tmpS);
int numParams = ModuleFn.getOutputSize(ea.getInputs());
IntDoubleDenseVector x = ModuleTestUtils.getAbsZeroOneGaussian(numParams);
final MutableDouble sum = new MutableDouble(0);
x.iterate(new FnIntDoubleToVoid() {
public void call(int idx, double val) {
sum.add(val);
}
});
x.scale(-1.0/sum.doubleValue());
ModuleTestUtils.assertGradientCorrectByFd(ea, x, 1e-8, 1e-5);
}
示例11: setAngledSprite
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
protected void setAngledSprite(SpriteList sprite) {
MutableDouble angle = new MutableDouble(Math.toDegrees(Math.atan2(velY, velX)));
Map<BodyPart, SpriteRelation> angledSprite = new HashMap<BodyPart, SpriteRelation>();
angledSprite.put(BodyPart.MAIN, new AngledSpriteRelation(new Sprite(sprite), this, angle, 0, 0,
this.bounds.getWidth(), this.bounds.getHeight(), this.bounds.posX(), this.bounds.posY()));
setAdditionalSprites(angledSprite);
}
示例12: progressMonotonicallyGrows
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
@Test
public void progressMonotonicallyGrows() {
MutableDouble lastProgress = new MutableDouble(-Double.MAX_VALUE);
AtomicReference<String> lastOperation = new AtomicReference<String>("");
mergeManager.addProgressListener((progress, operation) -> {
if (!lastOperation.get().equals(operation))
lastOperation.set(operation);
else
assertThat(progress, greaterThanOrEqualTo(lastProgress.getValue()));
lastProgress.setValue(progress);
});
mergeManager.execute();
}
示例13: subtractPoint
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
private void subtractPoint(final Integer index, final MutableDouble value) {
data.compute(
index,
(i, v) -> {
v.subtract(value);
return v;
});
}
示例14: fromString
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
/**
* @param rivString : A string representation of a RIV, generally got by calling RIV.toString().
* @return a MapRIV
*/
public static MapRIV fromString(final String rivString) {
String[] pointStrings = rivString.split(" ");
final int last = pointStrings.length - 1;
final int size = Integer.parseInt(pointStrings[last]);
pointStrings = Arrays.copyOf(pointStrings, last);
final ConcurrentHashMap<Integer, MutableDouble> elts = new ConcurrentHashMap<>();
for (final String s : pointStrings) {
final String[] elt = s.split("\\|");
if (elt.length != 2) throw new IndexOutOfBoundsException("Wrong number of partitions: " + s);
else elts.put(Integer.parseInt(elt[0]), new MutableDouble(Double.parseDouble(elt[1])));
}
return new MapRIV(elts, size).destructiveRemoveZeros();
}
示例15: mapByGeoHash
import org.apache.commons.lang3.mutable.MutableDouble; //导入依赖的package包/类
/**
* Group the points with similar Geohash at specified level
*
* @param points
* @param level Geohash level
* @return
*/
private Map<String, MutableDouble> mapByGeoHash(List<GeoPoint> points, int level) {
if (level < 1 || points == null)
throw new IllegalArgumentException();
Map<String, MutableDouble> hashPoints = new HashMap<String, MutableDouble>();
for (GeoPoint point : points) {
try {
// Calculate geo hash
String hash = GeohashUtils.encodeLatLon(point.getLatitude(), point.getLongitude());
// Cut to geo hash level
hash = hash.substring(0, level);
// Group values
MutableDouble val = hashPoints.get(hash);
if (val == null) {
hashPoints.put(hash, new MutableDouble(point.getValue()));
} else {
val.add(point.getValue());
}
} catch (Exception e) {
log.error(e);
}
}
return hashPoints;
}