Bonjour,
Je travaille actuellement sur un algorithme que j'utiliserai dans une application Android. (alias A*)
Y a t-il possibilité d'optimiser le code obtenu ?
Merci de votre renseignement.
Flo.
Bonjour,
Je travaille actuellement sur un algorithme que j'utiliserai dans une application Android. (alias A*)
Y a t-il possibilité d'optimiser le code obtenu ?
Merci de votre renseignement.
Flo.
Qu'entends tu par "Optimiser le code obtenu"?
Si tu utilises un algorithme standard, il y a peu de chances que tu arrives a l'optimiser beaucoups.
Ensuite,ca depends des structures de donnée que tu utilises et de ta manière de coder.
Sans code, c'est assez délicat de te répondre...
Merci de ta réponse.
Je le posterai ce soir.
Tu peux jeter un coup d’œil au NDK pour du développement natif (C/C++) sur Android.
EDIT :
@guigz2000 : je suis complétement d'accord avec toi. Je propose le NDK car Flob91 cherche un moyenet comme tu le dis dans ton poste précédent, si Flob91 utilise un algo connu, normalement on doit pas pouvoir l'optimiser. Après sans le code on ne peut pas vraiment savoir.d'optimiser le code obtenu
PS : quelqu'un sait comment on peut faire une citation au sein d'une ligne ?
Perso, avant de me lancer dans une appli native, j'essaierai avec java.
Si le resultat est trop lent, alors effectivement passe en C++.
L'integration dans eclipse (ADT) est bien faite et ca te permettra de debugger plus facilement. Tu pourras utiliser ddms pour faire un profiling de ton code et voir les goulots d'étranglement. En plus, quand tron algorithme sera bien au point,ca sera très simple de passer au C++.
Merci pour vos réponses.
Juste une question peut on faire (par exemple) un morceau de l'application en C++ et le reste en Java ?
Sinon voila mon algorithme, il s'agit de la création d'un labyrinthe (X par Y cases).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 Random random = new Random(); int d; int frompropagate = 0, topropagate = 0; isFinished = false; isSolved = false; initialisation(); do { int x = 0; int y = 0; do { x = random.nextInt( (2*X)-1 )+1; y = random.nextInt( (2*Y)-1 )+1; } while( !(( x%2==1)^(y%2==1)) || Labyrinthe[x][y]!=-1); if( x%2 == 1) { d = Labyrinthe[x][y-1] - Labyrinthe[x][y+1]; if(d > 0) { Labyrinthe[x][y] = Labyrinthe[x][y+1]; frompropagate = Labyrinthe[x][y+1]; topropagate = Labyrinthe[x][y-1]; }else if(d<0) { Labyrinthe[x][y] = Labyrinthe[x][y-1]; frompropagate = Labyrinthe[x][y-1]; topropagate = Labyrinthe[x][y+1]; } } else { d = Labyrinthe[x-1][y] - Labyrinthe[x+1][y]; if( d>0 ) { Labyrinthe[x][y] = Labyrinthe[x+1][y]; frompropagate = Labyrinthe[x+1][y]; topropagate = Labyrinthe[x-1][y]; }else if( d<0 ) { Labyrinthe[x][y] = Labyrinthe[x-1][y]; frompropagate = Labyrinthe[x-1][y]; topropagate = Labyrinthe[x+1][y]; } } for(int i = 0; i < (2*X)+1 ; i++) { for(int j = 0; j < (2*Y)+1; j++) { if(Labyrinthe[i][j] == topropagate) { Labyrinthe[i][j] = frompropagate; } } } } while ( !isComplete()); isFinished = true; return true; } private boolean isComplete() { for(int i = 0; i < (2*X)+1; i++) { for(int j = 0; j < (2*Y)+1; j++) { if(Labyrinthe[i][j] != 0 && Labyrinthe[i][j] != -1) { return false; } } } return true; }
Partager