Commit b2d5edf1 authored by Benedikt Kleinmeier's avatar Benedikt Kleinmeier
Browse files

Merge branch 'add_progress_for_potential_field_distances_brute_force'

parents eeba22e8 5e913979
Pipeline #217544 passed with stages
in 150 minutes and 4 seconds
......@@ -18,6 +18,8 @@ import org.vadere.util.logging.Logger;
import java.awt.*;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Benedikt Zoennchen
......@@ -78,11 +80,37 @@ public class PotentialFieldDistancesBruteForce implements IPotentialField {
if (!isInitialized){
long ms = System.currentTimeMillis();
this.cellGrid.pointStream().forEach(p -> computeDistanceToGridPoint(p));
List<Point> points = this.cellGrid.pointStream().collect(Collectors.toList());
int totalPoints = points.size();
int processedPoints = 0;
double checkpointInPercentage = 0.0;
for (Point point : points) {
checkpointInPercentage = printProgressIfCheckpointReached(processedPoints, totalPoints, checkpointInPercentage);
computeDistanceToGridPoint(point);
processedPoints++;
}
logger.info("floor field initialization time:" + (System.currentTimeMillis() - ms + "[ms]"));
}
}
private double printProgressIfCheckpointReached(int processedPoints, int totalPoints, double checkpointInPercentage) {
double newCheckpoint = checkpointInPercentage;
double progressInPercentage = ((double) processedPoints / totalPoints) * 100;
if (progressInPercentage >= checkpointInPercentage) {
logger.info(String.format("Progress: %2.0f%% -> %d/%d [points]", progressInPercentage, processedPoints, totalPoints));
double stepSize = 10.0;
newCheckpoint += stepSize;
}
return newCheckpoint;
}
private void computeDistanceToGridPoint(@NotNull final Point gridPoint) {
VPoint point = cellGrid.pointToCoord(gridPoint);
double distance = obstacles.stream().map(shape -> shape.distance(point)).min(Double::compareTo).orElse(Double.MAX_VALUE);
......
......@@ -48,7 +48,8 @@ public class VadereConfig {
private static final String DEFAULT_CONFIG_DIR = ".config";
// Both variables must not be "final" so that we are able
// to inject another config file from CLI argument "--config-file myconfig.conf".
// to inject another config file from CLI argument "--config-file myconfig.conf"
// via static method "setConfigPath()".
private static String CONFIG_FILENAME = "vadere.conf";
private static Path CONFIG_PATH = Path.of(DEFAULT_HOME_DIR, DEFAULT_CONFIG_DIR, CONFIG_FILENAME);
......@@ -208,7 +209,7 @@ public class VadereConfig {
CONFIG_FILENAME = CONFIG_PATH.getFileName().toString();
}
// Static setters
// Static getters
/**
* Use Apache Common Configuration API on the returned object to retrieve Vadere's config
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment