Skip to content

Commit 812e1a2

Browse files
authored
minor refactoring (#76)
1 parent 70d89ec commit 812e1a2

3 files changed

+15
-5
lines changed

src/main/java/org/matsim/rebalancing/WaitingPointBasedRebalancingStrategyParams.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import org.matsim.core.config.ReflectiveConfigGroup;
2424

2525
/**
26+
* The placeholder, which will be moved to the matsim-lib later.
2627
* @author Chengqi Lu
27-
* // TODO this is not needed for Kelheim scenario. I will move it to the matsim-lib after eeverything works well here.
2828
*/
2929
public final class WaitingPointBasedRebalancingStrategyParams extends ReflectiveConfigGroup
3030
implements RebalancingParams.RebalancingStrategyParams {
@@ -34,9 +34,17 @@ public final class WaitingPointBasedRebalancingStrategyParams extends Reflective
3434
@Comment("The path to the waiting point file (csv/tsv) can be specified here. title row of the file: link_id capacity" +
3535
"If unspecified (i.e., empty string by default), starting points of the fleet will be used as the waiting points")
3636
@NotNull
37-
public String waitingPointPath = "";
37+
private String waitingPointPath = "";
3838

3939
public WaitingPointBasedRebalancingStrategyParams() {
4040
super(SET_NAME);
4141
}
42+
43+
public String getWaitingPointPath() {
44+
return waitingPointPath;
45+
}
46+
47+
public void setWaitingPointPath(String waitingPointPath) {
48+
this.waitingPointPath = waitingPointPath;
49+
}
4250
}

src/main/java/org/matsim/rebalancing/WaitingPointsBasedRebalancingModule.java

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.IOException;
3434

3535
/**
36+
* Temporary installation module for the waiting point based rebalancing strategy.
3637
* @author Chengqi Lu
3738
*/
3839
public class WaitingPointsBasedRebalancingModule extends AbstractDvrpModeModule {

src/main/java/org/matsim/rebalancing/WaitingPointsBasedRebalancingStrategy.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.stream.Stream;
2828

2929
/**
30+
* The waiting point based rebalancing strategy will relocate vehicles to nearest waiting point that still has capacity when it becomes idle.
3031
* @author Chengqi Lu
3132
*/
3233
class WaitingPointsBasedRebalancingStrategy implements RebalancingStrategy {
@@ -50,9 +51,9 @@ private void initialize(String waitingPointsPath) throws IOException {
5051
log.info("Reading waiting points from the file...");
5152
try (CSVParser parser = new CSVParser(Files.newBufferedReader(Path.of(waitingPointsPath), StandardCharsets.UTF_8),
5253
CSVFormat.TDF.builder().setHeader().setSkipHeaderRecord(true).build())) {
53-
for (CSVRecord record : parser) {
54-
Link waitingPointLink = network.getLinks().get(Id.createLinkId(record.get("link_id")));
55-
Integer capacity = Integer.parseInt(record.get("capacity"));
54+
for (CSVRecord csvRecord : parser) {
55+
Link waitingPointLink = network.getLinks().get(Id.createLinkId(csvRecord.get("link_id")));
56+
Integer capacity = Integer.parseInt(csvRecord.get("capacity"));
5657
waitingPointsCapcityMap.put(waitingPointLink.getId(), capacity);
5758
}
5859
}

0 commit comments

Comments
 (0)