Skip to content

Commit

Permalink
Merge pull request #257 from msmobility/cllorca_branch
Browse files Browse the repository at this point in the history
Cllorca branch
  • Loading branch information
mergify[bot] authored Oct 25, 2019
2 parents 01afd69 + 5689d93 commit f77ca2c
Show file tree
Hide file tree
Showing 16 changed files with 528 additions and 26 deletions.
15 changes: 11 additions & 4 deletions siloCore/src/main/java/de/tum/bgu/msm/SiloModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,26 @@ public final class SiloModel {

private Simulator simulator;
private final TimeTracker timeTracker = new TimeTracker();
private ResultsMonitor resultsMonitor;
private Set<ResultsMonitor> resultsMonitors = new HashSet<>();

/**
* @param properties
* @param dataContainer
* @param modelContainer
*/
public SiloModel(Properties properties,
DataContainer dataContainer, ModelContainer modelContainer, ResultsMonitor resultsMonitor) {
DataContainer dataContainer, ModelContainer modelContainer) {
this.modelContainer = modelContainer;
this.dataContainer = dataContainer;
this.properties = properties;
this.resultsMonitor = resultsMonitor;

SiloUtil.modelStopper("initialize");
}

public void addResultMonitor(ResultsMonitor resultsMonitor){
resultsMonitors.add(resultsMonitor);
}

public void runModel() {
logger.info("Scenario: " + properties.main.scenarioName + ", Simulation start year: " + properties.main.startYear);
long startTime = System.currentTimeMillis();
Expand Down Expand Up @@ -97,7 +101,10 @@ private void setupModel() {
}
}

simulator.registerResultsMonitor(resultsMonitor);
for (ResultsMonitor resultsMonitor : resultsMonitors){
simulator.registerResultsMonitor(resultsMonitor);

}

setupScalingYears();

Expand Down
33 changes: 33 additions & 0 deletions siloCore/src/main/java/de/tum/bgu/msm/data/SummarizeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class SummarizeData {


private static PrintWriter spatialResultWriter;
private static PrintWriter spatialResultWriter_2;

private static TableDataSet scalingControlTotals;
private static final String RESULT_FILE_SPATIAL = "resultFileSpatial";
Expand Down Expand Up @@ -65,6 +66,23 @@ public static void resultFileSpatial(String action) {
}
}

public static void resultFileSpatial_2(String action) {
// handle summary file
switch (action) {
case "open":
String directory = Properties.get().main.baseDirectory + "scenOutput/" + Properties.get().main.scenarioName;
spatialResultWriter_2 = SiloUtil.openFileForSequentialWriting(directory + "/" + RESULT_FILE_SPATIAL +
"_2.csv", Properties.get().main.startYear != Properties.get().main.baseYear);
break;
case "close":
spatialResultWriter_2.close();
break;
default:
spatialResultWriter_2.println(action);
break;
}
}

public static void summarizeSpatially(int year, DataContainer dataContainer) {
// write out results by zone

Expand All @@ -77,6 +95,19 @@ public static void summarizeSpatially(int year, DataContainer dataContainer) {
hd = hd.concat(",dd_" + dwellingType.toString());
}

if(year == Properties.get().main.baseYear) {
String hd_2 = "year,zone,autoAccessibility,transitAccessibility,population,households,hhInc_<" + Properties.get().main.incomeBrackets[0];
for (int inc = 0; inc < Properties.get().main.incomeBrackets.length; inc++) {
hd_2 = hd_2.concat(",hhInc_>" + Properties.get().main.incomeBrackets[inc]);
}
for (DwellingType dwellingType : dwellingTypes) {
hd_2 = hd_2.concat(",dd_" + dwellingType.toString());
}
hd_2 = hd_2.concat(",availLand,avePrice,jobs,shWhite,shBlack,shHispanic,shOther");
resultFileSpatial_2(hd_2);
}


hd = hd.concat(",availLand,avePrice,jobs,shWhite,shBlack,shHispanic,shOther");
resultFileSpatial(hd);

Expand Down Expand Up @@ -132,7 +163,9 @@ public static void summarizeSpatially(int year, DataContainer dataContainer) {
// modelContainer.getMove().getZonalRacialShare(taz, Race.hispanic) + "," +
// modelContainer.getMove().getZonalRacialShare(taz, Race.other));
// String txt = f.toString();
String txt_2 = String.valueOf(year).concat(",").concat(txt);
resultFileSpatial(txt);
resultFileSpatial_2(txt_2);
}
}

Expand Down
Loading

0 comments on commit f77ca2c

Please sign in to comment.