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

Merge branch 'master' of https://github.com/msmobility/mito into mode… #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions src/main/java/de/tum/bgu/msm/data/MitoZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MitoZone implements Id{
private AreaTypeForModeChoice areaTypeHBWModeChoice;
private AreaTypeForModeChoice areaTypeNHBOmodeChoice;

private float distanceToNearestRailStop;
private float distanceToNearestTransitStop;

public MitoZone(int id, float size, AreaType areaType) {
this.zoneId = id;
Expand All @@ -41,13 +41,13 @@ public MitoZone(int id, float size, AreaType areaType) {

public void setAreaTypeNHBOModeChoice(AreaTypeForModeChoice areaTypeNHBOModeChoice){this.areaTypeNHBOmodeChoice = areaTypeNHBOModeChoice;}

public float getDistanceToNearestRailStop() {return distanceToNearestRailStop;}
public float getDistanceToNearestTransitStop() {return distanceToNearestTransitStop;}

/**
* Sets distance to nearest rail stop
* @param distanceToNearestRailStop distance in km
* Sets distance to nearest transit stop
* @param distanceToNearestTransitStop distance in km
*/
public void setDistanceToNearestRailStop(float distanceToNearestRailStop) {this.distanceToNearestRailStop = distanceToNearestRailStop;}
public void setDistanceToNearestTransitStop(float distanceToNearestTransitStop) {this.distanceToNearestTransitStop = distanceToNearestTransitStop;}

@Override
public int getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class ModeChoiceInputReader extends CSVReader {

private int railDistIndex;
private int transitDistIndex;
private int zoneIndex;
private int areaTypeHBWIndex;
private int areaTypeNHBOIndex;
Expand All @@ -22,25 +22,25 @@ public ModeChoiceInputReader(DataSet dataSet) {
@Override
protected void processHeader(String[] header) {
zoneIndex = MitoUtil.findPositionInArray("zoneID", header);
railDistIndex = MitoUtil.findPositionInArray("distToRailStop", header);
transitDistIndex = MitoUtil.findPositionInArray("distToTransit", header);
areaTypeHBWIndex = MitoUtil.findPositionInArray("areaTypeHBW", header);
areaTypeNHBOIndex = MitoUtil.findPositionInArray("areaTypeNHBO", header);
}

@Override
protected void processRecord(String[] record) {
int zoneID = Integer.parseInt(record[zoneIndex]);
float distToRailStop = Float.parseFloat(record[railDistIndex]);
float distToTransit = Float.parseFloat(record[transitDistIndex]);
AreaTypeForModeChoice areaTypeHBW = AreaTypeForModeChoice.valueOf(Integer.parseInt(record[areaTypeHBWIndex]));
AreaTypeForModeChoice areaTypeNHBO = AreaTypeForModeChoice.valueOf(Integer.parseInt(record[areaTypeNHBOIndex]));
MitoZone zone = dataSet.getZones().get(zoneID);
zone.setDistanceToNearestRailStop(distToRailStop);
zone.setDistanceToNearestTransitStop(distToTransit);
zone.setAreaTypeHBWModeChoice(areaTypeHBW);
zone.setAreaTypeNHBOModeChoice(areaTypeNHBO);
}

@Override
public void read() {
super.read(Resources.INSTANCE.getString(Properties.AREA_TYPES_AND_RAIL_DISTANCE),",");
super.read(Resources.INSTANCE.getString(Properties.AREA_TYPES_AND_TRANSIT_DISTANCE),",");
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/tum/bgu/msm/resources/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Properties {
public static final String TRAIN_TRAVEL_TIME_SKIM = "train.travelTime";
public static final String AUTO_TRAVEL_DISTANCE_SKIM = "auto.travelDistance";
public static final String NMT_TRAVEL_DISTANCE_SKIM = "nmt.travelDistance";
public static final String AREA_TYPES_AND_RAIL_DISTANCE = "areaTypes.distToRailStop";
public static final String AREA_TYPES_AND_TRANSIT_DISTANCE = "areaTypes.distToTransit";

public static final String AUTONOMOUS_VEHICLE_CHOICE = "include.AVchoice";

Expand Down
108 changes: 54 additions & 54 deletions src/main/resources/de/tum/bgu/msm/modules/modeChoice/ModeChoice

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ public class ModeChoiceCalculatorTest {

private ModeChoiceJSCalculator calculator;

private final double[] reference = new double[]{0.35258741,0.21025060,0.07781168,0.01532404,0.00755559,0.01247863,0.00364841,0.35258208,0.01560092};
private final double[] reference = new double[]{0.585260323,0.273709615,0.08747526,0.023052124,0.009195227,0.017205939,0.00410151};

@Before
public void setup() {

Resources.initializeResources("./testInput/test.properties", Implementation.MUNICH);

Reader reader = new InputStreamReader(this.getClass().getResourceAsStream("ModeChoiceAV"));
Reader reader = new InputStreamReader(this.getClass().getResourceAsStream("ModeChoice"));
calculator = new ModeChoiceJSCalculator(reader);
}

@Test
public void test() {
MitoZone origin = new MitoZone(1, 100, null);
origin.setDistanceToNearestRailStop(0.5f);
origin.setDistanceToNearestTransitStop(0.5f);
//origin.setAreaTypeHBWModeChoice(AreaTypeForModeChoice.HBW_mediumSizedCity);
MitoHousehold hh = new MitoHousehold(1, 20000, 1, null);
MitoPerson pp = new MitoPerson(1, Occupation.STUDENT, 1, 20, Gender.FEMALE, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package de.tum.bgu.msm.modules.modeChoice;

import cern.colt.matrix.tdouble.DoubleMatrix2D;
import de.tum.bgu.msm.data.*;
import de.tum.bgu.msm.data.travelTimes.TravelTimes;
import de.tum.bgu.msm.util.MitoUtil;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -47,7 +44,7 @@ private void fillDataSet() {
MitoPerson person1 = new MitoPerson(1, Occupation.WORKER, -1, 30, Gender.MALE, true);
trip1.setPerson(person1);
MitoZone zone1 = new MitoZone(1, 100, AreaType.URBAN);
zone1.setDistanceToNearestRailStop(0.5f);
zone1.setDistanceToNearestTransitStop(0.5f);
zone1.setAreaTypeHBWModeChoice(AreaTypeForModeChoice.HBW_coreCity);
trip1.setTripOrigin(zone1);
MitoZone zone2 = new MitoZone(2, 100, AreaType.URBAN);
Expand All @@ -67,7 +64,7 @@ private void fillDataSet() {
MitoPerson person2 = new MitoPerson(2, Occupation.WORKER, -1, 30, Gender.MALE, true);
trip2.setPerson(person2);
MitoZone zone3 = new MitoZone(3, 100, AreaType.URBAN);
zone3.setDistanceToNearestRailStop(0.5f);
zone3.setDistanceToNearestTransitStop(0.5f);
zone3.setAreaTypeHBWModeChoice(AreaTypeForModeChoice.HBW_coreCity);
trip2.setTripOrigin(zone3);
MitoZone zone4 = new MitoZone(4, 100, AreaType.URBAN);
Expand Down
2 changes: 1 addition & 1 deletion testInput/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bus.travelTime = ./testInput/CheapJrnyTime.omx
tramMetro.travelTime = ./testInput/CheapJrnyTime.omx
train.travelTime = ./testInput/CheapJrnyTime.omx
auto.travelDistance = ./testInput/CheapJrnyTime.omx
areaTypes.distToRailStop = ./testInput/zones_areaType_distToRailStop.csv
areaTypes.distToTransit = ./testInput/zones_areaType_distToTransit.csv

# Output files
non.motorized.trips = output/nonMotorizedTrips.csv
Expand Down
2 changes: 0 additions & 2 deletions testInput/zones_areaType_distToRailStop.csv

This file was deleted.