MulticastDemand extends NetworkElement implements IMonitorizableElement { public Pair<SortedSet<MulticastTree>,Double> computeMinimumCostMulticastTrees (double [] costs) { checkAttachedToNetPlanObject(); if (costs == null) costs = DoubleUtils.ones(layer.links.size ()); else if (costs.length != layer.links.size()) throw new Net2PlanException ("The array of costs must have the same length as the number of links in the layer"); SortedSet<MulticastTree> minCostTrees = new TreeSet<MulticastTree> (); double minCost = Double.MAX_VALUE; for (MulticastTree t : cache_multicastTrees) { double cost = 0; for (Link link : t.linkSet) cost += costs [link.index]; if (cost < minCost) { minCost = cost; minCostTrees.clear(); minCostTrees.add (t); } else if (cost == minCost) { minCostTrees.add (t); } } return Pair.of(minCostTrees , minCost); } MulticastDemand(NetPlan netPlan , long id , int index , NetworkLayer layer , Node ingressNode , Set<Node> egressNodes , double offeredTraffic , AttributeMap attributes); void setMaximumAcceptableE2EWorstCaseLatencyInMs(double maxLatencyMs); double getMaximumAcceptableE2EWorstCaseLatencyInMs(); void setQoSType(String newQosType); String getQosType(); void setOfferedTrafficPerPeriodGrowthFactor(double growthFactor); double getOfferedTrafficPerPeriodGrowthFactor(); NetworkLayer getLayer(); double getWorseCasePropagationTimeInMs(); double getWorstCaseLengthInKm(); boolean isTraversingOversubscribedLinks(); Node getIngressNode(); SortedSet<Node> getEgressNodes(); double getOfferedTraffic(); double getCarriedTraffic(); double getBlockedTraffic(); Pair<SortedSet<MulticastTree>,Double> computeMinimumCostMulticastTrees(double [] costs); boolean isBifurcated(); boolean isBlocked(); SortedSet<MulticastTree> getMulticastTrees(); boolean isAllTreesReachingAllEgressNodes(); void couple(Set<Link> links); SortedSet<Link> coupleToNewLinksCreated(NetworkLayer newLinkLayer); SortedSet<Link> getCoupledLinks(); boolean isCoupled(); void decouple(); void remove(); void setOfferedTraffic(double offeredTraffic); String toString(); SortedMap<Link, Double> getTraversedLinksAndCarriedTraffic(final boolean normalizedToOfferedTraffic); SortedSet<Link> getLinksNoDownPropagationPotentiallyCarryingTraffic(Node egressNode); TrafficSeries getMonitoredOrForecastedOfferedTraffic(); void setMonitoredOrForecastedOfferedTraffic(TrafficSeries newTimeSeries); @Override TrafficSeries getMonitoredOrForecastedCarriedTraffic(); @Override void setMonitoredOrForecastedCarriedTraffic(TrafficSeries newTimeSeries); @Override double getCurrentTrafficToAddMonitSample(); @Override boolean isPossibleToSetCurrentTrafficAsGivenMonitSample(); @Override void setCurrentTrafficToGivenMonitSample(double traffic); @Override Optional<TrafficPredictor> getTrafficPredictor(); @Override void setTrafficPredictor(TrafficPredictor tp); @Override void removeTrafficPredictor();  }
@Test public void testComputeMinimumCostMulticastTrees() { SortedSet<MulticastTree> twoTrees = new TreeSet<MulticastTree> (Arrays.asList(tStar , t123)); assertEquals (d123.computeMinimumCostMulticastTrees(null) , Pair.of(twoTrees , 2.0)); assertEquals (d123.computeMinimumCostMulticastTrees(new double [] { 1.0,2.0,1.0}) , Pair.of(new TreeSet<MulticastTree> (Arrays.asList(tStar)) , 2.0)); }