Commit ef7b2841 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

Merge branch 'master' of https://gitlab.lrz.de/vadere/vadere

parents c0ea7924 926b990a
Pipeline #218456 failed with stages
in 129 minutes and 59 seconds
......@@ -79,9 +79,9 @@ stages:
- mvn clean
- mvn -Dmaven.test.skip=true package
- python3 -m zipfile -c ${VADERE_PACKAGE_NAME_BRANCHES} CHANGELOG.md README.md Scenarios/ VadereGui/target/vadere-gui.jar VadereSimulator/target/vadere-console.jar
- scp ${VADERE_PACKAGE_NAME_BRANCHES} di49mur@webdev-mwn.lrz.de:~/webserver/htdocs/builds/master/${VADERE_PACKAGE_NAME_BRANCHES}
- scp ${VADERE_PACKAGE_NAME_BRANCHES} di49mur@webdev02-mwn.lrz.de:./webserver/htdocs/builds/master/${VADERE_PACKAGE_NAME_BRANCHES}
- python3 -m zipfile -c ${EIKMESH_PACKAGE_NAME_BRANCHES} VadereMeshing/README.md VadereMeshing/target/meshing-0.1-SNAPSHOT.jar
- scp ${EIKMESH_PACKAGE_NAME_BRANCHES} di49mur@webdev-mwn.lrz.de:~/webserver/htdocs/builds/master/eikmesh/${EIKMESH_PACKAGE_NAME_BRANCHES}
- scp ${EIKMESH_PACKAGE_NAME_BRANCHES} di49mur@webdev02-mwn.lrz.de:./webserver/htdocs/builds/master/eikmesh/${EIKMESH_PACKAGE_NAME_BRANCHES}
only:
refs:
- master
......@@ -93,7 +93,7 @@ stages:
- mvn clean
- mvn -Dmaven.test.skip=true package
- python3 -m zipfile -c ${VADERE_PACKAGE_NAME_RELEASES} CHANGELOG.md README.md Scenarios/ VadereGui/target/vadere-gui.jar VadereSimulator/target/vadere-console.jar
- scp ${VADERE_PACKAGE_NAME_RELEASES} di49mur@webdev-mwn.lrz.de:~/webserver/htdocs/builds/stable/${VADERE_PACKAGE_NAME_RELEASES}
- scp ${VADERE_PACKAGE_NAME_RELEASES} di49mur@webdev02-mwn.lrz.de:./webserver/htdocs/builds/stable/${VADERE_PACKAGE_NAME_RELEASES}
# Run job only for "tags" (usually on the "stable" branch). Watch out: Multiple "only" tags are ORed together.
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/27818
only:
......@@ -106,7 +106,7 @@ stages:
- mvn clean
- mvn -Dmaven.test.skip=true package
- python3 -m zipfile -c ${VADERE_PACKAGE_NAME_BRANCHES} CHANGELOG.md README.md Scenarios/ VadereGui/target/vadere-gui.jar VadereSimulator/target/vadere-console.jar
- scp ${VADERE_PACKAGE_NAME_BRANCHES} di49mur@webdev-mwn.lrz.de:~/webserver/htdocs/builds/branches/${VADERE_PACKAGE_NAME_BRANCHES}
- scp ${VADERE_PACKAGE_NAME_BRANCHES} di49mur@webdev02-mwn.lrz.de:./webserver/htdocs/builds/branches/${VADERE_PACKAGE_NAME_BRANCHES}
when: manual
.template_seed_test:
......
......@@ -28,4 +28,40 @@ Please, use following instructions to set up the OpenCL components for your oper
</details>
* [Intel Driverpack (only driver needed)](https://software.intel.com/en-us/articles/opencl-drivers#latest_linux_driver)
# Geforce RTX 2080 Ti eingebaut und installiert am 21.02.2019
``` installing rtx 1080 ti on minimuc
$ sudo apt-add-repository ppa:graphics-drivers/ppa
$ sudo apt install nvidia-utils-440
$ sudo apt install nvidia-driver-418 nvidia-settings
$ sudo reboot
#check driver
$ nvidia-smi
Fri Feb 21 13:01:51 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59 Driver Version: 440.59 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 208... Off | 00000000:3B:00.0 Off | N/A |
| 34% 36C P0 41W / 260W | 0MiB / 11019MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
```
``` add symbolic link from libOpenCL.so.1 -> libOpenCL.so
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/lib/x86_64-linux-gnu/libOpenCL.so
cd /etc
sudo mv ld.so.cache ld.so.cache.bak
sudo ldconfig
```
\ No newline at end of file
......@@ -12,14 +12,14 @@
"expectedResult" : "SUCCESS",
"optimizationMetricProcessorId" : 2,
"testEvacuationProcessorId" : 3,
"maxMeanPointDistance" : 0.06642665170830378,
"maxMeanDifferenceFuncValue" : 0.038131134445867326,
"maxMeanPointDistance" : 0.0741743541679023,
"maxMeanDifferenceFuncValue" : 0.03977588209021506,
"infoMinPointDistanceL2" : 0.0,
"infoMaxPointDistanceL2" : 1.0500643679096149,
"infoMinFuncDifference" : -0.0053311824072430625,
"infoMaxFuncDifference" : 3.112265864907295,
"infoStddevPointDistance" : 0.10963419080612646,
"infoStddevDifferenceFuncValue" : 0.14872546127402636
"infoMaxPointDistanceL2" : 1.116456695995013,
"infoMinFuncDifference" : -0.014172405140369548,
"infoMaxFuncDifference" : 3.285814543687535,
"infoStddevPointDistance" : 0.12307022389816641,
"infoStddevDifferenceFuncValue" : 0.13840077341363527
}
}, {
"type" : "org.vadere.simulator.projects.dataprocessing.processor.PedestrianMetricOptimizationProcessor",
......@@ -234,15 +234,15 @@
"sources" : [ {
"id" : 2,
"shape" : {
"x" : 2.5,
"y" : 8.0,
"width" : 3.95,
"height" : 4.74,
"x" : 0.6,
"y" : 6.4,
"width" : 10.0,
"height" : 8.0,
"type" : "RECTANGLE"
},
"interSpawnTimeDistribution" : "org.vadere.state.scenario.ConstantDistribution",
"distributionParameters" : [ 1.0 ],
"spawnNumber" : 100,
"spawnNumber" : 70,
"maxSpawnNumberTotal" : -1,
"startTime" : 0.0,
"endTime" : 0.0,
......
Density.measurementRadius = 15
Density.measurementScale = 10.0
Density.standardDeviation = 0.5
Gui.dataProcessingViewMode = json
Gui.toolbar.size = 40
Messages.language = en
SettingsDialog.dataFormat = yyyy_MM_dd_HH_mm_ss
PostVis.maxNumberOfSaveDirectories = 5
Pedestrian.radius = 0.195
PostVis.SVGHeight = 768
PostVis.SVGWidth = 1024
PostVis.cellWidth = 1.0
Gui.lastSavePoint =
ProjectView.maxCellWidth = 10.0
Density.measurementRadius = 15
PostVis.minCellWidth = 0.01
Testing.stepCircleOptimization.compareBruteForceSolution = true
PostVis.enableJsonInformationPanel = true
PostVis.framesPerSecond = 5
PostVis.maxCellWidth = 10.0
PostVis.maxFramePerSecond = 30
PostVis.maxNumberOfSaveDirectories = 5
PostVis.minCellWidth = 0.01
PostVis.framesPerSecond = 20
Gui.toolbar.size = 40
Messages.language = en
ProjectView.icon.width.value = 35
ProjectView.cellWidth = 1.0
ProjectView.icon.height.value = 35
ProjectView.icon.width.value = 35
ProjectView.maxCellWidth = 10.0
ProjectView.minCellWidth = 0.01
SettingsDialog.dataFormat = yyyy_MM_dd_HH_mm_ss
SettingsDialog.maxNumberOfTargets = 10
SettingsDialog.outputDirectory.path = .
PostVis.SVGHeight = 768
ProjectView.defaultDirectoryAttributes =
TopographyCreator.dotRadius = 0.5
History.lastUsedProject =
History.recentProjects =
SettingsDialog.showLogo = false
Gui.dataProcessingViewMode = json
SettingsDialog.outputDirectory.path = .
SettingsDialog.snapshotDirectory.path = .
Testing.stepCircleOptimization.compareBruteForceSolution = true
TopographyCreator.dotRadius = 0.5
PostVis.SVGWidth = 1024
ProjectView.defaultDirectory =
ProjectView.defaultDirectoryScenarios =
Density.measurementScale = 10.0
PostVis.maxFramePerSecond = 40
ProjectView.minCellWidth = 0.01
PostVis.cellWidth = 1.0
ProjectView.defaultDirectoryOutputProcessors =
Gui.showNodes = false
Project.ScenarioChecker.active = false
Vadere.cache.globalCacheBaseDir =
Gui.node.radius = 0.3
Project.simulationResult.show = true
Vadere.cache.useGlobalCacheBaseDir = false
PostVis.timeResolution = 0.4
......@@ -69,6 +69,19 @@ cli2.startScenario(scenarioPath)
embed()
```
```python
if __name__ == "__main__":
c = Py4jClient.create(
project_path="VADERE_PATH/Scenarios/Demos/roVer/scenarios",
vadere_base_path="VADERE_PATH",
start_server=False,
debug=False,
)
c.entrypoint_jar = "/VADERE_PATH/Tools/PythonTraciWrapper/vadere-traci-entrypoint.jar"
c.connect()
c.startScenario("roVerTest002.scenario")
```
## Extend API
If new TraCI commands are implemented in vadere, these can also be used via a python client. To achieve this the following steps are required:
......
......@@ -46,6 +46,7 @@ class Py4jClient:
self.server_log = server_log
self.entrypoint_log = entry_point_log
self.debug = debug
self.entrypoint_jar = ''
self._build_argparser()
if isinstance(args, List):
......@@ -53,6 +54,7 @@ class Py4jClient:
else:
self._parser.parse_args(["--help"])
def connect(self):
self._start_entrypoint()
self._connect_gateway()
......@@ -111,12 +113,18 @@ class Py4jClient:
def _start_entrypoint(self):
if self.start_server:
if self.entrypoint_jar == '':
jar_path = os.path.join(
self.vadere_base_path,
"VadereManager/target/vadere-server.jar",
),
else:
jar_path = self.entrypoint_jar
vadere_server_cmd = [
"java",
"-jar",
os.path.join(
self.vadere_base_path, "VadereManager/target/vadere-server.jar",
),
jar_path,
]
vadere_server_cmd.extend(self._server_args())
self.server_thread = Runner(
......@@ -132,13 +140,18 @@ class Py4jClient:
self.server_thread = None
print("Connecting to existing Server...")
entrypoint_cmd = [
"java",
"-jar",
os.path.join(
if self.entrypoint_jar == '':
jar_path = os.path.join(
self.vadere_base_path,
"VadereManager/target/vadere-traci-entrypoint.jar",
),
else:
jar_path = self.entrypoint_jar
entrypoint_cmd = [
"java",
"-jar",
jar_path,
]
entrypoint_cmd.extend(self._entrypoint_args())
self.entrypoint_thread = Runner(
......@@ -252,13 +265,3 @@ class Py4jClient:
dest="defaultScenario",
help="Supply a default scenario",
)
if __name__ == "__main__":
c = Py4jClient.create(
project_path="/path/to/vadere/scenarios/",
vadere_base_path="/path/to/vadere",
start_server=False,
debug=False,
)
c.startScenario("Test001.scenario")
.idea
__pycache__
*.pyc
.mypy_cache/
*.csv
......@@ -9,8 +10,11 @@ log.out
# do not track Vadere outputs (folders and files and environments), every computer as different paths, which results in changes for every commit.
vadere_scenarios
*.scenarios
!tutorial/example.scenario
*.scenario
*.project
*.json
# will be created automatically:
suqc/suqc_envs/
......@@ -18,14 +22,13 @@ suqc/suqc_envs/
*.jar
# Configuration files (generated when importing the project)
suq_config.json
suq_controller.conf
update_server.sh
# pickle files
*.p
# Ignore virtual environment
venv
......@@ -36,5 +39,5 @@ suqc.egg-info
# tutorial output
/tutorial/example_output/
/tutorial/*/
/tutorial/example_multirun_output/
......@@ -9,35 +9,16 @@ git subtree pull --prefix Tools/SUQController git@gitlab.lrz.de:vadere/suq-contr
### WORK IN PROGRESS
The suq-controller connects the modules "Surrogate Model" (S) and "Uncertainty Quantification" (UQ) (see other vadere Repos).
The main functionality of the `suq-controller` is to query many differently parametrized VADERE scenarios and
return the result of specified quantity of interests (QoI) in a convenient format ([pandas DataFrame](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html)).
This git repository uses git large file storage (git-lfs). This allows to ship default VADERE models (larger .jar files.)
with the git repository.
For developers: To install git-lfs follow the instructions [here](https://github.com/git-lfs/git-lfs/wiki/Installation)
In file `.gitattributes` in the repo shows the settings for git-lfs.
### Glossary
Other words were used in this project to not confuse terminology with VADERE (such as `scenario` and `project`).
* **container** is the parent folder of (multiple) environments
* **environment** is folder consisting of a specifed VADERE scenario that is intended to query
* **request** is an user request for a quantity of interest for the specific VADERE setting with the given the scenario
set in the environment. A query can simulate VADERE for multiple scenario settings for the parameter variation
(such as a full grid sampling).
The suq-controller connects the modules "Surrogate Model" (S) and "Uncertainty
Quantification" (UQ) (see other Vadere group repos).
The main functionality of the `suq-controller` is to sample parameters from Vadere
and return the result of specified quantity of interests (QoI) in a convenient format
([pandas DataFrame](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html)).
## Getting started
Either install as a Python package or run the source code directly. Either way it is recommended to use Python>=3.6
### Using the code
#### Use source directly:
......@@ -47,7 +28,7 @@ Run the code from the source directly (without install), please check if you mee
To install as a package `suqc` run
```
python3 setup.py install
python setup.py install
```
from the command line. (Note: In Linux this may have to be executed with `sudo`).
......@@ -55,7 +36,7 @@ from the command line. (Note: In Linux this may have to be executed with `sudo`)
Test if the installed package was installed successfully by running:
```
python3 -c "import suqc; print(suqc.__version__)"
python -c "import suqc; print(suqc.__version__)"
```
This command should print the installed version number (and potentially infos to set up required folder) in the terminal. In case an error was thrown the package is
......
matplotlib==2.2.3
setuptools==39.1.0
setuptools>=39.1.0
fabric==2.4.0
pandas==0.23.4
numpy==1.15.4
scikit-learn==0.20.2
pandas>=0.24.0,<1.0.0
numpy>=1.17.0
scikit-learn>=0.21.0
#!/usr/bin/env python3
# TODO: """ << INCLUDE DOCSTRING (one-line or multi-line) >> """
import os
from setuptools import setup, find_packages
......@@ -9,13 +7,6 @@ from setuptools import setup, find_packages
from suqc.configuration import SuqcConfig
from suqc import __version__
# --------------------------------------------------
# people who contributed code
__authors__ = "Daniel Lehmberg"
# people who made suggestions or reported bugs but didn't contribute code
__credits__ = ["n/a"]
# --------------------------------------------------
# To generate a new requirements.txt file run in console (install vis 'pip3 install pipreqs'):
# pipreqs --use-local --force /home/daniel/REPOS/suq-controller
......@@ -40,4 +31,4 @@ setup(
)
os.remove(SuqcConfig.path_package_indicator_file())
assert not os.path.exists(SuqcConfig.path_package_indicator_file())
\ No newline at end of file
assert not os.path.exists(SuqcConfig.path_package_indicator_file())
#!/usr/bin/env python3
# TODO: """ << INCLUDE DOCSTRING (one-line or multi-line) >> """
# include imports after here:
# --------------------------------------------------
# people who contributed code
__authors__ = "Daniel Lehmberg"
# people who made suggestions or reported bugs but didn't contribute code
__credits__ = ["n/a"]
# --------------------------------------------------
from suqc.parameter.sampling import *
from suqc.parameter.postchanges import ScenarioChanges
from suqc.parameter.postchanges import PostScenarioChangesBase
from suqc.qoi import *
from suqc.request import *
__version__ = "1.01"
__version__ = "2.0"
#!/usr/bin/env python3
# TODO: """ << INCLUDE DOCSTRING (one-line or multi-line) >> """
import os
import json
import os.path as p
import pathlib
# --------------------------------------------------
# people who contributed code
__authors__ = "Daniel Lehmberg"
# people who made suggestions or reported bugs but didn't contribute code
__credits__ = ["n/a"]
# --------------------------------------------------
# configuration of the suq-controller
DEFAULT_SUQ_CONFIG = {"default_vadere_src_path": "TODO", # TODO Feature: compile Vadere before using the jar file
"server": {
"host": "",
"user": "",
"port": -1
}}
DEFAULT_SUQC_CONFIG = {"default_vadere_src_path": "TODO", # TODO Feature: #25
"server": {
"host": "",
"user": "",
"port": -1}}
def check_setup(_paths_class):
if not os.path.exists(_paths_class.path_cfg_folder()) and _paths_class.is_package_paths():
print(f"INFO: Setting up configuration folder {_paths_class.path_cfg_folder()}")
os.mkdir(
_paths_class.path_cfg_folder()) # the next two checks will fail automatically too, because the folder is empty
if not os.path.exists(_paths_class.path_models_folder()):
print(f"INFO: Setting up default model lookup folder {_paths_class.path_models_folder()}")
os.mkdir(_paths_class.path_models_folder())
# the next two checks will fail automatically too, because the folder is empty
os.mkdir(_paths_class.path_cfg_folder())
if not os.path.exists(_paths_class.path_suq_config_file()):
print(f"INFO: Setting up default configuration file located at {_paths_class.path_suq_config_file()}")
_paths_class.store_config(DEFAULT_SUQ_CONFIG)
_paths_class.store_config(DEFAULT_SUQC_CONFIG)
if not os.path.exists(_paths_class.path_container_folder()):
print(f"INFO: Setting up the default container path (which will store output of simulation runs). "
......@@ -47,12 +33,12 @@ def check_setup(_paths_class):
return _paths_class
# class annotation -> everythime the clsas is used, it will be checked if the folders are correctly configured
# class annotation -> everythime the class is used, it will be checked if the folders are correctly configured
@check_setup
class SuqcConfig(object):
NAME_PACKAGE = "suqc"
NAME_SUQ_CONFIG_FILE = "suq_config.json"
NAME_SUQ_CONFIG_FILE = "suq_controller.conf"
NAME_MODELS_FOLDER = "models"
NAME_CON_FOLDER = "suqc_envs"
NAME_PACKAGE_FILE = "PACKAGE.txt"
......@@ -73,7 +59,7 @@ class SuqcConfig(object):
@classmethod
def _name_cfg_folder(cls):
if cls.is_package_paths():
return ".suqc"
return ".config"
else:
raise RuntimeError("This should not be called when IS_PACKAGE=False.")
......@@ -92,7 +78,11 @@ class SuqcConfig(object):
@classmethod
def path_cfg_folder(cls):
if cls.is_package_paths():
return p.join(cls.path_usrhome_folder(), cls._name_cfg_folder())
dir2conf = p.join(cls.path_usrhome_folder(), cls._name_cfg_folder())
if not p.exists(dir2conf):
# TODO instead of raising error the directory can also be created.
raise ValueError(f"Directory {dir2conf} does not exist.")
return dir2conf
else:
return cls.path_src_folder()
......
#!/usr/bin/env python3
# TODO: """ << INCLUDE DOCSTRING (one-line or multi-line) >> """
import json
import glob
import subprocess
......@@ -12,17 +10,11 @@ from shutil import rmtree
from typing import *
from suqc.configuration import SuqcConfig
from suqc.utils.general import user_query_yes_no, get_current_suqc_state, create_folder
from suqc.utils.general import user_query_yes_no, get_current_suqc_state, str_timestamp
# --------------------------------------------------
# people who contributed code
__authors__ = "Daniel Lehmberg"
# people who made suggestions or reported bugs but didn't contribute code
__credits__ = ["n/a"]
# --------------------------------------------------
# configuration of the suq-controller
DEFAULT_SUQ_CONFIG = {"default_vadere_src_path": "TODO", # TODO Feature: compile Vadere before using the jar file
DEFAULT_SUQ_CONFIG = {"default_vadere_src_path": "TODO",
"server": {
"host": "",
"user": "",
......@@ -30,40 +22,73 @@ DEFAULT_SUQ_CONFIG = {"default_vadere_src_path": "TODO", # TODO Feature: compi
}}
@DeprecationWarning
def get_suq_config():
assert os.path.exists(SuqcConfig.path_suq_config_file()), "Config file does not exist."
with open(SuqcConfig.path_suq_config_file(), "r") as f:
config_file = f.read()
return json.loads(config_file)
class VadereConsoleWrapper(object):
# Current log level choices, requires to manually add, if there are changes
ALLOWED_LOGLVL = ["OFF", "FATAL", "TOPOGRAPHY_ERROR", "TOPOGRAPHY_WARN", "INFO", "DEBUG", "ALL"]
def __init__(self, model_path: str, loglvl="ALL"):
def __init__(self, model_path: str, loglvl="INFO", jvm_flags: Optional[List] =
None, timeout_sec=None):
self.jar_path = os.path.abspath(model_path)
assert os.path.exists(self.jar_path)
self.loglvl = loglvl
if not os.path.exists(self.jar_path):
raise FileNotFoundError(
f"Vadere console .jar file {self.jar_path} does not exist.")
assert self.loglvl in self.ALLOWED_LOGLVL, f"set loglvl={self.loglvl} not contained in allowed: " \
f"{self.ALLOWED_LOGLVL}"
loglvl = loglvl.upper()
if loglvl not in self.ALLOWED_LOGLVL:
raise ValueError(f"set loglvl={loglvl} not contained "
f"in allowed: {self.ALLOWED_LOGLVL}")
if not os.path.exists(self.jar_path):
raise FileExistsError(f"Vadere console file {self.jar_path} does not exist.")
if jvm_flags is not None and not isinstance(jvm_flags, list):
raise TypeError(
f"jvm_flags are required to be a list. Got: {type(jvm_flags)}")
if timeout_sec is None:
pass # do nothing, no timeout
elif not isinstance(timeout_sec, int) or timeout_sec <= 0:
raise TypeError("vadere_run_timeout_sec must be of type int and positive "
"value")
self.loglvl = loglvl
# Additional Java Virtual Machine options / flags
self.jvm_flags = jvm_flags if jvm_flags is not None else []
self.timeout_sec = timeout_sec
def run_simulation(self, scenario_fp, output_path):
start = time.time()
ret_val = subprocess.call(["java", "-jar",
self.jar_path, "--loglevel",
self.loglvl, "suq", "-f", scenario_fp,
"-o", output_path])