In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit 285a9beb authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

Merge branch 'master' into add_artery_support

parents 3db7cafb 53e0e85d
Pipeline #309823 passed with stages
in 127 minutes and 30 seconds
{
"name" : "s2ucre_static_simple",
"description" : "",
"release" : "1.14",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.EventtimePedestrianIdOutputFile",
"filename" : "postvis.traj",
"processors" : [ 1, 2 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepProcessor",
"id" : 1
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.FootStepTargetIDProcessor",
"id" : 2
} ],
"isTimestamped" : true,
"isWriteMetaData" : false
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 4,
"numberOfCircles" : 1,
"optimizationType" : "NELDER_MEAD",
"varyStepDirection" : true,
"movementType" : "ARBITRARY",
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"minStepLength" : 0.0,
"minimumStepLength" : false,
"maxStepDuration" : 1.7976931348623157E308,
"dynamicStepLength" : true,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"targetPotentialModel" : "org.vadere.simulator.models.potential.fields.PotentialFieldTargetGrid",
"pedestrianPotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldPedestrianCompactSoftshell",
"obstaclePotentialModel" : "org.vadere.simulator.models.potential.PotentialFieldObstacleCompactSoftshell",
"submodels" : [ "org.vadere.simulator.models.groups.cgm.CentroidGroupModel" ]
},
"org.vadere.state.attributes.models.AttributesPotentialCompactSoftshell" : {
"pedPotentialIntimateSpaceWidth" : 0.45,
"pedPotentialPersonalSpaceWidth" : 1.2,
"pedPotentialHeight" : 50.0,
"obstPotentialWidth" : 0.8,
"obstPotentialHeight" : 6.0,
"intimateSpaceFactor" : 1.2,
"personalSpacePower" : 1,
"intimateSpacePower" : 1
},
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"cacheType" : "NO_CACHE",
"cacheDir" : "",
"timeCostAttributes" : {
"standardDeviation" : 0.7,
"type" : "UNIT",
"obstacleDensityWeight" : 3.5,
"pedestrianSameTargetDensityWeight" : 3.5,
"pedestrianOtherTargetDensityWeight" : 3.5,
"pedestrianWeight" : 3.5,
"queueWidthLoading" : 1.0,
"pedestrianDynamicWeight" : 6.0,
"loadingType" : "CONSTANT",
"width" : 0.2,
"height" : 1.0
}
},
"org.vadere.state.attributes.models.AttributesCGM" : {
"groupMemberRepulsionFactor" : 0.01,
"leaderAttractionFactor" : 0.003
}
},
"attributesSimulation" : {
"finishTime" : 500.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : -3213925745664992646,
"simulationSeed" : 0
},
"attributesPsychology" : {
"usePsychologyLayer" : false,
"psychologyLayer" : {
"perception" : "SimplePerceptionModel",
"cognition" : "SimpleCognitionModel"
}
},
"attributesStrategy" : {
"useStrategyModel" : false,
"strategyModel" : null
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 40.0,
"height" : 50.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true,
"referenceCoordinateSystem" : null
},
"obstacles" : [ {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 29.8,
"y" : 0.5
}, {
"x" : 7.711477719247341,
"y" : 10.030658625997603
}, {
"x" : 0.5,
"y" : 11.349890053272247
}, {
"x" : 0.5,
"y" : 0.5
} ]
},
"id" : 2
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 0.5,
"y" : 23.3
}, {
"x" : 3.9,
"y" : 20.3
}, {
"x" : 10.068316678749397,
"y" : 15.240937641821802
}, {
"x" : 15.45937814656645,
"y" : 12.808810473419726
}, {
"x" : 23.463889407925308,
"y" : 45.90773453190923
}, {
"x" : 23.463889407925308,
"y" : 49.5
}, {
"x" : 0.5,
"y" : 49.5
}, {
"x" : 0.46388940792530775,
"y" : 45.90773453190923
} ]
},
"id" : 3
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 39.5,
"y" : 49.5
}, {
"x" : 35.0,
"y" : 49.5
}, {
"x" : 31.295924079138786,
"y" : 42.50668004900217
}, {
"x" : 20.931872089859098,
"y" : 10.544835465960205
}, {
"x" : 32.12912071251776,
"y" : 5.936819093301892
}, {
"x" : 36.5,
"y" : 5.936819093301892
}, {
"x" : 34.0,
"y" : 0.5
}, {
"x" : 39.5,
"y" : 0.5
} ]
},
"id" : 1
} ],
"measurementAreas" : [ ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 0.5,
"y" : 11.5
}, {
"x" : 0.5,
"y" : 12.700000000186265
}, {
"x" : 0.5,
"y" : 23.200000000186265
}, {
"x" : 4.0,
"y" : 20.1
} ]
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
}, {
"id" : 1,
"absorbing" : true,
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 33.90000000002328,
"y" : 0.5
}, {
"x" : 29.900000000023283,
"y" : 0.5
}, {
"x" : 32.300000000046566,
"y" : 5.9
}, {
"x" : 36.40000000002328,
"y" : 5.900000000372529
} ]
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"targetChangers" : [ ],
"absorbingAreas" : [ ],
"sources" : [ {
"id" : 5,
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 23.5,
"y" : 49.5
}, {
"x" : 23.5,
"y" : 46.0
}, {
"x" : 33.1,
"y" : 46.0
}, {
"x" : 34.96,
"y" : 49.5
} ]
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 4,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 500.0,
"spawnAtRandomPositions" : true,
"spawnAtGridPositionsCA" : false,
"useFreeSpaceOnly" : true,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN",
"attributesPedestrian" : null
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0,
"footstepHistorySize" : 4,
"searchRadius" : 1.0,
"walkingDirectionCalculation" : "BY_TARGET_CENTER",
"walkingDirectionSameIfAngleLessOrEqual" : 45.0
},
"teleporter" : null,
"attributesCar" : null
},
"stimulusInfos" : [ ]
}
}
\ No newline at end of file
......@@ -148,7 +148,14 @@
<artifactId>TableLayout</artifactId>
<version>20050920</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jfree/jfreechart -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.5.0</version>
</dependency>
<!-- movie & screenshot -->
<dependency>
<groupId>org.jcodec</groupId>
......
......@@ -79,12 +79,14 @@ ProjectView.startDialog.button2=Create Project
ProjectView.btnNewButton.text=New button
ProjectView.btnRunAllTests.text=Run all scenarios
ProjectView.mntmRunSelectetTests.text=Run selected scenario
ProjectView.mntmRunRepeatedlyTests.text=Run scenario 10x
ProjectView.mntmRunSelectedTests.text=Run selected scenarios
ProjectView.mntmSimulationResult.text=Show summary after simulation
ProjectView.btnToggleScenarioChecker.text=Activate ScenarioChecker
ProjectView.btnPauseRunningTests.text=Pause
ProjectView.btnRunSelectedTest.text=Run selected scenario
ProjectView.btnRunSelectedTest.toolTipText=Run selected scenario
ProjectView.btnRunRepeatedlyTest.toolTipText=Run scenario 10x
ProjectView.btnPauseRunningTests.toolTipText=Pause the scenario run
ProjectView.btnStopRunningTests.text=Stop running scenarios
ProjectView.btnResumeNormalSpeed.text=Resume
......
package org.vadere.gui.projectview.control;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.gui.projectview.view.VTable;
import org.vadere.simulator.projects.Scenario;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Collection;
public class ActionRunRepeatedlyScenarios extends AbstractAction {
private final ProjectViewModel model;
private final VTable scenarioTable;
private final int repetitions;
public ActionRunRepeatedlyScenarios(final String name, final ProjectViewModel model, final VTable scenarioTable, final int repetitions) {
super(name);
this.model = model;
this.repetitions = repetitions;
this.scenarioTable = scenarioTable;
}
@Override
public void actionPerformed(final ActionEvent e) {
if (model.runScenarioIsOk()) {
Collection<Scenario> scenarios = model.getScenarios(scenarioTable.getSelectedRows());
// make sure only one scenario is chosen
if(scenarios.size()>1){
throw new IllegalArgumentException("Please select a single scenario for the stochastic evaluation");
}
Scenario singleScenario = scenarios.iterator().next();
for(int i_rep = 0; i_rep < repetitions; i_rep++)
scenarios.add(singleScenario);
model.getProject().runScenarios(scenarios);
model.getProject().getSimulationResults();
}
}
}
package org.vadere.gui.projectview.view;
import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.map.MultiValueMap;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.StandardXYBarPainter;
import org.jfree.chart.renderer.xy.XYBarRenderer;
import org.jfree.data.statistics.HistogramDataset;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.model.ProjectViewModel;
import org.vadere.simulator.projects.ProjectFinishedListener;
......@@ -16,7 +24,11 @@ import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.*;
import java.util.stream.Collectors;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.chart.ChartPanel;
import javax.swing.*;
......@@ -66,7 +78,8 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
class ResultDialog extends JDialog {
Button btnOk, btnCsv;
private JTable table;
JPanel main;
JPanel main_panel;
JPanel plots_panel;
JScrollPane scrollPane;
JPanel btnPane;
LinkedList<SimulationResult> data;
......@@ -75,14 +88,66 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
ResultDialog(ProjectView projectView, LinkedList<SimulationResult> data) {
super(projectView);
this.data = data;
main = new JPanel();
main.setLayout(new BoxLayout(main, BoxLayout.PAGE_AXIS));
main_panel = new JPanel();
main_panel.setLayout(new BoxLayout(main_panel, BoxLayout.PAGE_AXIS));
table = new JTable(getData(data), data.getFirst().getHeaders());
table.setFillsViewportHeight(true);
table.doLayout();
scrollPane = new JScrollPane(table);
main.add(scrollPane);
main_panel.add(scrollPane);
// add new panel for results plots
plots_panel = new JPanel();
FlowLayout plots = new FlowLayout(); // next to each other
plots_panel.setLayout(plots);
JScrollPane sPannel = new JScrollPane(plots_panel);
// Code histograms
// collect scenario names that are in the ProjectRunResultDialog
Set<String> scenarios = data.stream().map(SimulationResult::getScenarioName).collect(Collectors.toSet());
if( scenarios.size() == 1 && data.size() > 1) { // only one scenario was run, but multiple times
// merge results from all runs into one MultiValueMap (allows duplicate entries)
MultiMap mergedResults = new MultiValueMap();
data.forEach(d -> mergedResults.putAll(d.getData()));
Iterator iterator = mergedResults.entrySet().iterator();
// collect all results for one processor
while(iterator.hasNext()) {
Map.Entry element = (Map.Entry) iterator.next();
ArrayList<Double> values = (ArrayList) element.getValue();
double[] values_arr = values.stream().mapToDouble(Double::doubleValue).toArray();
var dataset = new HistogramDataset();
double mean = values.stream().mapToDouble(d->d).sum()/values.size();
dataset.addSeries("mean="+mean, values_arr, 10);
JFreeChart histogram = ChartFactory.createHistogram((String) element.getKey(),
"", "", dataset);
XYPlot xyplot = histogram.getXYPlot();
xyplot.setForegroundAlpha(0.7F);
xyplot.setBackgroundPaint(Color.WHITE);
xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
renderer.setShadowVisible(false);
renderer.setDrawBarOutline(true);
renderer.setBarPainter(new StandardXYBarPainter());
ChartPanel cp_hist = new ChartPanel(histogram);
cp_hist.setPreferredSize(new Dimension(500/mergedResults.size(), 500/mergedResults.size()));
plots_panel.add(cp_hist);
}
main_panel.add(sPannel);
}
btnOk = new Button(Messages.getString("SettingsDialog.btnClose.text"));
btnOk.addActionListener(this::btnOKListener);
......@@ -96,22 +161,110 @@ public class ProjectRunResultDialog implements ProjectFinishedListener {
btnPane.add(btnCsv);
Container c = getContentPane();
c.add(main, BorderLayout.CENTER);
c.add(main_panel, BorderLayout.CENTER);
c.add(btnPane, BorderLayout.PAGE_END);
setTitle(Messages.getString("ProjectView.label.simResults"));
setSize(600, 200);
setSize(600, 400);
}
Object[][] getData(LinkedList<SimulationResult> data) {
Object[][] res = new Object[data.size()][5];
int n_rows = data.size();
Set<String> scenarios = data.stream().map(SimulationResult::getScenarioName).collect(Collectors.toSet());
if( scenarios.size() == 1 && data.size() > 1) { // only one scenario was run, but multiple times
n_rows += 5; // for mean, min, max, std
}
// todo: adapt for different processors among scenarios or make sure that all scenarios have the same processors defined
Object[][] res = new Object[n_rows][5]; // todo: replace static limitation of 5 (processors?)
int rowIdx = 0;
for (SimulationResult d : data) {
res[rowIdx] = d.getAsTableRow();
rowIdx++;
}
// collect scenario names that are in the ProjectRunResultDialog
if( scenarios.size() == 1 && data.size() > 1) { // only one scenario was run, but multiple times
// merge results from all runs into one MultiValueMap (allows duplicate entries)
MultiMap mergedResults = new MultiValueMap();
data.forEach(d -> mergedResults.putAll(d.getData()));
// iterate over keys
Iterator it = mergedResults.entrySet().iterator();
int n = mergedResults.entrySet().size();
Map<Object, Map> summaryStat = new HashMap();
String[] stats = new String[]{"min","max","mean","std"};
while (it.hasNext()) {
Map.Entry mapEntry = (Map.Entry) it.next();
if(mapEntry.getValue() instanceof ArrayList) {
ArrayList tmp_val = (ArrayList) mapEntry.getValue();
double min = -1;
double max = -1;
double mean = -1;
double std = -1;
HashMap tmp_summary = new HashMap<>();
if(tmp_val.get(0) instanceof Double){
ArrayList<Double> values = (ArrayList<Double>) mapEntry.getValue(); // todo: what if there is another data type (e.g. Long)
min= Collections.min(values); // min
max = Collections.max(values); // max
mean= 0; // mean
std = 0; // std
for (Double val : values) {
mean += val;
}
mean = mean / values.size();
for (Double val : values) {
std += (val - mean) * (val - mean);
}
std = std / (values.size() - 1);
std = Math.sqrt(std);
}else{
System.out.println("ProjectRunResultDialog: Type is not yet supported \n " + tmp_val.get(0).getClass());
}
tmp_summary.put("mean",mean);
tmp_summary.put("min", min);
tmp_summary.put("std", std);
tmp_summary.put("max", max);
summaryStat.put(mapEntry.getKey(), tmp_summary);
}else{
System.out.println("ProjectRunResultDialog: Type is not yet supported \n " + mapEntry.getValue().getClass());
}
}
String[] emptyString = new String[n+3];
java.util.Arrays.fill(emptyString,"");
res[rowIdx++] = emptyString; // separate summary stat.
for(int i_stat = 0; i_stat < stats.length; i_stat++){
int icol = 0;
String[] tmp_stat = new String[n+3];
tmp_stat[icol++] = "summaryStats: " + stats[i_stat];
tmp_stat[icol++] = "-";
for(int i_proc = 2; i_proc < data.getFirst().getHeaders().length-1; i_proc++){
tmp_stat[icol++] = summaryStat.get(data.getFirst().getHeaders()[i_proc]).get(stats[i_stat]).toString();
}
tmp_stat[icol] = "-";
res[rowIdx++] = tmp_stat;
}
}
return res;
}
......
......@@ -4,37 +4,7 @@ package org.vadere.gui.projectview.view;
import org.jetbrains.annotations.NotNull;
import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.postvisualization.control.Player;
import org.vadere.gui.projectview.control.ActionAddScenario;
import org.vadere.gui.projectview.control.ActionCloneScenario;
import org.vadere.gui.projectview.control.ActionCloseApplication;
import org.vadere.gui.projectview.control.ActionCreateProject;
import org.vadere.gui.projectview.control.ActionDeleteOutputDirectories;
import org.vadere.gui.projectview.control.ActionDeleteScenarios;
import org.vadere.gui.projectview.control.ActionEditScenarioDescription;
import org.vadere.gui.projectview.control.ActionGenerateScenarioFromOutputFile;
import org.vadere.gui.projectview.control.ActionInterruptScenarios;
import org.vadere.gui.projectview.control.ActionLoadProject;
import org.vadere.gui.projectview.control.ActionLoadRecentProject;
import org.vadere.gui.projectview.control.ActionNextTimeStep;