private String getActivityType(String amenity){ String type = typeMap.get(amenity); if(type == null){ log.warn("Do not have an activity type mapping for " + amenity + "! Returning NULL."); } else{ } MapUtils.addToInteger(type, typeCount, 0, 1); return type; }
public void endInterval( final Location location, final double time) { final WrappedAroundIntervalSequence seq = MapUtils.getArbitraryObject( location, map, seqFactory); seq.endInterval( time ); } }
public void addJointPlan( final JointPlan jp ) { MapUtils.getCollection( jp.getIndividualPlans().keySet(), jointPlans ).add( jp ); }
public void addNonChainBasedTrip( final Trip t ) { MapUtils.getList( t.agentId , nonChainBasedModeTrips ).add( t ); } }
public PlanAllocation getCached( final List<PersonRecord> personsToAllocate, final Set<Id> allowedIncompatibilityGroups) { final PlanAllocation cached = MapUtils.getMap( personsToAllocate , cache ).get( allowedIncompatibilityGroups ); if ( cached == null ) return null; assert personsToAllocate.size() == cached.getPlans().size() : personsToAllocate.size()+" != "+cached.getPlans().size(); return SelectorUtils.copy( cached ); }
private static void pruneAtIndividualLevel( final IncompatiblePlanRecords incompatiblePlans, final PersonRecord person) { final Map<Set<Id<Person>>, Set<Set<Id>>> knownBranches = new HashMap< >(); double lastRecordWeight = Double.POSITIVE_INFINITY; final Iterator<PlanRecord> iterator = person.prunedPlans.iterator(); while ( iterator.hasNext() ) { final PlanRecord r = iterator.next(); assert r.individualPlanWeight <= lastRecordWeight : person.plans; lastRecordWeight = r.individualPlanWeight; final Set<Id<Person>> cotravs = r.jointPlan == null ? Collections.<Id<Person>>emptySet() : r.jointPlan.getIndividualPlans().keySet(); // only consider the best plan of each structure for each set of // incompatible plans. if ( !MapUtils.getSet( cotravs , knownBranches ).add( incompatiblePlans.getIncompatibilityGroups( r ) ) ) { iterator.remove(); } } } }
/** * Add a given value to the Double associated with the key in this map, or initialize a new one if no mapping exists * yet. * * @param key the key of the mapping * @param map the map in which to search * @param initialValue the value to which new entries should be initialized * @param toAdd the value to add to the existing mapped values * @param <K> type of the key * @return the collection (evt. newly) associated with the key */ public static <K> double addToDouble( final K key, final Map<K, Double> map, final double initialValue, final double toAdd) { final double newValue = getDouble( key , map , initialValue ) + toAdd; map.put( key , newValue ); return newValue; }
/** * Add a given value to the Integer associated with the key in this map, or initialize a new one if no mapping exists * yet. * * @param key the key of the mapping * @param map the map in which to search * @param initialValue the value to which new entries should be initialized * @param toAdd the value to add to the existing mapped values * @param <K> type of the key * @return the collection (evt. newly) associated with the key */ public static <K> double addToInteger( final K key, final Map<K, Integer> map, final int initialValue, final int toAdd) { final int newValue = getInteger( key , map , initialValue ) + toAdd; map.put( key , newValue ); return newValue; }
public double getScore() { final Map<Id, Double> timePerSocialContact = new HashMap<Id, Double>(); for ( Map.Entry<Location, WrappedAroundIntervalSequence> e : intervalsForEgo.map.entrySet() ) { final Location location = e.getKey(); final List<Interval> egoIntervals = e.getValue().getWrappedAroundSequence(); for (Map.Entry<Id, IntervalsAtLocation> e2 : intervalsPerAlter.entrySet() ) { final Id alter = e2.getKey(); final IntervalsAtLocation locatedAlterIntervals = e2.getValue(); final WrappedAroundIntervalSequence seq = locatedAlterIntervals.map.get( location ); if ( seq == null ) continue; final List<Interval> alterIntervals = seq.getWrappedAroundSequence(); final List<Interval> openingIntervals = getOpeningIntervals( location ); MapUtils.addToDouble( alter, timePerSocialContact, 0, calcOverlap( activeTimeWindow, openingIntervals, egoIntervals, alterIntervals ) ); } } double accumulatedUtility = 0; for ( Map.Entry<Id, Double> idAndTime : timePerSocialContact.entrySet() ) { accumulatedUtility += overlapScorer.getScore( idAndTime.getKey() , idAndTime.getValue() ); } return accumulatedUtility; }
MapUtils.get( ratioCalculator.getInternalizationNetwork().getAlters( ego.getId() ), sc.getPopulation().getPersons() );
public void addCarTrip( final Trip t ) { MapUtils.getList( t.agentId , carTrips ).add( t ); }
private void cacheUnfeasible( final List<PersonRecord> personsToAllocate, final Set<Id> allowedIncompatibilityGroups, final double minimalWeight) { final Map<Set<Id>, DecreasingDouble> map = MapUtils.getMap( personsToAllocate , unfeasible ); DecreasingDouble cachedWeight = map.get( allowedIncompatibilityGroups ); if ( cachedWeight == null ) { cachedWeight = new DecreasingDouble(); map.put( allowedIncompatibilityGroups , cachedWeight ); } cachedWeight.set( minimalWeight ); }
private static void pruneAtIndividualLevel( final IncompatiblePlanRecords incompatiblePlans, final PersonRecord person) { final Map<Set<Id<Person>>, Set<Set<Id>>> knownBranches = new HashMap< >(); double lastRecordWeight = Double.POSITIVE_INFINITY; final Iterator<PlanRecord> iterator = person.prunedPlans.iterator(); while ( iterator.hasNext() ) { final PlanRecord r = iterator.next(); assert r.avgJointPlanWeight <= lastRecordWeight : person.plans; lastRecordWeight = r.avgJointPlanWeight; final Set<Id<Person>> cotravs = r.jointPlan == null ? Collections.<Id<Person>>emptySet() : r.jointPlan.getIndividualPlans().keySet(); // only consider the best plan of each structure for each set of // incompatible plans. if ( !MapUtils.getSet( cotravs , knownBranches ).add( incompatiblePlans.getIncompatibilityGroups( r ) ) ) { iterator.remove(); } } } }
public void startInterval( final Location location, final double time) { final WrappedAroundIntervalSequence seq = MapUtils.getArbitraryObject( location, map, seqFactory); seq.startInterval( time ); }
public IncompatiblePlanRecords( final IncompatiblePlansIdentifier identifier, final Map<Id, PersonRecord> personRecords) { final HashSet<Id> ids = new HashSet<Id>(); this.allIncompatibilityGroupIds = Collections.unmodifiableSet( ids ); for ( PersonRecord person : personRecords.values() ) { for ( PlanRecord plan : person.plans ) { for ( Id group : identifyGroups( identifier , plan ) ) { MapUtils.getCollection( group , plansPerGroup ).add( plan ); ids.add( group ); } plan.setIncompatibilityGroups( identifyGroups( identifier , plan ) ); } } }
private String getActivityType(String osmValue, String osmKey){ String matsimType = typeMap.get(osmValue); if (matsimType == null) { if (useGeneralTypeIsSpecificTypeUnknown) { return osmKey; } else { LOG.info("Do not have an activity type mapping for " + osmValue + "! Returning NULL."); } } MapUtils.addToInteger(matsimType, typeCount, 0, 1); return matsimType; }
public JointTravelStructure( final List<JointTrip> jointTrips) { this.jointTrips = jointTrips; for (final JointTrip jt : jointTrips) { final List<JointTrip> trips = MapUtils.getList( new Couple( jt.getDriverId(), jt.getPassengerId() ), jointTripsPerCouple ); trips.add( jt ); } }
private void cacheFeasible( final List<PersonRecord> personsToAllocate, final Set<Id> allowedIncompatibilityGroups, final PlanAllocation allocation) { assert allocation != null; assert personsToAllocate.size() == allocation.getPlans().size() : personsToAllocate.size()+" != "+allocation.getPlans().size(); MapUtils.getMap( personsToAllocate , cache ).put( allowedIncompatibilityGroups, SelectorUtils.copy( allocation ) ); }