/** * Tests that a custom scoring function factory doesn't get overwritten in the initialization * process of the Controler. * * @author mrieser */ @Test public void testSetScoringFunctionFactory() { final Config config = this.utils.loadConfig(null); config.controler().setLastIteration(0); ScenarioImpl scenario = (ScenarioImpl) ScenarioUtils.createScenario(config); // create a very simple network with one link only and an empty population Network network = scenario.getNetwork(); Node node1 = network.getFactory().createNode(Id.create(1, Node.class), new Coord(0, 0)); Node node2 = network.getFactory().createNode(Id.create(2, Node.class), new Coord(100, 0)); network.addNode(node1); network.addNode(node2); Link link = network.getFactory().createLink(Id.create(1, Link.class), node1, node2); link.setLength(100); link.setFreespeed(1); link.setCapacity(3600.0); link.setNumberOfLanes(1); final Controler controler = new Controler(scenario); controler.getConfig().controler().setCreateGraphs(false); controler.getConfig().controler().setWriteEventsInterval(0); controler.setScoringFunctionFactory(new DummyScoringFunctionFactory()); controler.addOverridingModule( new AbstractModule() { @Override public void install() { bindMobsim() .toProvider( new Provider<Mobsim>() { @Override public Mobsim get() { return new FakeMobsim(); } }); } }); controler.setDumpDataAtEnd(false); controler.run(); assertTrue( "Custom ScoringFunctionFactory was not set.", controler.getScoringFunctionFactory() instanceof DummyScoringFunctionFactory); }