Ajout computeTopologyDistances() dans server

server.{hh,cc} :
* Ajout de computeTopologyDistances(), nécessaire au FRBHM continu.
* Intégration aux modifications de Soumaya.

git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@51 785a6c6c-259e-4ff1-8b91-dc31627914f0
This commit is contained in:
Matteo Cypriani 2008-07-09 08:27:39 +00:00
parent 1f5ce0426a
commit 2a56009c16
3 changed files with 53 additions and 14 deletions

View File

@ -19,7 +19,7 @@ int main(int argc, char ** argv)
Server server ;
server.createClient() ;
server.monitorClient(0, ALGO_BASIC_FRBHM) ;
server.monitorClient(0, ALGO_CONTINU_FRBHM) ;
cout << argv[0] << " : fin." << endl ;
fflush(stdout) ;

View File

@ -1,5 +1,4 @@
#include "server.hh"
#include <cmath>
@ -1934,11 +1933,18 @@ void Server::makeReferencePointDistances()
*/
void Server::selectDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2) const
{
#ifdef DEBUG_T
cout << "//--> Server::selectDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
matrix->resize(boost::extents[l1.size()][l2.size()]) ;
for (unsigned int i = 0 ; i < l1.size() ; i++)
for (unsigned int j = 0 ; j < l2.size() ; j++)
(*matrix)[i][j] = reference_point_matrix[pointIndex(l1[i])][pointIndex(l2[j])] ;
#ifdef DEBUG_T
cout << "//<-- Server::selectDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
}
@ -1947,11 +1953,40 @@ void Server::selectDistances(float_array *matrix, const vector<Point> &l1, const
*/
void Server::computeEuclideanDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2) const
{
#ifdef DEBUG_T
cout << "//--> Server::computeEuclideanDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
matrix->resize(boost::extents[l1.size()][l2.size()]) ;
for (unsigned int i = 0 ; i < l1.size() ; i++)
for (unsigned int j = 0 ; j < l2.size() ; j++)
(*matrix)[i][j] = l1[i].distance(l2[j]) ;
#ifdef DEBUG_T
cout << "//<-- Server::computeEuclideanDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
}
/* Calcule et place dans "matrix" les distances euclidiennes entre les points de "l1" et de "l2".
*/
void Server::computeTopologyDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2)
{
#ifdef DEBUG_T
cout << "//--> Server::computeTopologyDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
matrix->resize(boost::extents[l1.size()][l2.size()]) ;
for (unsigned int i = 0 ; i < l1.size() ; i++)
for (unsigned int j = 0 ; j < l2.size() ; j++)
(*matrix)[i][j] = distanceTopology(l1[i], l2[j]) ;
#ifdef DEBUG_T
cout << "//<-- Server::computeTopologyDistances()" << endl ; fflush(stdout) ;
#endif // DEBUG_T
}
@ -2217,17 +2252,20 @@ void Server::monitorClient(const unsigned int &client_id, const ALGORITHM &algo)
Frbhmbasique = fbcm_friis(vm, friisFromList);
cout << "Point selectioné: " << Frbhmbasique << endl;
break ;
case ALGO_CONTINU_FRBHM : /*Application de l'algorithme FRBHM continu */
cout << "--------FRBHM CONTINU------------" << endl ;
//computeFriisFromRefList();
for(unsigned int i= 0 ; i<E_current.size() ;i++)
{
friisFromList = computeFriisFromRefList(E_current[i],vm);
E_current[i] = fbcm_friis(vm, friisFromList);
}
pointFastViterbi = fastViterbiLike(client_id, dst_matrix) ;
cout << "Point selectionné: " << pointFastViterbi << endl;
break;
case ALGO_CONTINU_FRBHM : /* Application de l'algorithme FRBHM continu */
cout << "--------FRBHM CONTINU------------" << endl ;
//computeFriisFromRefList();
computeTopologyDistances(&dst_matrix, E_previous, E_current) ; // On calcule les distances entre les points de E_previous et E_current, en tenant compte de la topologie).
for (unsigned int i = 0 ; i < E_current.size() ; i++)
{
friisFromList = computeFriisFromRefList(E_current[i], vm) ;
E_current[i] = fbcm_friis(vm, friisFromList) ;
}
pointFastViterbi = fastViterbiLike(client_id, dst_matrix) ;
cout << "Point selectionné: " << pointFastViterbi << endl ;
break ;
default :
cerr << "Erreur ! Algorithme inconnu." << endl ;
}

View File

@ -48,7 +48,7 @@ typedef ClientInfo::float_index float_index ;
//#define DEFAULT_Z 3 // Décommenter pour utiliser des fichiers d'entrée avec des coordonnées dans un seul plan (X, Y).
//#define FRED_CSV_FORMAT // Décommenter pour utiliser les fichiers CSV au « format Fred » (plusieurs lignes par mesure, avec un AP par ligne).
typedef enum { ALGO_VLI = 1, ALGO_BASIC_FRBHM = 2, ALGO_CONTINU_FRBHM = 3 } ALGORITHM ;
typedef enum { ALGO_VLI = 1, ALGO_BASIC_FRBHM, ALGO_CONTINU_FRBHM } ALGORITHM ;
class Server
@ -122,6 +122,7 @@ public:
void selectDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2) const ;
void computeEuclideanDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2) const ;
void computeTopologyDistances(float_array *matrix, const vector<Point> &l1, const vector<Point> &l2) ;
void printReferencePointList() ;
void printPointList(vector<ReferencePoint> &point_list) ;