class RemoveVehicle implements ProblemFactChange<VehicleRoutingSolution> {

    @Override
    public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) {
        VehicleRoutingSolution workingSolution = scoreDirector.getWorkingSolution();

        // Look up a working copy of the vehicle
        PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(removedVehicle);
        if (workingVehicle == null) {
            throw new IllegalStateException("Can't look up a working copy of " + removedVehicle);
        }

        // Un-initialize all visits of this vehicle
        for (PlanningVisit visit : workingVehicle.getFutureVisits()) {
            scoreDirector.beforeVariableChanged(visit, "previousStandstill");
            visit.setPreviousStandstill(null);
            scoreDirector.afterVariableChanged(visit, "previousStandstill");
        }

        // No need to clone the vehicleList because it is a planning entity collection, so it is already
        // planning-cloned.
        // To learn more about problem fact changes, see:
        // https://docs.jboss.org/optaplanner/release/latest/optaplanner-docs/html_single/#problemFactChangeExample

        // Remove the vehicle
        scoreDirector.beforeProblemFactRemoved(workingVehicle);
        if (!workingSolution.getVehicleList().remove(workingVehicle)) {
            throw new IllegalStateException(
                    "Working solution's vehicleList "
                            + workingSolution.getVehicleList()
                            + " doesn't contain the workingVehicle ("
                            + workingVehicle
                            + "). This is a bug!");
        }
        scoreDirector.afterProblemFactRemoved(workingVehicle);

        scoreDirector.triggerVariableListeners();
    }

    public  RemoveVehicle(PlanningVehicle removedVehicle);

}