test devient guinumo
Le fichier "test.cc" a été renommé en "guinumo.cc" ; l'exécutable "test" produit par la compilation devient "guinumo". server.{hh,cc} : * Séparation de la fonction fastViterbiLike(), déplacement d'une partie du code dans la nouvelle fonction monitorClient(), comme expliqué à la révision 41. * Implémentation de createClient(). git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@42 785a6c6c-259e-4ff1-8b91-dc31627914f0
This commit is contained in:
parent
1b222af80c
commit
67525c445e
|
@ -3,9 +3,9 @@ GXXFLAGS=-g -Wall -pedantic -O2
|
|||
LD=g++
|
||||
LDFLAGS=-g -Wall -pedantic -lm -O2
|
||||
|
||||
HEADER=
|
||||
HEADER=guinumo.hh
|
||||
|
||||
all: test
|
||||
all : guinumo
|
||||
|
||||
% : %.o
|
||||
$(LD) $(LDFLAGS) -o $@ $^
|
||||
|
@ -19,12 +19,12 @@ accesspoint.o : accesspoint.hh point.hh
|
|||
point.o : point.hh
|
||||
measurement.o : measurement.hh
|
||||
area.o : area.hh point.hh
|
||||
test.o : point.hh measurement.hh accesspoint.hh referencepoint.hh clientinfo.hh server.hh
|
||||
guinumo.o : point.hh measurement.hh accesspoint.hh referencepoint.hh clientinfo.hh server.hh
|
||||
|
||||
test : point.o measurement.o accesspoint.o referencepoint.o clientinfo.o server.o area.o
|
||||
guinumo : point.o measurement.o accesspoint.o referencepoint.o clientinfo.o server.o area.o
|
||||
|
||||
clean:
|
||||
@rm -fv *~ *.o
|
||||
|
||||
purge : clean
|
||||
@rm -fv test
|
||||
@rm -fv guinumo
|
||||
|
|
|
@ -18,12 +18,8 @@ int main(int argc, char ** argv)
|
|||
string read_file;
|
||||
Server server ;
|
||||
|
||||
server.fastViterbiLike(VITERBI_N, VITERBI_K, 0) ;
|
||||
/*
|
||||
server.createClient() ;
|
||||
server.printLastClientV();
|
||||
server.monitorClient(0) ;
|
||||
*/
|
||||
|
||||
cout << argv[0] << " : fin." << endl ;
|
||||
fflush(stdout) ;
|
|
@ -2,7 +2,7 @@
|
|||
#define _GUINUMO_HH_
|
||||
|
||||
|
||||
#define TEST
|
||||
#define TEST // Décommenter si on teste le serveur avec des fichiers de mesures (commenter pour utiliser des mesures instantanées transmises par le réseau (NON-IMPLÉMENTÉ).
|
||||
#define DEBUG // Décommenter pour avoir de l'affichage en plus.
|
||||
//#define DEBUG_2 // Décommenter pour avoir encore plus d'affichage.
|
||||
#define DEBUG_T // Décommenter pour afficher chaque entrée et sortie de méthode (trace).
|
||||
|
|
|
@ -1114,44 +1114,38 @@ void Server::computeFriisFromRefList()
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Computes new cumulative distances for each running viterbi instance,
|
||||
* Returns the solution (type: Point) of the last ended viterbi.
|
||||
* Distances are grouped by line corresponding to an instance.
|
||||
* "K" MUST be the same as last.size() and current.size() !
|
||||
*/
|
||||
void Server::fastViterbiLike(const unsigned short &N, const unsigned short &K, const unsigned int &id_client)
|
||||
/* Ajoute un client (ClientInfo) à la liste "client_list", et renvoie une référence sur l'élément ajouté. */
|
||||
ClientInfo& Server::createClient()
|
||||
{
|
||||
client_list.push_back(ClientInfo()) ;
|
||||
return client_list.back() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Localise le client d'identifiant "client_id" en appliquant l'algorithme voulu. */
|
||||
void Server::monitorClient(const unsigned int &client_id)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> Server::fastViterbiLike()" << endl ; fflush(stdout) ;
|
||||
cout << "//--> Server::monitorClient()" << endl ; fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
#ifdef TEST
|
||||
client_list.push_back(ClientInfo()) ;
|
||||
ClientInfo &cl = client_list.back() ;
|
||||
float_array V = cl.getRef_viterbi_V() ;
|
||||
vector<Point>
|
||||
&E_current = cl.getRef_viterbi_Ecurrent(),
|
||||
&E_previous = cl.getRef_viterbi_Eprevious() ;
|
||||
vector<ReferencePoint> peregrination_point_list ;
|
||||
makePointListFromFile(peregrination_point_list, DEFAULT_TRACKING_FILE, false) ;
|
||||
#else // TEST
|
||||
float_array V = client_list[id_client].getRef_viterbi_V() ;
|
||||
vector<Point>
|
||||
&E_current = client_list[id_client].getRef_viterbi_Ecurrent(),
|
||||
&E_previous = client_list[id_client].getRef_viterbi_Eprevious() ;
|
||||
#endif // TEST
|
||||
&E_current = client_list[client_id].getRef_viterbi_Ecurrent(),
|
||||
&E_previous = client_list[client_id].getRef_viterbi_Eprevious() ;
|
||||
|
||||
int i = 1 ; // Nombre d'ensembles d'historique qu'on a déjà passés
|
||||
unsigned int V0_min_k = 0 ; // Indice du point sélectionné à chaque itération
|
||||
|
||||
if (N < 2)
|
||||
if (VITERBI_N < 2)
|
||||
{
|
||||
cerr << "fastViterbiLike() : N ne peut être inférieur à 2 !" << endl ;
|
||||
cerr << "monitorClient() : N ne peut être inférieur à 2 !" << endl ;
|
||||
return ;
|
||||
}
|
||||
|
||||
client_list.back().print_viterbi_V() ;
|
||||
|
||||
#ifdef TEST
|
||||
vector<ReferencePoint> peregrination_point_list ;
|
||||
makePointListFromFile(peregrination_point_list, DEFAULT_TRACKING_FILE, false) ;
|
||||
#endif // TEST
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << reference_point_list.size() << " points de référence" ;
|
||||
|
@ -1184,93 +1178,128 @@ void Server::fastViterbiLike(const unsigned short &N, const unsigned short &K, c
|
|||
/* Get point measurements */
|
||||
//vm.clear();
|
||||
vm = peregrination_point_list[pt].getMeasurementList();
|
||||
#else // TEST
|
||||
vm = récupère_mesure() ; // FIXME !
|
||||
#endif // TEST
|
||||
|
||||
E_previous = E_current ;
|
||||
E_current = getkClosestInSs(vm, K) ; // Création de l'ensemble des K points les plus proches dans l'espace des puissances.
|
||||
E_current = getkClosestInSs(vm, VITERBI_K) ; // Création de l'ensemble des K points les plus proches dans l'espace des puissances.
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "Point courant : " << peregrination_point_list[pt] ;
|
||||
#endif // DEBUG
|
||||
|
||||
if (i > 1) // Si on n'est plus à la première itération
|
||||
{
|
||||
/* Recalcul des plus courtes distances */
|
||||
for (float_index n = N-1-i ; n < N-2 ; n++) // Pour chaque historique existant (sauf le dernier),
|
||||
for (float_index k = 0 ; k < K ; k++) // pour chaque point de l'historique,
|
||||
{ // on met à jour le chemin minimum entre l'historique précédent et le point :
|
||||
V[n][k] = V[n+1][0] + E_previous[0].distance(E_current[k]) ;
|
||||
for (float_index l = 1 ; l < K ; l++)
|
||||
{
|
||||
float f = V[n+1][l] + E_previous[l].distance(E_current[k]) ;
|
||||
if (f < V[n][k])
|
||||
V[n][k] = f ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Traitement du dernier historique */
|
||||
for (float_index k = 0 ; k < K ; k++) // Pour chaque point,
|
||||
{ // on récupère le chemin minimum entre l'historique précédent et le point :
|
||||
V[N-2][k] = E_previous[0].distance(E_current[k]) ;
|
||||
for (float_index l = 1 ; l < K ; l++)
|
||||
{
|
||||
float f = E_previous[l].distance(E_current[k]) ;
|
||||
if (f < V[N-2][k])
|
||||
V[N-2][k] = f ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Choix du point à renvoyer */
|
||||
V0_min_k = 0 ; // Indice du point correspondant au V0 minimal. Si le tableau n'est pas plein, la plus petite valeur a l'indice 0 (car getkClosestInSs() renvoit un résultat trié).
|
||||
if (N-1-i == 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
float V0_min = V[0][0] ;
|
||||
cout << "V[0][0]=" << V[0][0] << " ; V0_min=" << V0_min << " ; V0_min_k=" << V0_min_k << " -- " ;
|
||||
#endif // DEBUG
|
||||
for (float_index k=1 ; k < K ; k++)
|
||||
{
|
||||
if (V[0][k] < V0_min)
|
||||
{
|
||||
V0_min_k = k ;
|
||||
#ifdef DEBUG
|
||||
V0_min = V[0][k] ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
#ifdef DEBUG
|
||||
cout << "V[0][" << k << "]=" << V[0][k] << " ; V0_min=" << V0_min << " ; V0_min_k=" << V0_min_k << " -- " ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
#ifdef DEBUG
|
||||
cout << "V0_min = " << V0_min << " ; V0_min_k=" << V0_min_k << endl ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// cout << "(N=" << N << ") - 1 - (i=" << i << ") = " << N-1-i << endl ;
|
||||
cout << "V :" << endl ;
|
||||
for (float_index n=0 ; n < N-1 ; n++)
|
||||
{
|
||||
for (float_index k=0 ; k < K ; k++)
|
||||
cout << "[" << V[n][k] << "]" ;
|
||||
cout << endl ;
|
||||
}
|
||||
cout << "Point sélectionné : " << E_current[V0_min_k] << endl ;
|
||||
cout << "--------------------------" << endl ;
|
||||
#endif // DEBUG
|
||||
|
||||
if (i < N-1)
|
||||
i++ ;
|
||||
/* Application de l'algorithme Viterbi */
|
||||
fastViterbiLike(client_id, NULL) ;
|
||||
|
||||
#ifdef TEST
|
||||
pt++ ;
|
||||
#endif // TEST
|
||||
}
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- Server::monitorClient()" << endl ; fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Computes new cumulative distances for the viterbi instance of the client nb "client_id".
|
||||
* Returns the solution (Point) of the last ended viterbi.
|
||||
* Distances are grouped by line corresponding to an instance.
|
||||
*/
|
||||
Point Server::fastViterbiLike(const unsigned int &client_id, float **distance_matrix)
|
||||
{
|
||||
#ifdef DEBUG_T
|
||||
cout << "//--> Server::fastViterbiLike()" << endl ; fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
float_array &V = client_list[client_id].getRef_viterbi_V() ;
|
||||
vector<Point>
|
||||
&E_current = client_list[client_id].getRef_viterbi_Ecurrent(),
|
||||
&E_previous = client_list[client_id].getRef_viterbi_Eprevious() ;
|
||||
unsigned int &i = client_list[client_id].getRef_viterbi_iteration() ;
|
||||
|
||||
int N = VITERBI_N, K = VITERBI_K ;
|
||||
|
||||
unsigned int V0_min_k = 0 ; // Indice du point sélectionné à chaque itération
|
||||
|
||||
|
||||
if (i > 1) // Si on n'est plus à la première itération
|
||||
{
|
||||
/* Recalcul des plus courtes distances */
|
||||
for (float_index n = N-1-i ; n < N-2 ; n++) // Pour chaque historique existant (sauf le dernier),
|
||||
for (float_index k = 0 ; k < K ; k++) // pour chaque point de l'historique,
|
||||
{ // on met à jour le chemin minimum entre l'historique précédent et le point :
|
||||
V[n][k] = V[n+1][0] + E_previous[0].distance(E_current[k]) ;
|
||||
for (float_index l = 1 ; l < K ; l++)
|
||||
{
|
||||
float f = V[n+1][l] + E_previous[l].distance(E_current[k]) ;
|
||||
if (f < V[n][k])
|
||||
V[n][k] = f ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Traitement du dernier historique */
|
||||
for (float_index k = 0 ; k < K ; k++) // Pour chaque point,
|
||||
{ // on récupère le chemin minimum entre l'historique précédent et le point :
|
||||
V[N-2][k] = E_previous[0].distance(E_current[k]) ;
|
||||
for (float_index l = 1 ; l < K ; l++)
|
||||
{
|
||||
float f = E_previous[l].distance(E_current[k]) ;
|
||||
if (f < V[N-2][k])
|
||||
V[N-2][k] = f ;
|
||||
}
|
||||
}
|
||||
|
||||
/* Choix du point à renvoyer */
|
||||
V0_min_k = 0 ; // Indice du point correspondant au V0 minimal. Si le tableau n'est pas plein, la plus petite valeur a l'indice 0 (car getkClosestInSs() renvoit un résultat trié).
|
||||
if (N-1-i == 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
float V0_min = V[0][0] ;
|
||||
cout << "V[0][0]=" << V[0][0] << " ; V0_min=" << V0_min << " ; V0_min_k=" << V0_min_k << " -- " ;
|
||||
#endif // DEBUG
|
||||
for (float_index k=1 ; k < K ; k++)
|
||||
{
|
||||
if (V[0][k] < V0_min)
|
||||
{
|
||||
V0_min_k = k ;
|
||||
#ifdef DEBUG
|
||||
V0_min = V[0][k] ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
#ifdef DEBUG
|
||||
cout << "V[0][" << k << "]=" << V[0][k] << " ; V0_min=" << V0_min << " ; V0_min_k=" << V0_min_k << " -- " ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
#ifdef DEBUG
|
||||
cout << "V0_min = " << V0_min << " ; V0_min_k=" << V0_min_k << endl ;
|
||||
#endif // DEBUG
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
cout << "V :" << endl ;
|
||||
for (float_index n=0 ; n < N-1 ; n++)
|
||||
{
|
||||
for (float_index k=0 ; k < K ; k++)
|
||||
cout << "[" << V[n][k] << "]" ;
|
||||
cout << endl ;
|
||||
}
|
||||
cout << "Point sélectionné : " << E_current[V0_min_k] << endl ;
|
||||
cout << "--------------------------" << endl ;
|
||||
#endif // DEBUG
|
||||
|
||||
if (i < N-1)
|
||||
i++ ;
|
||||
|
||||
#ifdef DEBUG_T
|
||||
cout << "//<-- Server::fastViterbiLike()" << endl ; fflush(stdout) ;
|
||||
#endif // DEBUG_T
|
||||
|
||||
return E_current[V0_min_k] ;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -108,10 +108,8 @@ public:
|
|||
|
||||
unsigned int getNbReferencePoints()const { return reference_point_list.size(); };
|
||||
|
||||
//void monitorClient(const unsigned int &client_id) ;
|
||||
//Point fastViterbiLike(const unsigned int &id_client, float **distance_matrix) ;
|
||||
void fastViterbiLike(const unsigned short &N, const unsigned short &K, const unsigned int &id_client) ;
|
||||
void printLastClientV();
|
||||
void monitorClient(const unsigned int &client_id) ;
|
||||
Point fastViterbiLike(const unsigned int &id_client, float **distance_matrix) ;
|
||||
|
||||
/* For experimentation purpose only ! */
|
||||
void radar_exp();
|
||||
|
|
Loading…
Reference in New Issue