Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

A Nearest Neighbor Query in Time-Dependent Road Networks - MDM #20

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
e006ad0
Adicionando artifato rcaller, para manipular as funções do R.
mirlabraga Nov 26, 2015
4d3822c
Criando estutura de classes para manipular dos entradas para a geraçã…
mirlabraga Nov 26, 2015
928b0c2
Manipulação como Banco de Dados. Consulta, aquivo de configuração e c…
mirlabraga Nov 26, 2015
beb8b0c
Gerado da função para cada aresta do grafo.
mirlabraga Nov 26, 2015
d1d7038
Classe com testes unitários para testes da biblioteca RCaller.
mirlabraga Nov 26, 2015
c3e3539
Criada primeira função após o uso do loess
mirlabraga Nov 26, 2015
3cea3f2
Removido teste unitário para outra classe.
mirlabraga Nov 26, 2015
43fd192
Finalizada função para o cálculo do tempo gasto para percorrer cada a…
mirlabraga Nov 26, 2015
a5272fd
Adicionado binário do R.
mirlabraga Nov 27, 2015
1f66faf
Add configure of the DB, with file properties, DAO and class java
mirlabraga Nov 30, 2015
da10bc5
Create importer of the OSM Fortaleza/Ce-Brazil and ploted taxi into g…
mirlabraga Nov 30, 2015
5d83a61
add postgis dependency and add configuration main class for service run.
mirlabraga Nov 30, 2015
2906f3e
Removed classes referente of the solution piecewise.
mirlabraga Nov 30, 2015
7c08382
Create classes with naive (Dijkstra) and
mirlabraga Nov 30, 2015
6f2840f
chance member level of the method
mirlabraga Nov 30, 2015
468a363
add util method double generatePdseurandom(int rangeMin, int rangeMax).
mirlabraga Nov 30, 2015
760435f
add util method boolean isPointInEdgeLine(GraphBounds graph, Node po…
mirlabraga Nov 30, 2015
4cf936a
set default value of category.
mirlabraga Nov 30, 2015
02d7d36
Added data collection in nanoseconds
mirlabraga Dec 4, 2015
6b464e8
Add test for verify cost edge
mirlabraga Dec 4, 2015
8f54628
NearestNeighbor nearestNeighbor = null;
mirlabraga Dec 4, 2015
d701d35
define node with taxi and fixed erro cost edge
mirlabraga Dec 4, 2015
a458dd4
alterado biblioteca que coloca log.
mirlabraga Dec 8, 2015
24ec194
add NumberVisitedNodes
mirlabraga Dec 8, 2015
9d44e92
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
a134c34
add cost in the graph
mirlabraga Dec 8, 2015
4ac9faf
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
d881d65
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
a554c7f
create compare method synthetic analysis.
mirlabraga Dec 8, 2015
8f4a07d
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
19989af
Milissegundo to Nanosegundos
mirlabraga Dec 8, 2015
3fb8eeb
add travel time.
mirlabraga Dec 8, 2015
3241e53
add travel time.
mirlabraga Dec 8, 2015
00fd97c
logger
mirlabraga Dec 15, 2015
8e3d433
Generalizado forma de passar o tamanho da rede. Por parametro.
mirlabraga Jan 15, 2016
e3e64fd
Alterado forma de capturar quantidade de nós visitados.
mirlabraga Jan 15, 2016
4cdb87e
refactorado nome de variavel
mirlabraga Jan 15, 2016
dfca468
adicionando parametro para captura consumo de memoria total.
mirlabraga Jan 15, 2016
68a79d8
Adicionada classe de Benchmark.
mirlabraga Jan 17, 2016
fca678f
Benchmark Memory.
mirlabraga Feb 4, 2016
bed2d54
Retirado comentários.
May 28, 2016
34ed185
Adicionando artifato rcaller, para manipular as funções do R.
mirlabraga Nov 26, 2015
3979ce1
Criando estutura de classes para manipular dos entradas para a geraçã…
mirlabraga Nov 26, 2015
cdc71ad
Manipulação como Banco de Dados. Consulta, aquivo de configuração e c…
mirlabraga Nov 26, 2015
3a630c3
Gerado da função para cada aresta do grafo.
mirlabraga Nov 26, 2015
bce4f3d
Classe com testes unitários para testes da biblioteca RCaller.
mirlabraga Nov 26, 2015
26695f9
Criada primeira função após o uso do loess
mirlabraga Nov 26, 2015
ca60561
Removido teste unitário para outra classe.
mirlabraga Nov 26, 2015
fb5d3f7
Finalizada função para o cálculo do tempo gasto para percorrer cada a…
mirlabraga Nov 26, 2015
c131407
Adicionado binário do R.
mirlabraga Nov 27, 2015
7b3b4f2
Add configure of the DB, with file properties, DAO and class java
mirlabraga Nov 30, 2015
ed12bed
Create importer of the OSM Fortaleza/Ce-Brazil and ploted taxi into g…
mirlabraga Nov 30, 2015
4754268
add postgis dependency and add configuration main class for service run.
mirlabraga Nov 30, 2015
c7b2edb
Removed classes referente of the solution piecewise.
mirlabraga Nov 30, 2015
a48704c
Create classes with naive (Dijkstra) and
mirlabraga Nov 30, 2015
137615b
chance member level of the method
mirlabraga Nov 30, 2015
7c2201b
add util method double generatePdseurandom(int rangeMin, int rangeMax).
mirlabraga Nov 30, 2015
a422468
add util method boolean isPointInEdgeLine(GraphBounds graph, Node po…
mirlabraga Nov 30, 2015
72549b3
set default value of category.
mirlabraga Nov 30, 2015
ecb98da
Added data collection in nanoseconds
mirlabraga Dec 4, 2015
d3effc0
Add test for verify cost edge
mirlabraga Dec 4, 2015
bdbf4ee
NearestNeighbor nearestNeighbor = null;
mirlabraga Dec 4, 2015
d59a922
define node with taxi and fixed erro cost edge
mirlabraga Dec 4, 2015
5ecda12
alterado biblioteca que coloca log.
mirlabraga Dec 8, 2015
d736dca
add NumberVisitedNodes
mirlabraga Dec 8, 2015
0d37048
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
e0318a0
add cost in the graph
mirlabraga Dec 8, 2015
8694d97
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
569b9f3
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
e259917
create compare method synthetic analysis.
mirlabraga Dec 8, 2015
30caf61
add parameter of the number visited nodes
mirlabraga Dec 8, 2015
d226e52
Milissegundo to Nanosegundos
mirlabraga Dec 8, 2015
f037ac9
add travel time.
mirlabraga Dec 8, 2015
a3e723a
add travel time.
mirlabraga Dec 8, 2015
09bf2fa
logger
mirlabraga Dec 15, 2015
31da478
Generalizado forma de passar o tamanho da rede. Por parametro.
mirlabraga Jan 15, 2016
f64919b
Alterado forma de capturar quantidade de nós visitados.
mirlabraga Jan 15, 2016
240ff52
refactorado nome de variavel
mirlabraga Jan 15, 2016
26da704
adicionando parametro para captura consumo de memoria total.
mirlabraga Jan 15, 2016
294e609
Adicionada classe de Benchmark.
mirlabraga Jan 17, 2016
c4c5538
Benchmark Memory.
mirlabraga Feb 4, 2016
fbe8d5d
Retirado comentários.
May 28, 2016
e1a1ebb
Alterado GraphBoundsImpl para GraphImpl
mirlabraga May 31, 2016
72fc90b
Merge branch 'master' of https://github.com/mirlabraga/graphast into …
mirlabraga May 31, 2016
f148dd2
Ocultando informações do bando de dados.
mirlabraga Jun 2, 2016
ddfc960
Removido arquivo de propriedades.
mirlabraga Jun 4, 2016
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ null
*.aux
*.synctex*
bin
core/.RData
42 changes: 40 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<id>maven-repo</id>
<url>http://arida.github.io/maven-repo/</url>
</repository>

</repositories>

<licenses>
Expand Down Expand Up @@ -77,9 +78,26 @@
<artifactId>rtree</artifactId>
<version>0.7.1</version>
</dependency>
</dependencies>


<dependency>
<groupId>postgresql</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evitar as dependências de banco no core.
talvez possamos pensar no projeto graphast-postgres para integração com o postgres e postgis.
uma interface genérica DAO poderia ficar no core.

<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>

<dependency>
<groupId>org.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>1.3.3</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>

</dependencies>

<build>
<plugins>
Expand Down Expand Up @@ -141,6 +159,26 @@
</executions>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.graphast.query.rnn.CompareRNNSearchsMethodsAnalysis</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
53 changes: 32 additions & 21 deletions core/src/main/java/org/graphast/importer/CostGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,101 @@

import org.graphast.model.Graph;


public class CostGenerator {

public static int[] generateSyntheticEdgesCosts(int distance) {

Random random = new Random();

int minSpeed, maxSpeed;
int minSpeed, maxSpeed; //Millimeters Per Millisecond (mm/ms)
int[] syntheticCosts = new int[96];

//1:00h to 6:00h
for(int i=0; i<24; i++) {
minSpeed = 14;
maxSpeed = 17;
minSpeed = 14; // 50km/h
maxSpeed = 17; // 60km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//6:00h to 7:00h
for(int i=24; i<28; i++) {
minSpeed = 6;
maxSpeed = 9;
minSpeed = 6; //21km/h
maxSpeed = 9; //32km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//7:00h to 9:00h
for(int i=28; i<36; i++) {
minSpeed = 1;
maxSpeed = 4;
minSpeed = 1; //3km/h
maxSpeed = 4; //14km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//9:00h to 11:00h
for(int i=36; i<44; i++) {
minSpeed = 6;
maxSpeed = 9;
minSpeed = 6; //21km/h
maxSpeed = 9; //32km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//11:00h to 14:00h
for(int i=44; i<56; i++) {
minSpeed = 1;
maxSpeed = 4;
minSpeed = 1; //3km/h
maxSpeed = 4; //14km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//14:00h to 16:00h
for(int i=56; i<64; i++) {
minSpeed = 14;
maxSpeed = 17;
minSpeed = 14; //50km/h
maxSpeed = 17; //60km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//16:00h to 17:00h
for(int i=64; i<68; i++) {
minSpeed = 6;
maxSpeed = 9;
minSpeed = 6; //21km/h
maxSpeed = 9; //30/km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//17:00h to 20:00h
for(int i=68; i<80; i++) {
minSpeed = 1;
maxSpeed = 4;
minSpeed = 1; //3km/h
maxSpeed = 4; //14km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//20:00h to 22:00h
for(int i=80; i<88; i++) {
minSpeed = 6;
maxSpeed = 9;
minSpeed = 6; //21km/h
maxSpeed = 9; //30/km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

}

//22:00h to 00:00h
for(int i=88; i<96; i++) {
minSpeed = 14;
maxSpeed = 17;
minSpeed = 14; //50km/h
maxSpeed = 17; //60km/h

syntheticCosts[i] = distance/(random.nextInt(maxSpeed-minSpeed)+minSpeed);

Expand Down
135 changes: 135 additions & 0 deletions core/src/main/java/org/graphast/importer/GraphGeneratorGrid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package org.graphast.importer;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import org.graphast.model.Edge;
import org.graphast.model.EdgeImpl;
import org.graphast.model.GraphBounds;
import org.graphast.model.GraphImpl;
import org.graphast.model.Node;
import org.graphast.model.NodeImpl;

public class GraphGeneratorGrid {

private int width;
private int length;
private GraphBounds graph;
private double percentagemPoi;
private BigDecimal distance_largura;
private BigDecimal distance_altura;

public GraphGeneratorGrid(String pathGraph, int width, int length, double percentualPoi) {
this.width = width;
this.length = length;
this.percentagemPoi = percentualPoi;
this.graph = new GraphImpl(pathGraph);
}

public GraphGeneratorGrid(String pathGraph, int size, double percentualPoi) {
this(pathGraph, size, size, percentualPoi);
}

public void generateGraph() {
plotNodes();
plotEdges();
graph.createBounds();
}

private void plotNodes() {

BigDecimal interador_largura = BigDecimal.valueOf(180).divide(BigDecimal.valueOf(width), 8, RoundingMode.HALF_UP);
BigDecimal interador_altura = BigDecimal.valueOf(180).divide(BigDecimal.valueOf(length), 8, RoundingMode.HALF_UP);
this.distance_largura = interador_largura;
this.distance_altura = interador_altura;

Set<Integer> listaIdsPoi = getListIdsPois();

Integer category = 0;
for (int i = 0; i < width; i++) {
BigDecimal latitude = interador_altura.multiply(BigDecimal.valueOf(i)).add(BigDecimal.valueOf(-90));
for (int j = 0; j < length; j++) {
BigDecimal longitude = interador_largura.multiply(BigDecimal.valueOf(j)).add(BigDecimal.valueOf(-90));;
Node node = new NodeImpl(Long.valueOf(category), latitude.doubleValue(), longitude.doubleValue());
if(listaIdsPoi.contains(category)) {
int[] costs = new int[]{0};
node.setCategory(category);
node.setExternalId(category);
node.setLabel("CATEGORY "+category);
node.setCosts(costs);
listaIdsPoi.remove(category);
}
graph.addNode(node);
category++;
}
}
}

private Set<Integer> getListIdsPois() {

int quantidadeVerticesPoi = BigDecimal.valueOf(width).multiply(BigDecimal.valueOf(length)).multiply(BigDecimal.valueOf(percentagemPoi)).divide(BigDecimal.valueOf(100.0f), 8, RoundingMode.UP).intValue();

Set<Integer> listIdPoi = new HashSet<>();
do {
int rangeMax = width*length - 1;
Double idRandom = generatePdseurandom(0, rangeMax);
listIdPoi.add(idRandom.intValue());
} while(listIdPoi.size()<quantidadeVerticesPoi);

return listIdPoi;
}


private void plotEdges() {
for (int i = 0; i < width*length - 1; i++) {

//altura
if(i < (width * length - width)) {

Edge edgeOutTopDown = new EdgeImpl(Long.valueOf(i).longValue(), Long.valueOf(i+length).longValue(), distance_altura.intValue());
addCost(edgeOutTopDown);
graph.addEdge(edgeOutTopDown);

Edge edgeInTopDown = new EdgeImpl(Long.valueOf(i+length).longValue(), Long.valueOf(i).longValue(), distance_altura.intValue());
addCost(edgeInTopDown);
graph.addEdge(edgeInTopDown);
}

//largura
if(i%width != width - 1) {

Edge edgeOutLeftRight = new EdgeImpl(Long.valueOf(i).longValue(), Long.valueOf(i+1).longValue(), distance_largura.intValue());
addCost(edgeOutLeftRight);
graph.addEdge(edgeOutLeftRight);

Edge edgeInLeftRight = new EdgeImpl(Long.valueOf(i+1).longValue(), Long.valueOf(i).longValue(), distance_largura.intValue());
addCost(edgeInLeftRight);
graph.addEdge(edgeInLeftRight);

}

}
}

private double generatePdseurandom(int rangeMin, int rangeMax) {
return rangeMin + (rangeMax - rangeMin) * new Random().nextDouble();
}

private void addCost(Edge edge) {

int distanceInMeters = edge.getDistance() * 100;
int[] edgesCosts = CostGenerator.generateSyntheticEdgesCosts(distanceInMeters);
edge.setCosts(edgesCosts);
}

public boolean isConnected() {
return Boolean.TRUE;
}

public GraphBounds getGraph() {
return graph;
}
}
Loading