@Override public Collection<? extends Object> getPlanningValues() { if (planningValues == null) { final ImmutableSet.Builder<Visit> valuesBuilder = ImmutableSet.builder(); for (final Changeset c : changesets) { valuesBuilder.addAll(isUndo ? c.getOriginalValues() : c.getTargetValues()); } planningValues = valuesBuilder.build(); } return planningValues; }
@Override protected void doMoveOnGenuineVariables(ScoreDirector scoreDirector) { if (isUndo) { for (final Changeset cs : changesets) { cs.undo(scoreDirector); } } else { for (final Changeset cs : changesets) { cs.execute(scoreDirector); } } }
public void addChangesetToTask(String taskId, Changeset changeset) { List<String> changes = mappings.remove(taskId); changes.add(changeset.getRevision()); addTaskMapping(taskId, changes); addChangeset(changeset); }
static MovePair create(ParcelVisit pick, ParcelVisit delv, Visit pickToPrev, Visit delvToPrev) { final ImmutableList.Builder<Changeset> changesets = ImmutableList.builder(); if (delv.equals(pick.getNextVisit()) || pick.equals(delv.getNextVisit())) { // pickup and delivery are neighbors in originating vehicle if (pick.isBefore(delv)) { changesets.add( Changeset.create( nonNulls(pick.getPreviousVisit(), pick, delv, delv.getNextVisit()), nonNulls(pick.getPreviousVisit(), delv.getNextVisit()))); } else { changesets.add( Changeset.create( nonNulls(delv.getPreviousVisit(), delv, pick, pick.getNextVisit()), nonNulls(delv.getPreviousVisit(), pick.getNextVisit()))); } } else { // not neighbors in originating vehicle changesets.add( Changeset.create( nonNulls(pick.getPreviousVisit(), pick, pick.getNextVisit()), nonNulls(pick.getPreviousVisit(), pick.getNextVisit()))); changesets.add( Changeset.create( nonNulls(delv.getPreviousVisit(), delv, delv.getNextVisit()), nonNulls(delv.getPreviousVisit(), delv.getNextVisit()))); } if (pickToPrev.equals(delvToPrev) || delvToPrev.equals(pick)) { // targets are the same, meaning that they are neighbors changesets.add( Changeset.create( nonNulls(pickToPrev, pickToPrev.getNextVisit()), nonNulls(pickToPrev, pick, delv, pickToPrev.getNextVisit()))); } else { changesets.add( Changeset.create( nonNulls(pickToPrev, pickToPrev.getNextVisit()), nonNulls(pickToPrev, pick, pickToPrev.getNextVisit()))); changesets.add( Changeset.create( nonNulls(delvToPrev, delvToPrev.getNextVisit()), nonNulls(delvToPrev, delv, delvToPrev.getNextVisit()))); } return new MovePair(changesets.build(), false); }
public void addChangeset(Changeset changeset) { changesets.put(changeset.getRevision(), changeset); }