/** * Provides a {@link MASConfiguration} that configures a MAS that is * controlled centrally by a {@link Solver}. * @param solverCreator The solver creator to use for instantiating solvers. * @return A new configuration. */ public static MASConfiguration solverConfiguration( StochasticSupplier<? extends Solver> solverCreator) { return solverConfiguration(solverCreator, ""); }
/** * Test of {@link RandomMVArraysSolver} using the * {@link com.github.rinde.rinsim.central.arrays.MultiVehicleArraysSolver} * interface. */ @Test public void test() { Experiment.builder() .addScenario(scenario) .addConfiguration( Central.solverConfiguration(RandomMVArraysSolver.solverSupplier())) .repeat(!offline && allowDiversion ? 2 : 1) .perform(); }
/** * Test of {@link RandomSolver} on a scenario using the {@link Solver} * interface. */ @Test public void testRandomSolver() { Experiment.builder() .addScenario(scenario) .addConfiguration( Central.solverConfiguration(SolverValidator.wrap(RandomSolver .supplier()))) .repeat(3) .perform(); } }
/** * Tests whether the SolverConfigurator works. */ @Test public void testConfigurator() { final Gendreau06Scenario scenario = Gendreau06Parser.parse( new File(ScenarioPaths.GENDREAU)); final StochasticSupplier<Solver> s = new StochasticSupplier<Solver>() { @Override public Solver get(long seed) { return SolverValidator.wrap(new MultiVehicleSolverAdapter( ArraysSolverValidator.wrap(new RandomMVArraysSolver( new MersenneTwister(seed))), SI.MILLI(SI.SECOND))); } }; final Experiment.Builder builder = Experiment.builder() .addScenario(scenario) .addConfiguration(Central.solverConfiguration(s)) .withRandomSeed(123); final ExperimentResults res1 = builder.perform(); final ExperimentResults res2 = builder.perform(); assertEquals(res1.getResults(), res2.getResults()); }
.addConfiguration(Central.solverConfiguration(RandomSolver.supplier())) .withThreads(1) .usePostProcessor(
Experiment.builder() .withThreads(1) .addConfiguration(Central.solverConfiguration(dsc)) .addScenario(scenario) .repeat(10)
.instance(); final ExperimentResults results = Experiment.builder() .addConfiguration(Central.solverConfiguration(dsc)) .addScenario(scenario) .usePostProcessor(PostProcessors.statisticsPostProcessor(obj))
static StatisticsDTO simulate(Scenario scenario) { final ExperimentResults results = Experiment.builder() .addScenario(scenario) .addConfiguration(Central.solverConfiguration( StochasticSuppliers.constant(TestSolvers.lazyInsertion()))) .withThreads(1) .usePostProcessor(PostProcessors.statisticsPostProcessor(OBJ_FUNC)) .showGui(View.builder() .withAutoPlay() // .withAutoClose() .withSpeedUp(4) // .withFullScreen() .withTitleAppendix("AAMAS 2016 Experiment") .with(RoadUserRenderer.builder() .withToStringLabel()) .with(PDPModelRenderer.builder()) .with(RouteRenderer.builder()) .with(PlaneRoadModelRenderer.builder()) .with(TimeLinePanel.builder()) .withResolution(1280, 1024)) .showGui(false) .perform(); final SimulationResult res = results.getResults().iterator().next(); final StatisticsDTO stats = (StatisticsDTO) res.getResultObject(); return stats; }