Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f1f3cf6
Eigenes Projekt in DNA-Strukturen eingebunden
e-pool Oct 25, 2014
decc3d2
Grad 7 entfernt, Components-Titel geändert, Modus 3 (Vergleich der
barracuda317 Nov 7, 2014
4a4b07e
Bugfixes
e-pool Nov 10, 2014
62ffd73
Gewichte geändert
e-pool Nov 10, 2014
fa964d3
Gewichte geändert
e-pool Nov 13, 2014
f032c02
Minor Bugfixes
barracuda317 Nov 27, 2014
9c909b8
Minor Bugfixes
barracuda317 Nov 27, 2014
41cf3d9
Numerische Modi-Definition auf Enum umgestellt
barracuda317 Jan 5, 2015
ac7e9b8
Merge branch 'trafficmodel' of https://github.com/barracuda317/DNA.git
barracuda317 Jan 5, 2015
35f3040
Kommentare CrossroadWeight
barracuda317 Jan 5, 2015
fdb53a5
Kommentare Crossroad-Klasse
barracuda317 Jan 6, 2015
1ff55a0
Auswahl der Maximalwerte - dummyMax,ImprovedMax
barracuda317 Jan 6, 2015
ecc26a8
Kommentare für DB
barracuda317 Jan 6, 2015
4940fa6
Kommentare DB
barracuda317 Jan 7, 2015
7b6654d
Kommentare DB bis LN 1220
barracuda317 Jan 7, 2015
3772bfe
Aufsplitten InputWayWeight
barracuda317 Jan 7, 2015
205ba4f
Kommentare DB - fertig
barracuda317 Jan 7, 2015
c924568
Kommentare TrafficUpdate
barracuda317 Jan 21, 2015
90c6faa
Kommentare Crossroad, EdgeContainer, Inputway, InputWayConnection,
barracuda317 Jan 21, 2015
43e3dd0
Filterfunktionalität
barracuda317 Jan 23, 2015
49f6637
Datenkapselung, Kommentare
barracuda317 Feb 1, 2015
f1f9fee
Rearrangement, Kommentare
barracuda317 Feb 1, 2015
232646e
Umstellung auf TrafficConfig in Crossgroad und InputWay
barracuda317 Feb 11, 2015
29375f4
Kommentare, ungenutzte Importe und Variablen gelöscht
barracuda317 Feb 11, 2015
dbeffa1
Tabellenname geändert
barracuda317 Feb 19, 2015
ab7177e
Merge branch 'trafficmodel_backup' into master_rebase
barracuda317 Feb 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/mockito-all-1.9.5.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/perfidix-3.6.10-SNAPSHOT-jar-with-dependencies.jar"/>
<classpathentry kind="lib" path="lib/guava-16.0.1.jar"/>
<classpathentry kind="lib" path="lib/jchart2d_modified.jar"/>
<classpathentry kind="lib" path="lib/jide-oss-2.9.7.jar"/>
<classpathentry kind="lib" path="lib/xmlgraphics-commons-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/jpathwatch-0-95.jar"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/mockito-all-1.9.5.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/perfidix-3.6.10-SNAPSHOT-jar-with-dependencies.jar"/>
<classpathentry kind="lib" path="lib/guava-16.0.1.jar"/>
<classpathentry kind="lib" path="lib/jchart2d_modified.jar"/>
<classpathentry kind="lib" path="lib/jide-oss-2.9.7.jar"/>
<classpathentry kind="lib" path="lib/xmlgraphics-commons-1.3.1.jar"/>
<classpathentry kind="lib" path="lib/jpathwatch-0-95.jar"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
<classpathentry kind="lib" path="C:/Users/Maurice/Drive/UNI/BachelorArbeit/Tools/com.mysql.jdbc_5.1.5.jar/com.mysql.jdbc_5.1.5.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
4 changes: 2 additions & 2 deletions config/plotting/gnuplot.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## GENERAL PLOT SETTINGS ###############
GNUPLOT_PATH = /usr/bin/gnuplot
GNUPLOT_PATH = C:\\Users\\Maurice\\gnuplot\\bin\\gnuplot.exe
GNUPLOT_TERMINAL = png large
GNUPLOT_EXTENSION = png
GNUPLOT_DIR = null
Expand Down Expand Up @@ -39,4 +39,4 @@ GNUPLOT_DEFAULT_PLOTSTYLE = linespoint
GNUPLOT_DEFAULT_NVL_ORDER = ascending
GNUPLOT_DEFAULT_NVL_ORDERBY = average

GNUPLOT_DEFAULT_DIST_PLOTTYPE = distANDcdf
GNUPLOT_DEFAULT_DIST_PLOTTYPE = distANDcdf
5 changes: 5 additions & 0 deletions src/dna/graph/generators/traffic/CardinalDirection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package dna.graph.generators.traffic;

public enum CardinalDirection {
NORTH, EAST,SOUTH,WEST
}
132 changes: 132 additions & 0 deletions src/dna/graph/generators/traffic/Crossroad.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package dna.graph.generators.traffic;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;


public class Crossroad {
private HashMap<CardinalDirection, Integer> inputWays;
private HashMap<CardinalDirection, Integer> outputWays;
private HashMap<CardinalDirection,Set<CardinalDirection>> inputToOutput;
private HashMap<CardinalDirection, InputWay> outputToInput;
private int crossroadID;
private DB db;

public Crossroad(int crossroadID, DB db){
this.inputToOutput=new HashMap<>();
this.crossroadID=crossroadID;
this.db=db;
this.outputToInput = new HashMap<>();
}
/**
* speichert die übergebene HashMap von Einfahrtswegen
* @param newInputWays
* @return Setzen = true, Ersetzen = False
*/
public boolean setInputWays(HashMap<CardinalDirection, Integer> newInputWays) {
boolean wasNull = inputWays==null;
inputWays=newInputWays;
return wasNull;
}
/**
* speichert die übergebene HashMap von Ausfahrtswegen
* @param newOutputWays
* @return Setzen = true, Ersetzen = False
*/
public boolean setOutputWays(HashMap<CardinalDirection, Integer> newOutputWays) {
boolean wasNull = outputWays==null;
outputWays=newOutputWays;
return wasNull;
}
/**
* Verbindet einen Einfahrtsweg mit einem Ausfahrtsweg
* @param inDir CardinalDirection des Einfahrtsweges
* @param outDir CardinalDirection des Ausfahrtsweges
* @return Wert neu gesetzt = true, Wert bereits vorhanden = false
*/
public boolean setOutputWay(CardinalDirection inDir, CardinalDirection outDir){
if(!inputToOutput.containsKey(inDir)){
inputToOutput.put(inDir, new HashSet<CardinalDirection>());
}
return inputToOutput.get(inDir).add(outDir);
}
/**
* liefert den Identifier eines Weges
* @param direction, Himmelsrichtung des Weges
* @param isInputWay, Einfahrtsweg = true, Ausfahrtsweg = false
* @return
*/
public Integer getWay(CardinalDirection direction, boolean isInputWay) {
if(isInputWay)
return (inputWays.containsKey(direction)) ? inputWays.get(direction) : -1;
else
return (outputWays.containsKey(direction)) ? outputWays.get(direction) : -1;
}

/**
* verbindet die Ausfahrtswege mit den Einfahrtswegen benachbarter Kreuzungen
*/
public void connectWays () {
for (CardinalDirection outDir : outputWays.keySet()) {
List<InputWay> connectedWays = db.getConnectedInputWays(getWay(outDir,false), crossroadID);
for (InputWay integers : connectedWays) {
if(integers!=null) {
outputToInput.put(outDir, integers);
}
}
}
}
/**
* liefert eine Menge von Verbindungen von Einfahrtswegen zu benachbarten Einfahrtswegen
* @return
*/
public Set<InputWayConnection> getConnections(){
Set<CardinalDirection> connectedOutputways;
Set<InputWayConnection> connectedCrossroads = new HashSet<>();
InputWay connection;
for (Map.Entry<CardinalDirection, Set<CardinalDirection>> innerConnection : inputToOutput.entrySet()) {
connectedOutputways = innerConnection.getValue();
for (CardinalDirection outputDirection : connectedOutputways) {
if(outputToInput.containsKey(outputDirection)) {
connection = outputToInput.get(outputDirection);
connectedCrossroads.add(new InputWayConnection(this.crossroadID, inputWays.get(innerConnection.getKey()),innerConnection.getKey(), connection.getWayID() , connection.getCrossroadID() ,outputDirection));
}
}
}
return connectedCrossroads;
}

/**
* Kontrollausgabe für die Einfahrtswege
*/
public void printInputWays(){
System.out.println("InputWays von:\t"+this.crossroadID);
for (Map.Entry<CardinalDirection, Integer> inputWay : inputWays.entrySet()) {
System.out.println(inputWay.getKey() +"\t"+inputWay.getValue());
}
}
/**
* Kontrollausgabe für die innere Verbindung von Wegen
*/
public void printInput2Output(){
System.out.println("Input2Output von:\t"+this.crossroadID);
for (Map.Entry<CardinalDirection, Set<CardinalDirection>> inputWay : inputToOutput.entrySet()) {
System.out.println(inputWay.getKey());
for (CardinalDirection outputWay : inputWay.getValue()) {
System.out.println("\t"+outputWay);
}
}
}
/**
* Kontrollausgabe für die Ausfahrtswege
*/
public void printOutputWays(){
System.out.println("OutputWays von:\t"+this.crossroadID);
for (Map.Entry<CardinalDirection, Integer> outputWay : outputWays.entrySet()) {
System.out.println(outputWay.getKey() +"\t"+outputWay.getValue());
}
}
}
197 changes: 197 additions & 0 deletions src/dna/graph/generators/traffic/CrossroadWeight.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package dna.graph.generators.traffic;

import java.util.HashMap;
import java.util.Map;

public class CrossroadWeight {
public int crossroadID;
private String crossroadName;
public HashMap<Integer,double[]> inputWayWeights;
private HashMap<Integer,double[]> inputWayMaxWeights;
private double maxCount;
private double maxLoad;
private double threshold;
private long timestamp;

public CrossroadWeight(int crossroadID,String crossroadName, double treshold){
this.crossroadID = crossroadID;
this.crossroadName = crossroadName;
this.inputWayWeights = new HashMap<>();
this.inputWayMaxWeights = new HashMap<>();
this.threshold = treshold;
this.timestamp=0;
}
/**
* liefert den Schwellwert für die Überlastung
* @return
*/
public double getThreshold(){
return threshold;
}
/**
* liefert den Namen der Kreuzung im Format "A ..."
* @return
*/
public String getCrossroadName(){
return crossroadName;
}
/**
* fügt Gewichte zu einem Einfahrtsweg hinzu
* @param osmWayID, OSM-ID des Einfahrtsweges
* @param weights, Gewichte des Einfahrtsweges
*/
public void addWeightWay(int osmWayID, double[] weights) {
inputWayWeights.put(osmWayID, weights);
}
/**
* fügt die maximalen Gewichte des Einfahrtsweges hinzu
* @param osmWayID - OSM-ID des Einfahrtsweges
* @param maxWeights
*/
public void setMaxWeightWay(int osmWayID, double[] maxWeights) {
inputWayMaxWeights.put(osmWayID, maxWeights);
}

/**
* liefert die maximalen Gewichte des Einfahrtsweges
* @param osmWayID, OSM-ID des Einfahrtsweges
* @return
*/
public double[] getMaxWeightWay(int osmWayID) {
return inputWayMaxWeights.get(osmWayID);
}

/**
* setzt den Zeitstempel, für den das letzte Gewicht vorliegt
* @param timestampInit
*/
public void setTimestamp(long timestampInit){
this.timestamp = timestampInit;
}

/**
* liefert den Zeitstempel, für den das letzte Gewicht vorliegt
* @return
*/
public long getTimestamp(){
return timestamp;
}

/**
* setzt die maximalen Gewichte für die gesamte Kreuzung
* @param maxWeights
*/
public void setMaxWeight(double[] maxWeights) {
this.maxCount=maxWeights[0];
this.maxLoad=maxWeights[1];
}

/**
* liefert die maximalen Werte für die gesamte Kreuzung
* @return
*/
public double[] getMaxWeight() {
return new double[] {maxCount,maxLoad};
}

/**
* verteilt das Knotengewicht gleichmäßig auf die Einfahrtswege, wird bei der Simulation verwendet
* @param count
* @param load
*/
public void resetInputWayWeight(double count, double load){
double numOfInputWays = inputWayWeights.keySet().size();
double count_value = count/numOfInputWays;
double load_value = load/numOfInputWays;
for (Map.Entry<Integer, double[]> entry : inputWayWeights.entrySet()) {
entry.setValue(new double[]{count_value,load_value,(count_value/inputWayMaxWeights.get(entry.getKey())[0])*100});
}
}

/**
* berechnet das Gewicht des Kreuzungsknotens
* Index 0 - count
* Index 1 - load
* Index 2 - count/maxcount
* @return 3D-double
*/
public double[] getWeight(){
double[] sum = new double[3];
for (double[] entry : inputWayWeights.values()) {
sum[0]+=entry[0];
sum[1]+=entry[1];
}
int numOfinputWays = inputWayWeights.size();
if(numOfinputWays>0){
sum[1]/=numOfinputWays;
}

// Normierte Werte
if(maxCount>0)
sum[2]=(sum[0]/maxCount)*100;
else
sum[2]=0;

return sum;
}

/**
* liefert alle Einfahrtswege, deren Gewicht den Schwellwert überschritten hat
* @return
*/
public HashMap<Integer,double[]> getOverladedEdges() {
HashMap<Integer, double[]> result = new HashMap<>();
for (Map.Entry<Integer, double[]> inputWay : inputWayWeights.entrySet()) {
if(inputWay.getValue()[2] >threshold){
result.put(inputWay.getKey(), inputWay.getValue());
}
}
return result;
}

/**
* liefert alle Einfahrtswege mit ihren Gewichten
* @return
*/
public HashMap<Integer, double[]> getWayWeights(){
return inputWayWeights;
}

/**
* addiert die übergebenen Gewichte auf die Gewichte der Einfahrtswege
* @param wayWeights
* @return
*/
public boolean addWeights(HashMap<Integer,double[]> wayWeights){
for (Integer keys : wayWeights.keySet()) {
if(!inputWayWeights.containsKey(keys))
return false;
}
for (Map.Entry<Integer, double[]> entry : wayWeights.entrySet()) {
double[] value = inputWayWeights.get(entry.getKey());
double[] newValue = entry.getValue();
for (int i = 0; i < value.length; i++) {
value[i]+=newValue[i];
}
inputWayWeights.put(entry.getKey(), value);
}
return true;
}

/**
* bildet den Durchschnitt der aufsummierten Gewichte
* @param divisor, Anzahl der Batches/Tage über die aggregiert wurde
*/
public void divWays(int divisor){
if(divisor>0){
for (Map.Entry<Integer, double[]> entry : inputWayWeights.entrySet()) {
double[] value = entry.getValue();
for (int i = 0; i < value.length; i++) {
value[i] = value[i]/divisor;
}
inputWayWeights.put(entry.getKey(), value);
}
}
}

}
Loading