コード例 #1
0
  @Override
  public GroupPlanStrategy get() {
    final GroupPlanStrategy strategy = instantiateStrategy(sc.getConfig());

    final GroupReplanningConfigGroup configGroup =
        (GroupReplanningConfigGroup)
            sc.getConfig().getModule(GroupReplanningConfigGroup.GROUP_NAME);
    strategy.addStrategyModule(
        new MutateActivityLocationsToLocationsOfOthersModule(
            sc.getConfig().global().getNumberOfThreads(),
            sc.getPopulation(),
            configGroup.getLocationChoiceActivityType()));

    strategy.addStrategyModule(
        GroupPlanStrategyFactoryUtils.createJointTripAwareTourModeUnifierModule(
            sc.getConfig(), tripRouterFactory));

    strategy.addStrategyModule(
        GroupPlanStrategyFactoryUtils.createReRouteModule(
            sc.getConfig(), planRoutingAlgorithmFactory, tripRouterFactory));

    strategy.addStrategyModule(
        GroupPlanStrategyFactoryUtils.createRecomposeJointPlansModule(
            sc.getConfig(),
            ((JointPlans) sc.getScenarioElement(JointPlans.ELEMENT_NAME)).getFactory(),
            planLinkIdentifier));

    return strategy;
  }
コード例 #2
0
  @Test
  public void testNumberOfSelectedJointPlans() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final ReplanningGroup group = createTestGroup(jointPlans);
    strategy.run(createContext(), jointPlans, Arrays.asList(group));

    int countSelectedJoint = 0;
    int countSelectedIndiv = 0;
    for (Person person : group.getPersons()) {
      for (Plan plan : person.getPlans()) {
        if (plan.isSelected() && jointPlans.getJointPlan(plan) != null) {
          countSelectedJoint++;
        }
        if (plan.isSelected() && jointPlans.getJointPlan(plan) == null) {
          countSelectedIndiv++;
        }
      }
    }

    assertEquals(
        "wrong number of selected plans in joint plans",
        N_INITIALLY_INDIV_PLANS,
        countSelectedJoint);
    assertEquals(
        "wrong number of selected plans in individual plans",
        N_INITIALLY_JOINT_PLANS,
        countSelectedIndiv);
  }
コード例 #3
0
  @Test
  public void testNewPlanIsSelected() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final List<Plan> selectedPlans = new ArrayList<Plan>();
    final ReplanningGroup group = createTestGroup(jointPlans);
    for (Person p : group.getPersons()) {
      selectedPlans.add(p.getSelectedPlan());
    }

    strategy.run(createContext(), jointPlans, Arrays.asList(group));
    for (Person person : group.getPersons()) {
      for (Plan plan : person.getPlans()) {
        if (plan.isSelected()) {
          // new plan: selection status inverted
          assertFalse("old plan still selected", selectedPlans.contains(plan));
        } else {
          assertTrue("old plan still selected", selectedPlans.contains(plan));
        }
      }
    }
  }
コード例 #4
0
  @Test
  public void testNumberOfPlans() throws Exception {
    final JointPlans jointPlans = new JointPlans();
    final GroupPlanStrategy strategy =
        new GroupPlanStrategy(
            new HighestScoreSumSelector(new EmptyIncompatiblePlansIdentifierFactory()));
    strategy.addStrategyModule(new JointStructureInvertingModule(jointPlans.getFactory()));

    final ReplanningGroup group = createTestGroup(jointPlans);
    final int groupSize = group.getPersons().size();
    strategy.run(createContext(), jointPlans, Arrays.asList(group));

    assertEquals("group size changed by strategy!", groupSize, group.getPersons().size());
  }