List of usage examples for com.google.common.collect ArrayTable create
public static <R, C, V> ArrayTable<R, C, V> create(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys)
From source file:org.matsim.contrib.util.random.WeightedRandomSelectionTable.java
public static <R, C, V> WeightedRandomSelectionTable<R, C, V> createWithArrayTable( Iterable<? extends R> rowKeys, Iterable<? extends C> colKeys) { Table<R, C, WeightedRandomSelection<V>> selectionTable = ArrayTable.create(rowKeys, colKeys); return new WeightedRandomSelectionTable<R, C, V>(selectionTable); }
From source file:org.softinica.maven.jmeter.report.model.Table.java
public Table(Iterable<? extends Object> rowKeys, Iterable<String> columnKeys) { table = ArrayTable.create(rowKeys, columnKeys); }
From source file:abs.frontend.delta.TopologicalSorting.java
public TopologicalSorting(Set<T> nodes) { this.nodes = nodes; if (nodes.size() == 0) { preferredOrder = Collections.emptyList(); incidence = null;// ww w . ja v a 2s.c o m return; } incidence = ArrayTable.create(nodes, nodes); for (T cn : nodes) for (T rn : nodes) incidence.put(cn, rn, false); partition = new ArrayList<Set<T>>(); }
From source file:org.abs_models.frontend.delta.TopologicalSorting.java
public TopologicalSorting(Set<T> nodes) { this.nodes = nodes; if (nodes.size() == 0) { partition = Collections.emptyList(); preferredOrder = Collections.emptyList(); incidence = null;// w ww .j av a2 s . c o m return; } incidence = ArrayTable.create(nodes, nodes); for (T cn : nodes) for (T rn : nodes) incidence.put(cn, rn, false); partition = new ArrayList<>(); }
From source file:eu.lp0.cursus.scoring.scores.base.AbstractRaceLapsData.java
private void calculateRaceLaps() { raceLaps = ArrayTable.create(scores.getRaces(), scores.getPilots()); raceLapOrder = new HashMap<Race, List<Pilot>>(scores.getRaces().size() * 2); for (Race race : scores.getRaces()) { raceLapOrder.put(race, calculateRaceLapsInOrder(race, raceLaps.row(race))); }// w ww. j a v a 2 s .co m }
From source file:com.github.lukaszkusek.xml.comparator.comparators.children.cost.CostMatrix.java
private CostMatrix(Collection<INode> children1, Collection<INode> children2) { costMatrix = ArrayTable.create(children1, children2); }
From source file:org.sonar.server.measure.live.MeasureMatrix.java
MeasureMatrix(Collection<ComponentDto> components, Collection<MetricDto> metrics, List<LiveMeasureDto> dbMeasures) { for (MetricDto metric : metrics) { this.metricsByKeys.put(metric.getKey(), metric); this.metricsByIds.put(metric.getId(), metric); }//from w ww. j a v a 2 s . c o m this.table = ArrayTable.create(Collections2.transform(components, ComponentDto::uuid), metricsByKeys.keySet()); for (LiveMeasureDto dbMeasure : dbMeasures) { table.put(dbMeasure.getComponentUuid(), metricsByIds.get(dbMeasure.getMetricId()).getKey(), new MeasureCell(dbMeasure, false)); } }
From source file:org.matsim.contrib.dvrp.path.ManyToManyPathData.java
private Table<Id<Link>, Id<Link>, PathData>[] createTables(List<Link> links) { ImmutableList<Id<Link>> linkIds = links.stream().map(l -> l.getId()) .collect(ImmutableList.toImmutableList()); @SuppressWarnings("unchecked") Table<Id<Link>, Id<Link>, PathData>[] tables = new Table[discretizer.getIntervalCount()]; for (int i = 0; i < tables.length; i++) { tables[i] = ArrayTable.create(linkIds, linkIds); }//w w w . j a v a 2 s. c o m return tables; }
From source file:eu.itesla_project.mcla.forecast_errors.HistoricalDataCreator.java
private ForecastErrorsHistoricalData loadHistoricalDataFromCsvFile(Path historicalDataCsvFile, ArrayList<String> generatorsIds, ArrayList<String> loadsIds, ArrayList<StochasticVariable> stochasticVariables) throws IOException { ForecastErrorsHistoricalData forecastErrorsHistoricalData = null; Integer rowsIndexes[] = getRowsIndexes(historicalDataCsvFile); String columnsIndexes[] = getColumnsIndexes(generatorsIds, loadsIds); ArrayTable<Integer, String, Float> forecastsData = ArrayTable.create(Arrays.asList(rowsIndexes), Arrays.asList(columnsIndexes)); ArrayTable<Integer, String, Float> snapshotsData = ArrayTable.create(Arrays.asList(rowsIndexes), Arrays.asList(columnsIndexes)); ICsvMapReader csvMapReader = null;// w w w . j a v a 2s .c o m int rowcount = 0; boolean odd = false; try { csvMapReader = new CsvMapReader(new FileReader(historicalDataCsvFile.toFile()), CsvPreference.STANDARD_PREFERENCE); final String[] headers = csvMapReader.getHeader(true); final CellProcessor[] rowProcessors = new CellProcessor[headers.length]; Map<String, Object> componentMap; while ((componentMap = csvMapReader.read(headers, rowProcessors)) != null) { String datetime = (String) componentMap.get("datetime"); int forecastTime = (int) Float.parseFloat((String) componentMap.get("forecastTime")); if (forecastTime == 0) { snapshotsData.put(rowcount, "datetime", Float.valueOf(datetime)); snapshotsData.put(rowcount, "forecastTime", new Float(forecastTime)); } else { forecastsData.put(rowcount, "datetime", Float.valueOf(datetime)); forecastsData.put(rowcount, "forecastTime", new Float(forecastTime)); } for (String generatorId : generatorsIds) { // generators active power String activePowerValue = (String) componentMap.get(generatorId + "_P"); if (forecastTime == 0) snapshotsData.put(rowcount, generatorId + "_P", (activePowerValue != null) ? Float.valueOf(activePowerValue) : Float.NaN); else forecastsData.put(rowcount, generatorId + "_P", (activePowerValue != null) ? Float.valueOf(activePowerValue) : Float.NaN); // generators reactive power String reactivePowerValue = (String) componentMap.get(generatorId + "_Q"); if (forecastTime == 0) snapshotsData.put(rowcount, generatorId + "_Q", (reactivePowerValue != null) ? Float.valueOf(reactivePowerValue) : Float.NaN); else forecastsData.put(rowcount, generatorId + "_Q", (reactivePowerValue != null) ? Float.valueOf(reactivePowerValue) : Float.NaN); } for (String loadId : loadsIds) { // loads active power String activePowerValue = (String) componentMap.get(loadId + "_P"); if (forecastTime == 0) snapshotsData.put(rowcount, loadId + "_P", (activePowerValue != null) ? Float.valueOf(activePowerValue) : Float.NaN); else forecastsData.put(rowcount, loadId + "_P", (activePowerValue != null) ? Float.valueOf(activePowerValue) : Float.NaN); // loads reactive power String reactivePowerValue = (String) componentMap.get(loadId + "_Q"); if (forecastTime == 0) snapshotsData.put(rowcount, loadId + "_Q", (reactivePowerValue != null) ? Float.valueOf(reactivePowerValue) : Float.NaN); else forecastsData.put(rowcount, loadId + "_Q", (reactivePowerValue != null) ? Float.valueOf(reactivePowerValue) : Float.NaN); } if (odd) { rowcount++; odd = false; } else { odd = true; } } LOGGER.info("Loaded {} records of historical data from csv file {}", rowcount, historicalDataCsvFile.toString()); } catch (IOException e) { LOGGER.error("Error loading historical data from cvs file" + historicalDataCsvFile.toString() + ": " + e.getMessage()); throw e; } finally { if (csvMapReader != null) try { csvMapReader.close(); } catch (IOException e) { LOGGER.error("Error closing CSV map reader: " + e.getMessage()); } } forecastErrorsHistoricalData = new ForecastErrorsHistoricalData(generatorsIds, loadsIds, stochasticVariables, forecastsData, snapshotsData); return forecastErrorsHistoricalData; }
From source file:org.age.util.fsm.StateMachineServiceBuilder.java
StateMachineServiceBuilder(@NonNull final Class<S> states, @NonNull final Class<E> events) { stateClass = requireNonNull(states); eventClass = requireNonNull(events); transitions = ArrayTable.create(EnumSet.allOf(stateClass), EnumSet.allOf(eventClass)); actions = ArrayTable.create(EnumSet.allOf(stateClass), EnumSet.allOf(eventClass)); noStateTransitions = newEnumMap(eventClass); noStateActions = newEnumMap(eventClass); }