Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor refactoring #76

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading