List of usage examples for com.google.common.collect Range closedOpen
public static <C extends Comparable<?>> Range<C> closedOpen(C lower, C upper)
From source file:client.ChainExp.java
public static void main(String[] args) { final Range<Integer> numAgents = Range.closedOpen(1000, 10001); final int runs = 10; final int A = 4; final int B = 0; final int maxTimeSteps = 1200000; ExtendedGraph g = new ExtendedGraph("Chain Experiment"); Simulator sim = new Simulator(g, numAgents, A, B, maxTimeSteps, runs, Level.OFF); sim.generateGraphChain(2, false, false, false); sim.agentDistribution(Distribution.SINGLE); sim.setSingleAgentDistNodeID("0"); sim.nodeSelection(NodeSelection.WEIGHTED); sim.execute();/*from w ww. j av a 2s . co m*/ }
From source file:client.OriginalPaper.java
public static void main(String[] args) { final Range<Integer> numAgents = Range.closedOpen(1000, 10001); final int runs = 10; final int A = 4; final int B = 0; final int maxTimeSteps = 600000; ExtendedGraph g = new ExtendedGraph("Original Paper"); g.addNode("A"); Simulator sim = new Simulator(g, numAgents, A, B, maxTimeSteps, runs, Level.OFF); sim.agentDistribution(Distribution.SINGLE); sim.setSingleAgentDistNodeID("A"); sim.nodeSelection(NodeSelection.NON_WEIGHTED); sim.execute();//from w ww . ja v a2 s .co m }
From source file:client.Visualization.java
public static void main(String[] args) { final Range<Integer> numAgents = Range.closedOpen(1000, 1001); final int runs = 1; final int A = 4; final int B = 0; final int maxTimeSteps = 100000; final double interactProbability = 0.25; final double traversalProbability = 0.75; ExtendedGraph g = new ExtendedGraph("Visualization"); Simulator sim = new Simulator(g, numAgents, A, B, maxTimeSteps, runs, Level.INFO); sim.generateGraphChain(10, true, true, false); sim.agentDistribution(Distribution.EVEN_SPREAD); sim.nodeSelection(NodeSelection.NON_WEIGHTED); sim.setActionProbabilites(interactProbability, traversalProbability); sim.simDescription("Description about the test"); /*/*from w ww . ja va 2 s. co m*/ * Turn on graph visualization */ sim.vis(); /* * Turn on charts, as in display them */ sim.charts(); sim.execute(); }
From source file:client.SampleClient.java
public static void main(String[] args) { /**// w w w . j a v a 2 s . c o m * How many agents should be used in the simulation? * * This is defined as a range, and thus could be a single value or * more. If its is more than one (a range), for example 5 to 10, then a * simulation is performed for each value within that range. See 'runs' * variable below for more. * * The range object is configurable. See details in the link below. * * https://code.google.com/p/guava-libraries/wiki/RangesExplained#Building_Ranges */ final Range<Integer> numAgents = Range.closedOpen(1000, 1001); /** * Number of simulation runs to occur at each value in the range of the * number of agents. So for example, if the range of the number of * agents is from 5 to 10, then 10 simulations will be run * for each value of agents within that range. */ final int runs = 1; /** * Values for terms A & B in the election process completion estimate * equation. They are buffer factors. See paper for more. * * A: multiplicative factor * B: additive factor */ final int A = 4; final int B = 0; /** * What is the maximum number of timesteps that a simulation can run * for? This is a safety parameter to cut off a simulation that is * running too long. * * Steps is defined as the number of interactions + traversals. So on * any iteration of the simulation, there is a 50/50 chance that either * an interaction or traversal will occur. That is assuming of course * a traversal is possible. If it is not, the simulator will detect * this, and all timesteps will be simply interactions. */ final int maxTimeSteps = 100000; /** * Probabilities for the possible actions on every timestep. Must add * up to 1.0 (100%). */ final double interactProbability = 0.25; final double traversalProbability = 0.75; // Create a graph ExtendedGraph g = new ExtendedGraph("Client"); // Create a new simulation Simulator sim = new Simulator(g, numAgents, A, B, maxTimeSteps, runs, Level.INFO); /* * Configure simulation settings * */ // Use a graph generator to auto create a graph. In this case, a chain sim.generateGraphChain(10, true, true, false); // Define how agents should be spread across the graph sim.agentDistribution(Distribution.EVEN_SPREAD); // Define how a node should be selected on every time step sim.nodeSelection(NodeSelection.WEIGHTED); // Set the probabilities for the possible actions sim.setActionProbabilites(interactProbability, traversalProbability); // Run the simulation sim.execute(); }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.ProposalMatchers.java
public static ProposalMatcher prefixesMatcher() { return new ProposalMatcher() { @Override/* w w w. j a v a 2s . c om*/ public Optional<ProposalMatch> matches(final String userContent, final String proposalContent) { if (proposalContent.toLowerCase().startsWith(userContent.toLowerCase())) { return Optional.of(new ProposalMatch(Range.closedOpen(0, userContent.length()))); } else { return Optional.empty(); } } }; }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.Commons.java
static ProposalMatcher substringMatcher() { return new ProposalMatcher() { @Override/*w w w. java2 s .c o m*/ public Optional<ProposalMatch> matches(final String userContent, final String proposalContent) { if (proposalContent.toLowerCase().contains(userContent.toLowerCase())) { final int index = proposalContent.toLowerCase().indexOf(userContent.toLowerCase()); return Optional.of(new ProposalMatch(Range.closedOpen(index, index + userContent.length()))); } return Optional.empty(); } }; }
From source file:com.google.googlejavaformat.java.Replacement.java
public static Replacement create(int startPosition, int endPosition, String replaceWith) { return new Replacement(Range.closedOpen(startPosition, endPosition), replaceWith); }
From source file:org.nickelproject.util.sources.Sequences.java
public static Source<Integer> integer(final int min, final int max) { return Sources.from(ContiguousSet.create(Range.closedOpen(min, max), DiscreteDomain.integers())); }
From source file:com.pingcap.tikv.util.KeyRangeUtils.java
public static Range toRange(Coprocessor.KeyRange range) { if (range == null || (range.getStart().isEmpty() && range.getEnd().isEmpty())) { return Range.all(); }/*from w ww. ja v a 2 s . c o m*/ if (range.getStart().isEmpty()) { return Range.lessThan(Comparables.wrap(range.getEnd())); } if (range.getEnd().isEmpty()) { return Range.atLeast(Comparables.wrap(range.getStart())); } return Range.closedOpen(Comparables.wrap(range.getStart()), Comparables.wrap(range.getEnd())); }
From source file:org.robotframework.ide.eclipse.main.plugin.assist.ProposalMatchers.java
public static ProposalMatcher caseSensitivePrefixesMatcher() { return new ProposalMatcher() { @Override/* ww w . j a v a 2s. com*/ public Optional<ProposalMatch> matches(final String userContent, final String proposalContent) { if (proposalContent.startsWith(userContent)) { return Optional.of(new ProposalMatch(Range.closedOpen(0, userContent.length()))); } else { return Optional.empty(); } } }; }