added tex
many changes/eval etc...
This commit is contained in:
@@ -16,9 +16,11 @@
|
||||
#include "Indoor/floorplan/v2/FloorplanCeilings.h"
|
||||
|
||||
#include "Indoor/sensors/radio/model/WiFiModelLogDistCeiling.h"
|
||||
#include "Helper.h"
|
||||
|
||||
using APAtFloor = std::pair<Floorplan::AccessPoint*, Floorplan::Floor*>;
|
||||
|
||||
|
||||
/**
|
||||
* compare different optimzation levels
|
||||
* fixed ap pos / fixed params
|
||||
@@ -29,8 +31,9 @@ class EvalCompareOpt {
|
||||
|
||||
protected:
|
||||
|
||||
int power = 1;
|
||||
Floorplan::IndoorMap* map;
|
||||
WiFiFingerprints* calib;
|
||||
WiFiFingerprints calib;
|
||||
VAPGrouper* vap;
|
||||
Floorplan::Ceilings ceilings;
|
||||
std::vector<APAtFloor> mapAPs;
|
||||
@@ -38,13 +41,26 @@ protected:
|
||||
|
||||
|
||||
/** ctor with map and fingerprints */
|
||||
EvalCompareOpt(const std::string& mapFile, const std::string& fpFile) {
|
||||
EvalCompareOpt(const std::string& mapFile, const std::string& fpFile, const bool ignoreStaircases, const bool ignoreOutdoor) {
|
||||
|
||||
// load floorplan
|
||||
map = Floorplan::Reader::readFromFile(mapFile);
|
||||
|
||||
// how to group VAPs
|
||||
vap = new VAPGrouper(VAPGrouper::Mode::LAST_MAC_DIGIT_TO_ZERO, VAPGrouper::Aggregation::AVERAGE);
|
||||
|
||||
// load fingerprints
|
||||
calib = new WiFiFingerprints(fpFile);
|
||||
calib = WiFiFingerprints(fpFile);
|
||||
|
||||
LeHelper::removeNonFHWS(calib);
|
||||
if (ignoreOutdoor) {calib = LeHelper::removeOutdoor(calib);}
|
||||
if (ignoreStaircases) {calib = LeHelper::removeStaircases(calib);}
|
||||
//LeHelper::plot(map, calib);
|
||||
WiFiFingerprints calib2 = calib;
|
||||
for (WiFiFingerprint& fp : calib2.getFingerprints()) {
|
||||
fp.measurements = vap->group(fp.measurements);
|
||||
}
|
||||
LeHelper::plot(map, calib2);
|
||||
|
||||
// some ceiling calculations
|
||||
ceilings = Floorplan::Ceilings(map);
|
||||
@@ -52,12 +68,9 @@ protected:
|
||||
// all APs within the map
|
||||
mapAPs = FloorplanHelper::getAPs(map);
|
||||
|
||||
// how to group VAPs
|
||||
vap = new VAPGrouper(VAPGrouper::Mode::LAST_MAC_DIGIT_TO_ZERO, VAPGrouper::Aggregation::AVERAGE);
|
||||
|
||||
// used to aggreagate fingerprints
|
||||
base = new WiFiOptimizer::Base(*vap);
|
||||
base->addFingerprints(*calib);
|
||||
base->addFingerprints(calib);
|
||||
|
||||
}
|
||||
|
||||
@@ -121,8 +134,8 @@ protected:
|
||||
const float diff = std::abs(rssiModel - reading.rssi);
|
||||
|
||||
// adjust
|
||||
stats.add(std::abs(diff));
|
||||
dstAbs.add(std::abs(diff));
|
||||
stats.add(std::pow(std::abs(diff), power));
|
||||
dstAbs.add(std::pow(std::abs(diff), power));
|
||||
|
||||
}
|
||||
|
||||
@@ -135,6 +148,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** fixed ap pos, fixed ap params */
|
||||
class EvalCompareOptAllFixed : public EvalCompareOpt {
|
||||
|
||||
@@ -147,8 +162,9 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
EvalCompareOptAllFixed(const std::string& mapFile, const std::string& fpFile) : EvalCompareOpt(mapFile, fpFile) {
|
||||
|
||||
EvalCompareOptAllFixed(const std::string& mapFile, const std::string& fpFile, const bool ignoreStaircases, const bool ignoreOutdoor) :
|
||||
EvalCompareOpt(mapFile, fpFile, ignoreStaircases, ignoreOutdoor) {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -182,28 +198,38 @@ public:
|
||||
}
|
||||
|
||||
/** calculate error for fixed positions and fixed constants */
|
||||
void fixedPosFixedParamsForAll() {
|
||||
K::Statistics<float> fixedPosFixedParamsForAll() {
|
||||
|
||||
// fire
|
||||
K::Statistics<float> stats = getStatsAll(txp, exp, waf);
|
||||
std::cout << "----------------------------------------------------" << std::endl;
|
||||
std::cout << "AP POS FROM MAP, FIXED TXP/EXP/WAF FOR ALL APS" << std::endl;
|
||||
std::cout << getStatsAll(txp, exp, waf).asString() << std::endl;
|
||||
std::cout << stats.asString() << std::endl;
|
||||
std::cout << std::endl;
|
||||
return stats;
|
||||
|
||||
}
|
||||
|
||||
/** calculate error for fixed positions and optimized constants, but the same 3 for all APs */
|
||||
void fixedPosOptParamsForAll() {
|
||||
K::Statistics<float> fixedPosOptParamsForAll() {
|
||||
|
||||
auto func = [&] (const float* params) {
|
||||
return getStatsAll(params[0], params[1], params[2]).getAvg();
|
||||
};
|
||||
|
||||
auto callback = [&] (const int run, const int iteration, const float , const float* ) {
|
||||
const int percent = ((run*40+iteration)*100) / (40*11);
|
||||
if (iteration == 0) {
|
||||
std::cout << percent << "," << std::flush;
|
||||
}
|
||||
};
|
||||
|
||||
// use simplex
|
||||
float params[3] = {-40, 2, -8};
|
||||
K::NumOptAlgoDownhillSimplex<float> opt(3);
|
||||
opt.setMaxIterations(50);
|
||||
opt.setMaxIterations(40);
|
||||
opt.setNumRestarts(10);
|
||||
opt.setCallback(callback);
|
||||
opt.calculateOptimum(func, params);
|
||||
|
||||
// use genetic
|
||||
@@ -215,16 +241,18 @@ public:
|
||||
// opt.setMutation(0.25);
|
||||
// opt.calculateOptimum(func, params);
|
||||
|
||||
K::Statistics<float> stats = getStatsAll(params[0], params[1], params[2]);
|
||||
std::cout << "----------------------------------------------------" << std::endl;
|
||||
std::cout << "AP POS FROM MAP, OPTIMIZING TXP/EXP/WAF: THE SAME FOR ALL APS" << std::endl;
|
||||
std::cout << "params: " << params[0] << "," << params[1] << "," << params[2] << std::endl;
|
||||
std::cout << getStatsAll(params[0], params[1], params[2]).asString() << std::endl;
|
||||
std::cout << stats.asString() << std::endl;
|
||||
std::cout << std::endl;
|
||||
return stats;
|
||||
|
||||
}
|
||||
|
||||
/** calculate error for fixed positions and optimized constants, each AP on its own */
|
||||
void fixedPosOptParamsForEach() {
|
||||
K::Statistics<float> fixedPosOptParamsForEach() {
|
||||
|
||||
K::Statistics<float> _dstAbs;
|
||||
|
||||
@@ -263,7 +291,7 @@ public:
|
||||
analyzeErrorForAP(mac, pos, params[0], params[1], params[2], tmp);
|
||||
|
||||
// adjust global error with the resulting params
|
||||
std::cout << "--" << mac.asString() << " params: " << params[0] << "," << params[1] << "," << params[2] << " err: " << tmp.getAvg() << std::endl;
|
||||
std::cout << "--" << mac.asString() << " params: " << params[0] << ",\t" << params[1] << ",\t" << params[2] << "\terr: " << tmp.getAvg() << std::endl;
|
||||
analyzeErrorForAP(mac, pos, params[0], params[1], params[2], _dstAbs);
|
||||
|
||||
}
|
||||
@@ -272,14 +300,19 @@ public:
|
||||
std::cout << "AP POS FROM MAP, OPTIMIZING TXP/EXP/WAF INDIVIDUALLY FOR EACH AP" << std::endl;
|
||||
std::cout << _dstAbs.asString() << std::endl;
|
||||
std::cout << std::endl;
|
||||
return _dstAbs;
|
||||
|
||||
}
|
||||
|
||||
/** calculate error for fixed positions and optimized constants, each AP on its own */
|
||||
void optPosOptParamsForEach() {
|
||||
K::Statistics<float> optPosOptParamsForEach() {
|
||||
|
||||
K::Statistics<float> _dstAbs;
|
||||
|
||||
std::cout << "NOTE" << std::endl;
|
||||
std::cout << "INCREASE ITERATIONS!" << std::endl;
|
||||
std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
|
||||
|
||||
// construct vector containing each AP within the map + add fixed parameters
|
||||
for (const APAtFloor& mapAP : mapAPs) {
|
||||
|
||||
@@ -312,9 +345,10 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
K::NumOptAlgoRangeRandom<float> opt(valRegion);
|
||||
opt.setPopulationSize(500);
|
||||
opt.setNumIerations(150);
|
||||
opt.setPopulationSize(100);
|
||||
opt.setNumIerations(40);
|
||||
opt.calculateOptimum(func, params);
|
||||
|
||||
// local stats
|
||||
@@ -322,7 +356,7 @@ public:
|
||||
analyzeErrorForAP(mac, Point3(params[0], params[1], params[2]), params[3], params[4], params[5], tmp);
|
||||
|
||||
// adjust global error with the resulting params
|
||||
std::cout << "--" << mac.asString() << " params: " << params[0] << "," << params[1] << "," << params[2] << "," << params[3] << "," << params[4] << "," << params[5] << " err: " << tmp.getAvg() << std::endl;
|
||||
std::cout << "--" << mac.asString() << " params: " << params[0] << ",\t" << params[1] << ",\t" << params[2] << ",\t" << params[3] << ",\t" << params[4] << ",\t" << params[5] << "\terr: " << tmp.getAvg() << std::endl;
|
||||
analyzeErrorForAP(mac, Point3(params[0], params[1], params[2]), params[3], params[4], params[5], _dstAbs);
|
||||
|
||||
}
|
||||
@@ -331,6 +365,7 @@ public:
|
||||
std::cout << "OPTIMIZING POS/TXP/EXP/WAF INDIVIDUALLY FOR EACH AP" << std::endl;
|
||||
std::cout << _dstAbs.asString() << std::endl;
|
||||
std::cout << std::endl;
|
||||
return _dstAbs;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user