Skip to content

Commit

Permalink
adapt to changes in matsim-libs: i) controler is now spelled with ll.…
Browse files Browse the repository at this point in the history
… ii) some cleanup
  • Loading branch information
kt86 committed Dec 9, 2024
1 parent 54f948c commit 49469d0
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
import com.graphhopper.jsprit.core.util.VehicleRoutingTransportCostsMatrix;

import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controller.CarrierControllerUtils;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierStrategyManager;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts.Builder;
Expand Down Expand Up @@ -405,7 +405,7 @@ public ScoringFunction createScoringFunction(Carrier carrier) {
* @return
*/
private static CarrierStrategyManager createMyStrategyManager() {
return CarrierControlerUtils.createDefaultCarrierStrategyManager();
return CarrierControllerUtils.createDefaultCarrierStrategyManager();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.Tour.ServiceActivity;
import org.matsim.freight.carriers.Tour.TourElement;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.FreightActivity;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.FreightActivity;
import org.matsim.freight.carriers.jsprit.VehicleTypeDependentRoadPricingCalculator;
import org.matsim.vehicles.Vehicle;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/matsim/vsp/freight/RunFreight.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
import org.matsim.freight.carriers.ScheduledTour;
import org.matsim.freight.carriers.Tour.ServiceActivity;
import org.matsim.freight.carriers.Tour.TourElement;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controller.CarrierControllerUtils;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierStrategyManager;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
Expand Down Expand Up @@ -416,7 +416,7 @@ public void install(){
//Benötigt, da listener kein "Null" als StrategyFactory mehr erlaubt, KT 17.04.2015
//Da keine Strategy notwendig, hier zunächst eine "leere" Factory
private static CarrierStrategyManager createMyStrategymanager() {
return CarrierControlerUtils.createDefaultCarrierStrategyManager();
return CarrierControllerUtils.createDefaultCarrierStrategyManager();
}


Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/matsim/vsp/freight/RunFreightOnlyMatsim.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import org.matsim.api.core.v01.Scenario;
import org.matsim.freight.carriers.FreightCarriersConfigGroup;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controller.CarrierControllerUtils;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierStrategyManager;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
Expand Down Expand Up @@ -249,7 +249,7 @@ public void install(){
//Benötigt, da listener kein "Null" als StrategyFactory mehr erlaubt, KT 17.04.2015
//Da keine Strategy notwendig, hier zunächst eine "leere" Factory
private static CarrierStrategyManager createMyStrategymanager() {
return CarrierControlerUtils.createDefaultCarrierStrategyManager();
return CarrierControllerUtils.createDefaultCarrierStrategyManager();
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/matsim/vsp/freight/food/RunFood.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import org.matsim.freight.carriers.CarrierPlan;
import org.matsim.freight.carriers.CarriersUtils;
import org.matsim.freight.carriers.Carriers;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkRouter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.matsim.freight.carriers.ScheduledTour;
import org.matsim.freight.carriers.Tour;
import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierModule;

/**
* Diese Klasse soll den Output von "alten" runs derart updaten,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static void main(String[] args) {
VehicleUtils.copyFromTo(vehicleType_new, vehicleType);

CarrierVehicle additionalCarrierVehicle =
CarrierVehicle.Builder.newInstance(vehicleId2, carrierVehicle.getLocation(), vehicleType_new)
CarrierVehicle.Builder.newInstance(vehicleId2, carrierVehicle.getLinkId(), vehicleType_new)
.setEarliestStart(carrierVehicle.getEarliestStartTime())
.setLatestEnd(carrierVehicle.getLatestEndTime())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void run(){

someChecks(oldCarriers, newCarriers);

new CarrierPlanXmlWriterV2(newCarriers).write(outputNewCarriers);
new CarrierPlanWriter(newCarriers).write(outputNewCarriers);

log.info("#### Done ####");
}
Expand All @@ -81,7 +81,7 @@ private void convertCarrierCapabilities(Network oldNetwork, Network newNetworkFi
newCarrier.getCarrierCapabilities().setFleetSize(cc.getFleetSize());
for (CarrierVehicle carrierVehicle: cc.getCarrierVehicles().values()) {
Id<Link> newLinkId;
newLinkId = getNewLinkId(oldNetwork, newNetworkFiltered, carrierVehicle.getLocation());
newLinkId = getNewLinkId(oldNetwork, newNetworkFiltered, carrierVehicle.getLinkId());
//Adapt VehicleId to new Location
String oldVehicleString = carrierVehicle.getId().toString();
Id<Vehicle> newVehicleId = Id.createVehicleId(oldVehicleString.substring(0,oldVehicleString.lastIndexOf("_")+1)+newLinkId.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.network.Link;
import org.matsim.freight.carriers.Carrier;
import org.matsim.freight.carriers.CarrierCapabilities;
import org.matsim.freight.carriers.CarrierVehicle;
import org.matsim.freight.carriers.CarrierVehicleTypeLoader;
import org.matsim.freight.carriers.CarrierVehicleTypes;
import org.matsim.freight.carriers.Carriers;
import org.matsim.freight.carriers.*;
import org.matsim.vehicles.Vehicle;
import org.matsim.vehicles.VehicleType;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.CarrierImpl;

public class AbfallChessboardUtils {

Expand Down Expand Up @@ -84,7 +78,7 @@ static void createShipmentsForChessboardII(HashMap<String, Carrier> carrierMap,
*
* @param
*/
static void createCarriersForChessboard(Carriers carriers, FleetSize fleetSize, CarrierVehicleTypes carrierVehicleTypes) {
static void createCarriersForChessboard(FleetSize fleetSize, CarrierVehicleTypes carrierVehicleTypes) {
String vehicleName = "TruckChessboard";
double earliestStartingTime = 6 * 3600;
double latestFinishingTime = 14 * 3600;
Expand All @@ -94,27 +88,10 @@ static void createCarriersForChessboard(Carriers carriers, FleetSize fleetSize,
.newInstance(Id.create(vehicleName, Vehicle.class), Id.createLinkId(linkChessboardDepot), vehicleType)
.setEarliestStart(earliestStartingTime).setLatestEnd(latestFinishingTime).build();

// AbfallUtils.createGarbageTruck(vehicleName, linkChessboardDepot, earliestStartingTime, latestFinishingTime);

// define Carriers
carrierChessboard.setCarrierCapabilities(CarrierCapabilities.Builder.newInstance().
addVehicle(newCarrierVehicle).setFleetSize(fleetSize).build());

defineCarriersChessboard(carriers, newCarrierVehicle, fleetSize, carrierVehicleTypes);
}

/**
* Defines and sets the Capabilities of the Carrier, including the vehicleTypes
* for the carriers for the Chessboard network
*
* @param
*
*/
private static void defineCarriersChessboard(Carriers carriers, CarrierVehicle vehicleDepot, FleetSize fleetSize, CarrierVehicleTypes carrierVehicleTypes) {
CarrierCapabilities carrierCapabilities = CarrierCapabilities.Builder.newInstance()
.addType(carrierVehicleTypes.getVehicleTypes().values().iterator().next()).addVehicle(vehicleDepot).setFleetSize(fleetSize).build();

carrierChessboard.setCarrierCapabilities(carrierCapabilities);

// Fahrzeugtypen den Anbietern zuordenen
new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(carrierVehicleTypes);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/matsim/vsp/wasteCollection/AbfallUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.matsim.freight.carriers.Tour.Leg;
import org.matsim.freight.carriers.Tour.Pickup;
import org.matsim.freight.carriers.Tour.TourElement;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts.Builder;
Expand Down Expand Up @@ -611,7 +611,7 @@ static void solveWithJsprit(Scenario scenario, Carriers carriers, HashMap<String
scenario.getConfig().controller().getOutputDirectory() + "/jsprit_CarrierPlans_Test01.png",
"bestSolution");
}
new CarrierPlanXmlWriterV2(carriers)
new CarrierPlanWriter(carriers)
.write(scenario.getConfig().controller().getOutputDirectory() + "/jsprit_CarrierPlans.xml");

}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/matsim/vsp/wasteCollection/Run_Abfall.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ public static void main(String[] args) throws Exception {
AbfallChessboardUtils.createShipmentsForChessboardI(carrierMap, kgGarbageToCollect, allLinks,
volumeDustbinInLiters, secondsServiceTimePerDustbin, scenario, carriers);
FleetSize fleetSize = FleetSize.INFINITE;
AbfallChessboardUtils.createCarriersForChessboard(carriers, fleetSize, carrierVehicleTypes);
AbfallChessboardUtils.createCarriersForChessboard(fleetSize, carrierVehicleTypes);
}
case chessboardGarbagePerMeterToCollect -> {
double kgGarbagePerMeterToCollect = 0.2;
CarrierVehicleTypes carrierVehicleTypes2 = CarriersUtils.getCarrierVehicleTypes(scenario);
AbfallChessboardUtils.createShipmentsForChessboardII(carrierMap, kgGarbagePerMeterToCollect, allLinks,
volumeDustbinInLiters, secondsServiceTimePerDustbin, scenario, carriers);
FleetSize fleetSize2 = FleetSize.INFINITE;
AbfallChessboardUtils.createCarriersForChessboard(carriers, fleetSize2, carrierVehicleTypes2);
AbfallChessboardUtils.createCarriersForChessboard(fleetSize2, carrierVehicleTypes2);
}
case berlinSelectedDistricts -> {
// day input: MO or DI or MI or DO or FR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.freight.carriers.*;
import org.matsim.freight.carriers.CarrierCapabilities.FleetSize;
import org.matsim.freight.carriers.controler.CarrierModule;
import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controler.CarrierStrategyManager;
import org.matsim.freight.carriers.controler.CarrierControlerUtils;
import org.matsim.freight.carriers.controller.CarrierModule;
import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory;
import org.matsim.freight.carriers.controller.CarrierStrategyManager;
import org.matsim.freight.carriers.controller.CarrierControllerUtils;
import org.matsim.freight.carriers.jsprit.MatsimJspritFactory;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts;
import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts.Builder;
Expand Down Expand Up @@ -601,6 +601,6 @@ private static CarrierScoringFunctionFactory createMyScoringFunction2() {
* @return
*/
private static CarrierStrategyManager createMyStrategyManager() {
return CarrierControlerUtils.createDefaultCarrierStrategyManager();
return CarrierControllerUtils.createDefaultCarrierStrategyManager();
}
}

0 comments on commit 49469d0

Please sign in to comment.