24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit a7e19309 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck

changes for version 0.5

parent 9a44a670
......@@ -9,6 +9,8 @@ import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.MigrationOptions;
import org.vadere.simulator.projects.migration.helper.MigrationUtil;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
......@@ -25,6 +27,7 @@ public class MigrationSubCommand implements SubCommandRunner {
boolean revertMode = ns.getBoolean("revert-migration");
boolean recursive = ns.getBoolean("recursive");
List<String> paths = ns.getList("paths");
String newVersion = ns.getString("create-new-version");
ArrayList<Path> files = new ArrayList<>();
ArrayList<Path> dirs = new ArrayList<>();
......@@ -50,6 +53,10 @@ public class MigrationSubCommand implements SubCommandRunner {
throw new MigrationException("Error in input paths");
}
if (newVersion != null && dirs.size() == 1){
createNewTransformFiles(dirs.get(0), newVersion);
return;
}
if (revertMode) {
for (Path file : files) {
......@@ -75,6 +82,18 @@ public class MigrationSubCommand implements SubCommandRunner {
}
private void createNewTransformFiles(Path dest, String versionLabel) throws MigrationException {
MigrationUtil migrationUtil = new MigrationUtil();
try {
migrationUtil.generateNewVersionTransform(dest, versionLabel);
} catch (URISyntaxException e) {
throw new MigrationException("Error creating new transformation", e);
} catch (IOException e) {
throw new MigrationException("Error creating new transformation", e);
}
}
private void revert(Path scenarioFile) throws MigrationException {
MigrationAssistant ma = MigrationAssistant.getNewInstance(MigrationOptions.defaultOptions());
ma.revertFile(scenarioFile);
......
......@@ -20,7 +20,7 @@ public class VadereConsole {
public static void main(String[] args) {
ArgumentParser parser = createArgumentParser();
// args = new String[]{"migrate", "-f", "/home/lphex/hm.d/vadere/VadereSimulator/testResources/data/simpleProject/output/test_postvis_2018-01-17_16-56-37.307/test_postvis.scenario"};
// args = new String[]{"migrate", "--create-new-version", "0.5", "/home/lphex/hm.d/vadere/VadereSimulator/resources"};
try {
Namespace ns = parser.parseArgs(args);
SubCommandRunner sRunner = ns.get("func");
......@@ -145,6 +145,14 @@ public class VadereConsole {
.help("If PATH contains a directory instead of a scenario file recursively search " +
"the directory tree for scenario files and apply the command");
migrationAssistant.addArgument("--create-new-version")
.required(false)
.type(String.class)
.dest("create-new-version")
.help("Create new transformation and identity file based on current latest version" +
"PATH must point to the directory containing the old transformation files." +
" This Argument takes the new Version Label as input");
return parser;
}
......
......@@ -4,8 +4,6 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlap;
import org.vadere.state.attributes.processor.AttributesPedestrianOverlapProcessor;
import org.vadere.state.attributes.processor.AttributesProcessor;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography;
......@@ -21,18 +19,16 @@ import java.util.stream.Collectors;
*/
@DataProcessorClass()
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdOverlap, Double> {
private double pedRadius;
private double minDist;
public PedestrianOverlapProcessor() {
super("overlaps");
setAttributes(new AttributesPedestrianOverlapProcessor());
}
@Override
protected void doUpdate(final SimulationState state) {
this.pedRadius = state.getTopography().getAttributesPedestrian().getRadius(); // in init there is no access to the state
double pedRadius = state.getTopography().getAttributesPedestrian().getRadius();
Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
minDist = pedRadius * 2;
int timeStep = state.getStep();
......@@ -40,7 +36,7 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
// get all Pedestrians with at moust pedRadius*2.5 distance away
// this reduces the amount auf overlap test.
VPoint pedPos = ped.getPosition();
List<DynamicElement> neighbours = getDynElementsAtPosition(state.getTopography(), ped.getPosition(), pedRadius*2.5);
List<DynamicElement> neighbours = getDynElementsAtPosition(state.getTopography(), ped.getPosition(), pedRadius *2.5);
// collect pedIds and distance of all overlaps for the current ped in the current timestep
List<Pair> overlaps = neighbours
.parallelStream()
......@@ -55,9 +51,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
@Override
public void init(final ProcessorManager manager) {
super.init(manager);
AttributesPedestrianOverlapProcessor att = (AttributesPedestrianOverlapProcessor) this.getAttributes();
this.pedRadius = att.getPedRadius();
}
private List<DynamicElement> getDynElementsAtPosition(final Topography topography, VPoint sourcePosition, double radius) {
......@@ -65,15 +58,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
return dynElements.getObjects(sourcePosition, radius);
}
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesPedestrianOverlapProcessor());
}
return super.getAttributes();
}
class Pair{
int id;
......
......@@ -46,7 +46,7 @@ public class MigrationUtil {
return Arrays.stream(addAll).collect(Collectors.toCollection(ArrayList::new));
}
private void generateNewVersionTransform(Path resourceDir, String newVersionLabel) throws URISyntaxException, IOException {
public void generateNewVersionTransform(Path resourceDir, String newVersionLabel) throws URISyntaxException, IOException {
Path oldTransform = JoltTransformation.getTransforamtionFile(Version.latest());
Path oldIdentity = JoltTransformation.getIdenityFile(Version.latest());
......@@ -63,7 +63,7 @@ public class MigrationUtil {
json = json.replace("\"release\": \"" + Version.latest().label('-') + "\",", "\"release\": \"" + newVersionLabel + "\",");
IOUtils.writeTextFile(newIdenity.toString(), json);
json = json.replace("\"release\": \"&\",", "// no relase here to overwrite it with default at the default operation down below");
json = json.replace("\"release\": \"&\",", "// no release here to overwrite it with default at the default operation down below");
IOUtils.writeTextFile(newTransform.toString(), json);
}
......
{
"name" : "basic_2_density_discrete_ca",
"description" : "",
"release" : "0.4",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
"filename" : "density.txt",
"processors" : [ 1 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "out.txt",
"processors" : [ 3 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "out1.txt",
"processors" : [ 4 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianDensityCountingProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianDensityCountingProcessor",
"attributes" : {
"pedestrianPositionProcessorId" : 2,
"radius" : 1.5
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 2
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 3,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianOverlapProcessor",
"attributes" : {
"pedRadius" : 0.2
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 4,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 3
}
} ],
"isTimestamped" : true
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"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"
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"varyStepDirection" : false,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"optimizationType" : "DISCRETE",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"minimumStepLength" : 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.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
}
},
"attributesSimulation" : {
"finishTime" : 200.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : true,
"visualizationEnabled" : true,
"printFPS" : false,
"needsBoundary" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 38.0,
"height" : 12.0
},
"boundingBoxWidth" : 0.5,
"bounded" : true
},
"obstacles" : [ {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 9.0,
"y" : 12.0
}, {
"x" : 9.0,
"y" : 10.0
}, {
"x" : 30.0,
"y" : 7.0
}, {
"x" : 30.0,
"y" : 12.0
} ]
},
"id" : -1
}, {
"shape" : {
"type" : "POLYGON",
"points" : [ {
"x" : 9.0,
"y" : 0.0
}, {
"x" : 9.0,
"y" : 2.0
}, {
"x" : 30.0,
"y" : 5.0
}, {
"x" : 30.0,
"y" : 0.0
} ]
},
"id" : -1
} ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 35.0,
"y" : 5.0,
"width" : 2.0,
"height" : 2.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"sources" : [ {
"id" : -1,
"shape" : {
"x" : 1.0,
"y" : 1.0,
"width" : 3.0,
"height" : 10.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 200,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : true,
"useFreeSpaceOnly" : false,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null
}
}
}
\ No newline at end of file
{
"name" : "corner_waiting_time_processor_test",
"description" : "",
"release" : "0.4",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.PedestrianIdOutputFile",
"filename" : "waitingTimes.txt",
"processors" : [ 1 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.PedestrianIdOutputFile",
"filename" : "evacuationTimes.txt",
"processors" : [ 2 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.NoDataKeyOutputFile",
"filename" : "out.txt",
"processors" : [ 5 ]
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOverlapOutputFile",
"filename" : "out1.txt",
"processors" : [ 6 ]
} ],
"processors" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianWaitingTimeProcessor",
"id" : 1,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor",
"attributes" : {
"waitingArea" : {
"x" : 1.0,
"y" : 3.5,
"width" : 9.5,
"height" : 10.0,
"type" : "RECTANGLE"
}
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianEvacuationTimeProcessor",
"id" : 2,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianEvacuationTimeProcessor",
"attributes" : {
"pedestrianStartTimeProcessorId" : 4
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianPositionProcessor",
"id" : 3
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianStartTimeProcessor",
"id" : 4
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.NumberOverlapsProcessor",
"id" : 5,
"attributesType" : "org.vadere.state.attributes.processor.AttributesNumberOverlapsProcessor",
"attributes" : {
"pedestrianOverlapProcessorId" : 6
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianOverlapProcessor",
"id" : 6,
"attributesType" : "org.vadere.state.attributes.processor.AttributesPedestrianOverlapProcessor",
"attributes" : {
"pedRadius" : 0.2
}
} ],
"isTimestamped" : true
},
"scenario" : {
"mainModel" : "org.vadere.simulator.models.osm.OptimalStepsModel",
"attributesModel" : {
"org.vadere.state.attributes.models.AttributesFloorField" : {
"createMethod" : "HIGH_ACCURACY_FAST_MARCHING",
"potentialFieldResolution" : 0.1,
"obstacleGridPenalty" : 0.1,
"targetAttractionStrength" : 1.0,
"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"
}
},
"org.vadere.state.attributes.models.AttributesOSM" : {
"stepCircleResolution" : 18,
"numberOfCircles" : 1,
"varyStepDirection" : true,
"stepLengthIntercept" : 0.4625,
"stepLengthSlopeSpeed" : 0.2345,
"stepLengthSD" : 0.036,
"movementThreshold" : 0.0,
"optimizationType" : "DISCRETE",
"movementType" : "ARBITRARY",
"dynamicStepLength" : false,
"updateType" : "EVENT_DRIVEN",
"seeSmallWalls" : false,
"minimumStepLength" : 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.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
}
},
"attributesSimulation" : {
"finishTime" : 100.0,
"simTimeStepLength" : 0.4,
"realTimeSimTimeRatio" : 0.0,
"writeSimulationData" : false,
"visualizationEnabled" : true,
"printFPS" : false,
"needsBoundary" : false,
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
"bounds" : {
"x" : 0.0,
"y" : 0.0,
"width" : 14.0,
"height" : 18.0
},
"boundingBoxWidth" : 1.0,
"bounded" : true
},
"obstacles" : [ {
"shape" : {
"x" : 0.8,
"y" : 3.0,
"width" : 10.2,
"height" : 1.0,
"type" : "RECTANGLE"
},
"id" : -1
}, {
"shape" : {
"x" : 10.0,
"y" : 4.0,
"width" : 1.0,
"height" : 9.0,
"type" : "RECTANGLE"
},
"id" : -1
} ],
"stairs" : [ ],
"targets" : [ {
"id" : 1,
"absorbing" : true,
"shape" : {
"x" : 11.0,
"y" : 15.0,
"width" : 2.0,
"height" : 2.0,
"type" : "RECTANGLE"
},
"waitingTime" : 0.0,
"waitingTimeYellowPhase" : 0.0,
"parallelWaiters" : 0,
"individualWaiting" : true,
"deletionDistance" : 0.1,
"startingWithRedLight" : false,
"nextSpeed" : -1.0
} ],
"sources" : [ {
"id" : -1,
"shape" : {
"x" : 1.2,
"y" : 1.2,
"width" : 6.0,
"height" : 1.6,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 20,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
"spawnAtRandomPositions" : true,
"useFreeSpaceOnly" : false,
"targetIds" : [ 1 ],
"groupSizeDistribution" : [ 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ {
"source" : null,
"targetIds" : [ 1 ],
"position" : {
"x" : 4.3,
"y" : 4.6
},
"velocity" : {
"x" : 0.0,
"y" : 0.0
},
"nextTargetListIndex" : -1,
"freeFlowSpeed" : 1.34,
"attributes" : {
"id" : -1,
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.0,
"minimumSpeed" : 0.3,
"maximumSpeed" : 3.0,
"acceleration" : 2.0
},
"idAsTarget" : -1,
"modelPedestrianMap" : { },
"isChild" : false,
"isLikelyInjured" : false,
"groupIds" : [ ],
"type" : "PEDESTRIAN"
} ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
"speedDistributionMean" : 1.34,
"speedDistributionStandardDeviation" : 0.26,
"minimumSpeed" : 0.5,
"maximumSpeed" : 2.2,
"acceleration" : 2.0
},
"attributesCar" : null
}
}
}
\ No newline at end of file
......@@ -53,9 +53,9 @@ public class TestTrajectoryReader {
}
private void resetTestStructure() throws URISyntaxException {
String dest = getClass().getResource("/data/VTestMultiRun").toURI().getPath();
String backup = getClass().getResource("/data/VTestMultiRun.bak").toURI().getPath();
TestUtils.resetTestStructure(dest, backup);
String source = getClass().getResource("/data/VTestMultiRun").toURI().getPath();
String dest = getClass().getResource("/data/VTestMultiRun.bak").toURI().getPath();
TestUtils.copyDirTo(source, dest);
}
......
......@@ -3,7 +3,6 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.junit.Before;
import org.junit.Test;
import org.vadere.simulator.control.SimulationState;
import org.vadere.state.attributes.processor.AttributesPedestrianOverlapProcessor;
import static org.junit.Assert.assertEquals;
......@@ -23,9 +22,7 @@ public class PedestrianOverlapProcessorTest extends ProcessorTest {
@Test
public void init() throws Exception {
AttributesPedestrianOverlapProcessor att = (AttributesPedestrianOverlapProcessor) p.getAttributes();
assertInit(p);
assertEquals(att.getPedRadius(), r.valOfField("pedRadius"), 0.001);
for (SimulationState s : processorTestEnv.getSimStates()) {
p.update(s);
......
......@@ -17,7 +17,6 @@ public class AttributesSimulation extends Attributes {
private boolean writeSimulationData = true;
private boolean visualizationEnabled = true;
private boolean printFPS = false;
private boolean needsBoundary = false;
private int digitsPerCoordinate = 2;
private boolean useFixedSeed = true;
private long fixedSeed = new Random().nextLong();
......@@ -49,9 +48,6 @@ public class AttributesSimulation extends Attributes {
return printFPS;
}
public boolean isNeedsBoundary() {
return needsBoundary;
}