Skip to content

Commit

Permalink
minor refactoring (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
luchengqi7 authored May 21, 2024
1 parent 70d89ec commit 812e1a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.matsim.core.config.ReflectiveConfigGroup;

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

public WaitingPointBasedRebalancingStrategyParams() {
super(SET_NAME);
}

public String getWaitingPointPath() {
return waitingPointPath;
}

public void setWaitingPointPath(String waitingPointPath) {
this.waitingPointPath = waitingPointPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.IOException;

/**
* Temporary installation module for the waiting point based rebalancing strategy.
* @author Chengqi Lu
*/
public class WaitingPointsBasedRebalancingModule extends AbstractDvrpModeModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.stream.Stream;

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

0 comments on commit 812e1a2

Please sign in to comment.