Commit a7e19309 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

changes for version 0.5

parent 9a44a670
...@@ -9,6 +9,8 @@ import org.vadere.simulator.projects.migration.MigrationException; ...@@ -9,6 +9,8 @@ import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.MigrationOptions; import org.vadere.simulator.projects.migration.MigrationOptions;
import org.vadere.simulator.projects.migration.helper.MigrationUtil; 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.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -25,6 +27,7 @@ public class MigrationSubCommand implements SubCommandRunner { ...@@ -25,6 +27,7 @@ public class MigrationSubCommand implements SubCommandRunner {
boolean revertMode = ns.getBoolean("revert-migration"); boolean revertMode = ns.getBoolean("revert-migration");
boolean recursive = ns.getBoolean("recursive"); boolean recursive = ns.getBoolean("recursive");
List<String> paths = ns.getList("paths"); List<String> paths = ns.getList("paths");
String newVersion = ns.getString("create-new-version");
ArrayList<Path> files = new ArrayList<>(); ArrayList<Path> files = new ArrayList<>();
ArrayList<Path> dirs = new ArrayList<>(); ArrayList<Path> dirs = new ArrayList<>();
...@@ -50,6 +53,10 @@ public class MigrationSubCommand implements SubCommandRunner { ...@@ -50,6 +53,10 @@ public class MigrationSubCommand implements SubCommandRunner {
throw new MigrationException("Error in input paths"); throw new MigrationException("Error in input paths");
} }
if (newVersion != null && dirs.size() == 1){
createNewTransformFiles(dirs.get(0), newVersion);
return;
}
if (revertMode) { if (revertMode) {
for (Path file : files) { for (Path file : files) {
...@@ -75,6 +82,18 @@ public class MigrationSubCommand implements SubCommandRunner { ...@@ -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 { private void revert(Path scenarioFile) throws MigrationException {
MigrationAssistant ma = MigrationAssistant.getNewInstance(MigrationOptions.defaultOptions()); MigrationAssistant ma = MigrationAssistant.getNewInstance(MigrationOptions.defaultOptions());
ma.revertFile(scenarioFile); ma.revertFile(scenarioFile);
......
...@@ -20,7 +20,7 @@ public class VadereConsole { ...@@ -20,7 +20,7 @@ public class VadereConsole {
public static void main(String[] args) { public static void main(String[] args) {
ArgumentParser parser = createArgumentParser(); 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 { try {
Namespace ns = parser.parseArgs(args); Namespace ns = parser.parseArgs(args);
SubCommandRunner sRunner = ns.get("func"); SubCommandRunner sRunner = ns.get("func");
...@@ -145,6 +145,14 @@ public class VadereConsole { ...@@ -145,6 +145,14 @@ public class VadereConsole {
.help("If PATH contains a directory instead of a scenario file recursively search " + .help("If PATH contains a directory instead of a scenario file recursively search " +
"the directory tree for scenario files and apply the command"); "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; return parser;
} }
......
...@@ -4,8 +4,6 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass; ...@@ -4,8 +4,6 @@ import org.vadere.annotation.factories.dataprocessors.DataProcessorClass;
import org.vadere.simulator.control.SimulationState; import org.vadere.simulator.control.SimulationState;
import org.vadere.simulator.projects.dataprocessing.ProcessorManager; import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepPedestrianIdOverlap; 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.DynamicElement;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.scenario.Topography; import org.vadere.state.scenario.Topography;
...@@ -21,18 +19,16 @@ import java.util.stream.Collectors; ...@@ -21,18 +19,16 @@ import java.util.stream.Collectors;
*/ */
@DataProcessorClass() @DataProcessorClass()
public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdOverlap, Double> { public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrianIdOverlap, Double> {
private double pedRadius;
private double minDist; private double minDist;
public PedestrianOverlapProcessor() { public PedestrianOverlapProcessor() {
super("overlaps"); super("overlaps");
setAttributes(new AttributesPedestrianOverlapProcessor());
} }
@Override @Override
protected void doUpdate(final SimulationState state) { 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); Collection<Pedestrian> peds = state.getTopography().getElements(Pedestrian.class);
minDist = pedRadius * 2; minDist = pedRadius * 2;
int timeStep = state.getStep(); int timeStep = state.getStep();
...@@ -40,7 +36,7 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian ...@@ -40,7 +36,7 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
// get all Pedestrians with at moust pedRadius*2.5 distance away // get all Pedestrians with at moust pedRadius*2.5 distance away
// this reduces the amount auf overlap test. // this reduces the amount auf overlap test.
VPoint pedPos = ped.getPosition(); 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 // collect pedIds and distance of all overlaps for the current ped in the current timestep
List<Pair> overlaps = neighbours List<Pair> overlaps = neighbours
.parallelStream() .parallelStream()
...@@ -55,9 +51,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian ...@@ -55,9 +51,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
@Override @Override
public void init(final ProcessorManager manager) { public void init(final ProcessorManager manager) {
super.init(manager); super.init(manager);
AttributesPedestrianOverlapProcessor att = (AttributesPedestrianOverlapProcessor) this.getAttributes();
this.pedRadius = att.getPedRadius();
} }
private List<DynamicElement> getDynElementsAtPosition(final Topography topography, VPoint sourcePosition, double radius) { private List<DynamicElement> getDynElementsAtPosition(final Topography topography, VPoint sourcePosition, double radius) {
...@@ -65,15 +58,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian ...@@ -65,15 +58,6 @@ public class PedestrianOverlapProcessor extends DataProcessor<TimestepPedestrian
return dynElements.getObjects(sourcePosition, radius); return dynElements.getObjects(sourcePosition, radius);
} }
@Override
public AttributesProcessor getAttributes() {
if (super.getAttributes() == null) {
setAttributes(new AttributesPedestrianOverlapProcessor());
}
return super.getAttributes();
}
class Pair{ class Pair{
int id; int id;
......
...@@ -46,7 +46,7 @@ public class MigrationUtil { ...@@ -46,7 +46,7 @@ public class MigrationUtil {
return Arrays.stream(addAll).collect(Collectors.toCollection(ArrayList::new)); 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 oldTransform = JoltTransformation.getTransforamtionFile(Version.latest());
Path oldIdentity = JoltTransformation.getIdenityFile(Version.latest()); Path oldIdentity = JoltTransformation.getIdenityFile(Version.latest());
...@@ -63,7 +63,7 @@ public class MigrationUtil { ...@@ -63,7 +63,7 @@ public class MigrationUtil {
json = json.replace("\"release\": \"" + Version.latest().label('-') + "\",", "\"release\": \"" + newVersionLabel + "\","); json = json.replace("\"release\": \"" + Version.latest().label('-') + "\",", "\"release\": \"" + newVersionLabel + "\",");
IOUtils.writeTextFile(newIdenity.toString(), json); 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); 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"