Link extends NetworkElement implements IMonitorizableElement { public double getUtilization() { if ((capacity <= Configuration.precisionFactor) && (cache_totalOccupiedCapacity > Configuration.precisionFactor)) return Double.POSITIVE_INFINITY; return capacity <= Configuration.precisionFactor? 0 : cache_totalOccupiedCapacity / capacity; } protected  Link(NetPlan netPlan , long id , int index , NetworkLayer layer , Node originNode , Node destinationNode , double lengthInKm , double propagationSpeedInKmPerSecond , double capacity , AttributeMap attributes); Color getNominalColor(); void setNominalColor(Color nominalColor); double getOccupiedCapacityFromDemand(Demand d); Pair<Double,Double> getQosOccupationAndQosViolation(String qosType); Pair<Integer,Double> getQosTypePriorityAndMaxLinkUtilization(String qosType); SortedMap<String,Pair<Integer,Double>> getQosTypePriorityAndMaxLinkUtilizationMap(); void setQosTypePriorityAndMaxLinkUtilization(String qosType , int priority , double maxLinkUtilization); void removeQosTypePriorityAndMaxLinkUtilization(String qosType); SortedMap<String,Pair<Double,Double>> getPerQoSOccupationAndQosViolationMap(); SortedSet<Demand> getDemandsWithNonZeroForwardingRules(); Node getOriginNode(); Node getDestinationNode(); NetworkLayer getLayer(); Demand getCoupledDemand(); MulticastDemand getCoupledMulticastDemand(); boolean isCoupled(); SortedMap<Pair<Demand,Link>,Double> getForwardingRules(); double getCapacity(); void setCapacity(double newLinkCapacity); double getCarriedTraffic(); SortedSet<Route> getTraversingBackupRoutes(); int getNumberOfTraversingBackupRoutes(); double getUtilization(); double getOccupiedCapacity(); double getOccupiedCapacityOnlyBackupRoutes(); double getLengthInKm(); void setLengthInKm(double lengthInKm); double getPropagationSpeedInKmPerSecond(); double getMulticastCarriedTraffic(); double getMulticastOccupiedLinkCapacity(); void setPropagationSpeedInKmPerSecond(double speed); double getPropagationDelayInMs(); boolean isUp(); boolean isDown(); boolean isOversubscribed(); double getOversubscribedTraffic(); SortedSet<SharedRiskGroup> getSRGs(); SortedSet<Route> getTraversingRoutes(); SortedMap<Route,Integer> getTraversingRoutesAndMultiplicity(); int getNumberOfTraversingRoutes(); SortedSet<MulticastTree> getTraversingTrees(); int getNumberOfTraversingTrees(); int getNumberOfForwardingRules(); void coupleToLowerLayerDemand(Demand demand); Demand coupleToNewDemandCreated(NetworkLayer newDemandLayer , RoutingType routingTypeDemand); void removeAllForwardingRules(); Link getBidirectionalPair(); void setBidirectionalPair(Link e); boolean isBidirectional(); Link createBidirectionalPair(); void remove(); boolean setFailureState(boolean setAsUp); @Override String toString(); SortedSet<String> getQosViolated(); boolean isQoSViolated(String qosType); Triple<SortedSet<Demand>,SortedSet<Demand>,SortedSet<MulticastDemand>> getDemandsPotentiallyTraversingThisLink(); Triple<SortedMap<Demand,SortedSet<Link>>,SortedMap<Demand,SortedSet<Link>>,SortedMap<Pair<MulticastDemand,Node>,SortedSet<Link>>> getLinksThisLayerPotentiallyCarryingTrafficTraversingThisLink(); Triple<SortedMap<Demand,SortedSet<Link>>,SortedMap<Demand,SortedSet<Link>>,SortedMap<Pair<MulticastDemand,Node>,SortedSet<Link>>> getLinksDownPropagationPotentiallyCarryingTrafficTraversingThisLink(); boolean isCoupledInSameLayer(); boolean isCoupledInDifferentLayer(); void decouple(); @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 testGetUtilization() { assertEquals(link12.getUtilization() , (1.5+1.5+1.5+300+15+15) / 100 , 0.0001); assertEquals(link13.getUtilization() , (50.0+15.0) / 100.0 , 0.0001); }