List of usage examples for org.apache.commons.collections15.map HashedMap HashedMap
public HashedMap()
From source file:com.jgoetsch.ib.handlers.SingleHandlerManager.java
public SingleHandlerManager() { handlerMap = MultiKeyMap.decorate(new HashedMap<MultiKey<Object>, EWrapper>()); handlerReverseMap = new MultiHashMap<EWrapper, MultiKey<Object>>(); }
From source file:geneaquilt.algorithms.LayerClusterer.java
/** * Assign ranks to a connected component * @param graph the graph/*from ww w .ja v a2 s .c o m*/ * @param comp the component * @return an ordered list of vertices with the same rank */ public List<Set<V>> rank(DirectedGraph<V, E> graph, Collection<V> comp) { this.graph = graph; this.rank = new HashedMap<V, Integer>(); this.maxRank = 0; //Tree<V, E> tree = feasibleTree(comp); //TODO return null; }
From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.ClearingGiltsBondsAndCommercialLoansMarket.java
@Inject public ClearingGiltsBondsAndCommercialLoansMarket(@Assisted final String marketName, @Assisted final ClearingHouse clearingHouse) { super(marketName, clearingHouse); this.bankIsParticipating = new HashMap<String, Boolean>(); this.firmIsParticipating = new HashMap<String, Boolean>(); this.fundIsParticipating = new HashMap<String, Boolean>(); this.commercialLoanRiskGrades = Arrays.asList("Low Risk", "Medium Risk", "High Risk"); this.instruments = new HashMap<String, ClearingInstrument>(); this.lastTradeVolumes = new HashMap<ClearingInstrument, Double>(); this.lastTradeWeightedReturnRates = new HashMap<ClearingInstrument, Double>(); this.commericalLoanClientRiskBuckets = new HashedMap<String, List<ClearingMarketParticipant>>(); for (final String riskGrade : commercialLoanRiskGrades) addInstrument(riskGrade + " Commercial Loan", instruments); addInstrument("Gilt", instruments); addInstrument("Bank Bond", instruments); for (final ClearingInstrument instrument : instruments.values()) { lastTradeVolumes.put(instrument, 0.); lastTradeWeightedReturnRates.put(instrument, 0.); }/* w w w. j a va2 s. c o m*/ }
From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.ClearingGiltsBondsAndCommercialLoansMarket.java
/** * Process the Commerical Loan/Bond market and commit to contracts. *//*from ww w. j a v a 2 s . c o m*/ @Override public void process() { final ResourceExchangeAggregator bondTradeAggregator = new SimpleResourceExchangeAggregator(); final Map<String, ResourceExchangeAggregator> gradedCommercianLoanAggregators = new HashedMap<String, ResourceExchangeAggregator>(); final ResourceExchangeAggregator giltTradeAggregator = new SimpleResourceExchangeAggregator(); // Build network MixedClearingNetwork.Builder networkBuilder = new MixedClearingNetwork.Builder(); // Add risk grades for commerical loan consumers. for (final String riskGrade : commercialLoanRiskGrades) commericalLoanClientRiskBuckets.put(riskGrade, new ArrayList<ClearingMarketParticipant>()); for (final String riskGrade : commericalLoanClientRiskBuckets.keySet()) { gradedCommercianLoanAggregators.put(riskGrade, new SimpleResourceExchangeAggregator()); } bankIsParticipating.clear(); firmIsParticipating.clear(); fundIsParticipating.clear(); // Assign Firms to risk buckets assignCommericalLoanClientsToRiskBuckets(); // Install Banks, Firms and Funds int numSuppliers = addBondSuppliersToNetwork(networkBuilder), numConsumers = addCommercialLoanConsumersToNetwork(networkBuilder), numIntermediaries = addLoanRelayersToNetwork(networkBuilder); if (numSuppliers == 0 || numIntermediaries == 0 || numConsumers == 0) { System.out.printf("---------------------------------------------\n" + "Commercial Loan/Bond Network Cleared [Time: %g]\n" + " No trade pathways in this session.\n" + " Bond Suppliers: %d\n" + " Intermediaries: %d\n" + " Commercial Loan Consumers: %d\n" + "---------------------------------------------\n", Simulation.getTime(), numSuppliers, numIntermediaries, numConsumers); return; } final boolean doIncludeGiltSubnetwork = tryAddGovernmentNodeToNetwork(networkBuilder); // Connect Bond trade routes for banks and funds. addFundBondEdgesToNetwork(networkBuilder, bondTradeAggregator); // Create Commercial loan trade routes for firm and banks. addCommercialLoanEdgesToNetwork(networkBuilder, gradedCommercianLoanAggregators); // If applicable, create gilt/government bond trade routes for government. if (doIncludeGiltSubnetwork) addGovernmentBondSubnetworkEdges(networkBuilder, giltTradeAggregator); // Build the network and apply a clearing algorithm. final MixedClearingNetwork network = networkBuilder.build(); final MixedClearingNetworkAlgorithm clearingAlgorithm = new AdaptiveMarchHeterogeneousClearingAlgorithm(60, 1.e-8, new OrderOrIterationsStoppingCondition(10, 30, network)); network.applyClearingAlgorithm(clearingAlgorithm); network.createContracts(); // Commit bond trades commitBankBondContracts(bondTradeAggregator); // Commit commercial loan trades for (final Entry<String, ResourceExchangeAggregator> record : gradedCommercianLoanAggregators.entrySet()) { commitCommercialLoanContracts(record.getValue(), record.getKey()); } // If applicable, commit government gilt contracts if (doIncludeGiltSubnetwork) commitGovernmentBondContracts(giltTradeAggregator); commericalLoanClientRiskBuckets.clear(); }
From source file:be.fedict.eid.applet.maven.DocbookMojo.java
private static BasicVisualizationServer<String, String> createGraph() { AppletProtocolMessageCatalog catalog = new AppletProtocolMessageCatalog(); List<Class<?>> catalogClasses = catalog.getCatalogClasses(); Map<ProtocolState, List<String>> allowedProtocolStates = new HashedMap<ProtocolState, List<String>>(); String startMessage = null;/*from w w w. ja v a2 s.c o m*/ List<String> stopMessages = new LinkedList<String>(); Graph<String, String> graph = new SparseMultigraph<String, String>(); for (Class<?> messageClass : catalogClasses) { StartRequestMessage startRequestMessageAnnotation = messageClass .getAnnotation(StartRequestMessage.class); if (null != startRequestMessageAnnotation) { if (null != startMessage) { throw new RuntimeException("only one single entry point possible"); } startMessage = messageClass.getSimpleName(); } StopResponseMessage stopResponseMessageAnnotation = messageClass .getAnnotation(StopResponseMessage.class); if (null != stopResponseMessageAnnotation) { stopMessages.add(messageClass.getSimpleName()); } graph.addVertex(messageClass.getSimpleName()); ProtocolStateAllowed protocolStateAllowedAnnotation = messageClass .getAnnotation(ProtocolStateAllowed.class); if (null != protocolStateAllowedAnnotation) { ProtocolState protocolState = protocolStateAllowedAnnotation.value(); List<String> messages = allowedProtocolStates.get(protocolState); if (null == messages) { messages = new LinkedList<String>(); allowedProtocolStates.put(protocolState, messages); } messages.add(messageClass.getSimpleName()); } } int edgeIdx = 0; for (Class<?> messageClass : catalogClasses) { ResponsesAllowed responsesAllowedAnnotation = messageClass.getAnnotation(ResponsesAllowed.class); if (null != responsesAllowedAnnotation) { Class<?>[] responseClasses = responsesAllowedAnnotation.value(); for (Class<?> responseClass : responseClasses) { String edgeName = "edge-" + edgeIdx; graph.addEdge(edgeName, messageClass.getSimpleName(), responseClass.getSimpleName(), EdgeType.DIRECTED); edgeIdx++; } } StateTransition stateTransitionAnnotation = messageClass.getAnnotation(StateTransition.class); if (null != stateTransitionAnnotation) { ProtocolState protocolState = stateTransitionAnnotation.value(); List<String> messages = allowedProtocolStates.get(protocolState); for (String message : messages) { graph.addEdge("edge-" + edgeIdx, messageClass.getSimpleName(), message, EdgeType.DIRECTED); edgeIdx++; } } } Layout<String, String> layout = new CircleLayout<String, String>(graph); layout.setSize(new Dimension(900, 600)); BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<String, String>( layout); visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); Transformer<String, Paint> myVertexTransformer = new MyVertexTransformer(startMessage, stopMessages); visualization.getRenderContext().setVertexFillPaintTransformer(myVertexTransformer); Transformer<String, Paint> myEdgeTransformer = new MyEdgeTransformer(); visualization.getRenderContext().setEdgeDrawPaintTransformer(myEdgeTransformer); visualization.getRenderer().getVertexLabelRenderer().setPosition(Position.AUTO); visualization.setPreferredSize(new Dimension(900, 650)); visualization.setBackground(Color.WHITE); return visualization; }
From source file:test.be.fedict.eid.applet.JGraphTest.java
private BasicVisualizationServer<String, String> createGraph() { AppletProtocolMessageCatalog catalog = new AppletProtocolMessageCatalog(); List<Class<?>> catalogClasses = catalog.getCatalogClasses(); Map<ProtocolState, List<String>> allowedProtocolStates = new HashedMap<ProtocolState, List<String>>(); String startMessage = null;// w ww . jav a 2 s . c o m List<String> stopMessages = new LinkedList<String>(); Graph<String, String> graph = new SparseMultigraph<String, String>(); for (Class<?> messageClass : catalogClasses) { StartRequestMessage startRequestMessageAnnotation = messageClass .getAnnotation(StartRequestMessage.class); if (null != startRequestMessageAnnotation) { if (null != startMessage) { throw new RuntimeException("only one single entry point possible"); } startMessage = messageClass.getSimpleName(); } StopResponseMessage stopResponseMessageAnnotation = messageClass .getAnnotation(StopResponseMessage.class); if (null != stopResponseMessageAnnotation) { stopMessages.add(messageClass.getSimpleName()); } graph.addVertex(messageClass.getSimpleName()); ProtocolStateAllowed protocolStateAllowedAnnotation = messageClass .getAnnotation(ProtocolStateAllowed.class); if (null != protocolStateAllowedAnnotation) { ProtocolState protocolState = protocolStateAllowedAnnotation.value(); List<String> messages = allowedProtocolStates.get(protocolState); if (null == messages) { messages = new LinkedList<String>(); allowedProtocolStates.put(protocolState, messages); } messages.add(messageClass.getSimpleName()); } } LOG.debug("allowed protocol states: " + allowedProtocolStates); int edgeIdx = 0; for (Class<?> messageClass : catalogClasses) { ResponsesAllowed responsesAllowedAnnotation = messageClass.getAnnotation(ResponsesAllowed.class); if (null != responsesAllowedAnnotation) { Class<?>[] responseClasses = responsesAllowedAnnotation.value(); for (Class<?> responseClass : responseClasses) { graph.addEdge("edge-" + edgeIdx, messageClass.getSimpleName(), responseClass.getSimpleName(), EdgeType.DIRECTED); edgeIdx++; } } StateTransition stateTransitionAnnotation = messageClass.getAnnotation(StateTransition.class); if (null != stateTransitionAnnotation) { ProtocolState protocolState = stateTransitionAnnotation.value(); List<String> messages = allowedProtocolStates.get(protocolState); for (String message : messages) { graph.addEdge("edge-" + edgeIdx, messageClass.getSimpleName(), message, EdgeType.DIRECTED); edgeIdx++; } } } Layout<String, String> layout = new CircleLayout<String, String>(graph); layout.setSize(new Dimension(900, 650)); BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<String, String>( layout); visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); Transformer<String, Paint> myVertexTransformer = new MyVertexTransformer(startMessage, stopMessages); visualization.getRenderContext().setVertexFillPaintTransformer(myVertexTransformer); visualization.getRenderer().getVertexLabelRenderer().setPosition(Position.AUTO); visualization.setPreferredSize(new Dimension(900, 650)); visualization.setBackground(Color.WHITE); return visualization; }