current code and TeX. code fine?!?!?!

This commit is contained in:
2017-04-29 20:57:12 +02:00
parent fc72a75f57
commit 60712689cf
41 changed files with 804 additions and 234 deletions

231
main.cpp Normal file → Executable file
View File

@@ -248,7 +248,7 @@ void errorPlotAllModels(Floorplan::IndoorMap* map) {
std::vector<K::Statistics<float>> errors = errorStatAllModels(map);
PlotErrFunc plot("", "fingerprints (%)");
PlotErrFunc plot("", "reference measurements (%)");
plot.getPlot().getAxisX().setTicsLabelFormat("%h dB");
plot.add("\\noOptEmpiric{}", &errors[0]);
plot.add("\\optParamsAllAP{}", &errors[1]);
@@ -275,14 +275,15 @@ void errorPlotAllModels(Floorplan::IndoorMap* map) {
// plot.getGP() << "set rmargin 0.2\n";
// plot.getGP() << "set bmargin 1.9\n";
plot.getPlot().getMargin().set(4.2, 0.2, 0.1, 1.9);
plot.getPlot().getAxisY().setLabelOffset(3.0,0);
plot.getPlot().getAxisY().setLabelOffset(3.0 - 0.75, 0);
plot.getPlot().setStringMod(new K::GnuplotStringModLaTeX());
plot.getPlot().getKey().setSampleLength(0.5);
plot.getPlot().getKey().setWidthIncrement(+7.0);
plot.setYRange(0, 95, 5);
plot.getPlot().getAxisY().setRange(K::GnuplotAxis::Range(0, 100));
plot.getPlot().getAxisY().setTicsStep(0, 25, 100);
plot.getPlot().getAxisY().setRange(K::GnuplotAxis::Range(0, 95));
//plot.getPlot().getAxisY().setTicsStep(0, 25, 100);
plot.getPlot().getAxisY().setTicsStep({0,25,50,75,95});
plot.getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 4.0));
plot.getPlot().getAxisX().setTicsStep(4); // 4dB
plot.getPlot().getAxisX().setRange(K::GnuplotAxis::Range(0, 16));
@@ -308,7 +309,7 @@ void errorPlotAllModels(Floorplan::IndoorMap* map) {
/** error plot for the given stats. used for fingerprint errors */
void errorPlotNumFingerprints(const std::vector<K::Statistics<float>>& stats, const std::vector<std::string>& titles, const std::string& name) {
PlotErrFunc plot("", "fingerprints (%)");
PlotErrFunc plot("", "ref. measurements (%)");
plot.getPlot().getAxisX().setTicsLabelFormat("%h dB");
plot.getPlot().getKey().setVisible(true);
@@ -335,22 +336,26 @@ void errorPlotNumFingerprints(const std::vector<K::Statistics<float>>& stats, co
// plot.getGP() << "set rmargin 0.2\n";
// plot.getGP() << "set bmargin 1.9\n";
plot.getPlot().getMargin().set(4.2, 0.2, 0.1, 1.9);
plot.getPlot().getAxisY().setLabelOffset(3.0,0);
plot.getPlot().getAxisY().setLabelOffset(3.0 - 0.7,0);
plot.getPlot().setStringMod(new K::GnuplotStringModLaTeX());
plot.getPlot().getKey().setSampleLength(0.5);
plot.getPlot().getKey().setWidthIncrement(-5.0);
plot.setYRange(0, 90, 5);
plot.getPlot().getAxisY().setRange(K::GnuplotAxis::Range(0, 100));
plot.getPlot().getAxisY().setTicsStep(0, 25, 100);
plot.getPlot().getAxisY().setRange(K::GnuplotAxis::Range(0, 90));
plot.getPlot().getAxisY().setTicsStep({0, 25, 50, 75, 90});
//lot.getPlot().getAxisY().setTicsStep(0, 25, 100);
plot.getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 3.3));
plot.getPlot().getAxisX().setTicsStep(4); // 4dB
plot.getPlot().getAxisX().setRange(K::GnuplotAxis::Range(0, 16));
plot.getPlot().getAxisX().setRange(K::GnuplotAxis::Range(0, 14));
plot.getGP().setOutput(Settings::fPathGFX + "/" + name + "_0_90.tex");
plot.writePlotToFile(Settings::fPathGFX + "/" + name + "_0_90.gp");
plot.plot();
// changes
plot.getPlot().getKey().setVisible(false);
plot.getPlot().getAxisY().setLabel("");
plot.setYRange(90, 100, 1);
plot.getPlot().getAxisY().setTicsStep(2);
plot.getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 2.6));
@@ -572,6 +577,8 @@ void plotEstAndRealApPosDistance(Floorplan::IndoorMap* map) {
}
#warning "TODO: code um alle pfade MEHRFACH mit allen modellen durch den filter laufen zu lassen"
// build plots for the paper
void paperOutputs() {
@@ -666,13 +673,15 @@ void paperOutputs() {
// perform varios AP-param optimizations
// generate error plot showing the performance of each
// save the resulting wifi-models to XML for later re-use during the walk-eval <<<<<< !!!!
if (1 == 0) {
if (1 == 1) {
rebuildAllModels(map, 0);
/** detailled error analysis for above optimization routine */
errorPlotAllModels(map);
}
// leaving out fingerprints and the effects on all optimization strategies
if (1 == 0) {
rebuildAllModels(map,4);
@@ -686,6 +695,13 @@ void paperOutputs() {
// analyze all 5 opt strategies. skip the empiric one: stats0[0]
for (int i = 1; i < 6; ++i) {
std::cout << "leaving out fingerprints for model " << i << std::endl;
std::cout << "\t 25%: " << stats4[i].asString() << std::endl;
std::cout << "\t 50%: " << stats2[i].asString() << std::endl;
std::cout << "\t 100%: " << stats0[i].asString() << std::endl;
std::cout << "\t noStair%: " << statsNoStairs[i].asString() << std::endl;
std::cout << std::endl;
std::string name = "wifi_model_error_num_fingerprints_method_" + std::to_string(i);
errorPlotNumFingerprints(
{stats0[0], stats4[i], stats2[i], stats0[i], statsNoStairs[i]},
@@ -729,62 +745,36 @@ void paperOutputs() {
// error histogram all pos, all params, between in/out/stair, in/out, in/stair, in
if(1==0){
// // error histogram all pos, all params, between in/out/stair, in/out, in/stair, in
// if(1==0){
EvalCompareOpt e1(Settings::fMap, Settings::fCalib, false, false, false);
EvalCompareOpt e2(Settings::fMap, Settings::fCalib, true, false, false);
EvalCompareOpt e3(Settings::fMap, Settings::fCalib, false, true, false);
EvalCompareOpt e4(Settings::fMap, Settings::fCalib, true, true, false);
// EvalCompareOpt e1(Settings::fMap, Settings::fCalib, false, false, false);
// EvalCompareOpt e2(Settings::fMap, Settings::fCalib, true, false, false);
// EvalCompareOpt e3(Settings::fMap, Settings::fCalib, false, true, false);
// EvalCompareOpt e4(Settings::fMap, Settings::fCalib, true, true, false);
K::Statistics<float> s1 = e1.optPosOptParamsForEach().errAbs;
K::Statistics<float> s2 = e2.optPosOptParamsForEach().errAbs;
K::Statistics<float> s3 = e3.optPosOptParamsForEach().errAbs;
K::Statistics<float> s4 = e4.optPosOptParamsForEach().errAbs;
// K::Statistics<float> s1 = e1.optPosOptParamsForEach().errAbs;
// K::Statistics<float> s2 = e2.optPosOptParamsForEach().errAbs;
// K::Statistics<float> s3 = e3.optPosOptParamsForEach().errAbs;
// K::Statistics<float> s4 = e4.optPosOptParamsForEach().errAbs;
PlotErrFunc pef("\\small{error (dB)}", "\\small{fingerprints (\\%)}");
pef.add("\\small{floor + stairs + out}", &s1);
pef.add("\\small{floor + out}", &s2);
pef.add("\\small{floor + stairs}", &s3);
pef.add("\\small{floor}", &s4);
// PlotErrFunc pef("\\small{error (dB)}", "\\small{fingerprints (\\%)}");
// pef.add("\\small{floor + stairs + out}", &s1);
// pef.add("\\small{floor + out}", &s2);
// pef.add("\\small{floor + stairs}", &s3);
// pef.add("\\small{floor}", &s4);
pef.getGP().setTerminal("epslatex", K::GnuplotSize(8.5, 5));
pef.getGP().setOutput(Settings::fPathGFX + "wifi-opt-error-hist-stair-outdoor.tex");
pef.writePlotToFile(Settings::fPathGFX + "wifi-opt-error-hist-stair-outdoor.gp");
pef.getGP() << "set key right bottom width -3\n";
pef.getGP() << "set rmargin 0.4\n";
pef.getGP() << "set tmargin 0.4\n";
pef.plot();
// pef.getGP().setTerminal("epslatex", K::GnuplotSize(8.5, 5));
// pef.getGP().setOutput(Settings::fPathGFX + "wifi-opt-error-hist-stair-outdoor.tex");
// pef.writePlotToFile(Settings::fPathGFX + "wifi-opt-error-hist-stair-outdoor.gp");
// pef.getGP() << "set key right bottom width -3\n";
// pef.getGP() << "set rmargin 0.4\n";
// pef.getGP() << "set tmargin 0.4\n";
// pef.plot();
}
// }
// wifi issue for path1
if (1 == 0) {
Offline::FileReader reader(Settings::path1a);
PlotWifiMeasurements plot;
for (int i = 0; i < 60; ++i) {
const WiFiMeasurements mes = reader.getWiFiGroupedByTime().at(i).data;
const WiFiMeasurements mes2 = Settings::WiFiModel::vg_eval.group(mes);
plot.add(mes2);
}
K::GnuplotObjectRectangle rect(
K::GnuplotCoordinate2(0, K::GnuplotCoordinateSystem::FIRST, 0, K::GnuplotCoordinateSystem::GRAPH),
K::GnuplotCoordinate2(10, K::GnuplotCoordinateSystem::FIRST, 1, K::GnuplotCoordinateSystem::GRAPH),
K::GnuplotFill(K::GnuplotFillStyle::SOLID, K::GnuplotColor::fromRGB(128,128,128), 0.5),
K::GnuplotStroke()
);
plot.getPlot().setGrid(true);
plot.getPlot().getKey().setVisible(false);
plot.getPlot().getObjects().add(&rect);
plot.plot();
sleep(100);
}
}
@@ -799,13 +789,20 @@ void testWAF() {
K::Gnuplot gp;
K::GnuplotPlot gplot;
K::GnuplotPlotElementLines lines; gplot.add(&lines);
K::GnuplotPlotElementLines ceils; gplot.add(&ceils);
const Point3 posAP(0, 0, 8);
for (const float h : ceilings.getCeilings()) {
ceils.addSegment(K::GnuplotPoint2(h, -2), K::GnuplotPoint2(h, +4));
}
for (float z = 0; z < 15; z += 0.1) {
const Point3 posMe(0, 0, z);
//float factor = ceilings.numCeilingsBetweenLinearInt(posAP, posMe);
float factor = ceilings.numCeilingsBetweenFloat(posAP, posMe);
lines.add({z, factor});
}
@@ -813,7 +810,7 @@ void testWAF() {
gp.draw(gplot);
gp.flush();
sleep(1000);
sleep(10);
}
@@ -900,6 +897,10 @@ int main(void) {
Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(Settings::fMap);
//testWAF();
//sleep(1);
//const float rssi = LogDistanceModel::distanceToRssi(-100, 0, 999);
//int i = 0; (void) i;
//paperOutputs(); return 0;
@@ -908,11 +909,41 @@ int main(void) {
//showFingerprintsFor(Settings::fMap, Settings::fCalib, "D8:84:66:4A:4A:E0");
//showModelFor(Settings::fMap, Settings::wifiEachOptParPos_multimodel, "D8:84:66:4A:4A:E0");
if (1 == 1) {
if (1 == 0) {
plotEstAndRealApPosDistance(map);
int i = 0; (void) i;
}
// // wifi issue for path1
// if (1 == 1) {
// Offline::FileReader reader(Settings::path1a);
// PlotWifiMeasurements plot;
// for (int i = 0; i < 60; ++i) {
// const WiFiMeasurements mes = reader.getWiFiGroupedByTime().at(i).data;
// const WiFiMeasurements mes2 = Settings::WiFiModel::vg_eval.group(mes);
// plot.add(mes2);
// }
// K::GnuplotObjectRectangle rect(
// K::GnuplotCoordinate2(0, K::GnuplotCoordinateSystem::FIRST, 0, K::GnuplotCoordinateSystem::GRAPH),
// K::GnuplotCoordinate2(10, K::GnuplotCoordinateSystem::FIRST, 1, K::GnuplotCoordinateSystem::GRAPH),
// K::GnuplotFill(K::GnuplotFillStyle::SOLID, K::GnuplotColor::fromRGB(128,128,128), 0.5),
// K::GnuplotStroke()
// );
// plot.getPlot().setGrid(true);
// plot.getPlot().getKey().setVisible(false);
// plot.getPlot().getObjects().add(&rect);
// plot.plot();
// sleep(100);
// }
// calib error in/out
if (1 == 0) {
@@ -942,22 +973,31 @@ int main(void) {
}
// prob on ground
// plot probability within the building for every wifi measurement
if (1 == 0) {
EvalWiFiGround eval(map, Settings::wifiEachOptParPos_multimodel);
Plotty::Settings settings;
settings.outline = false;
EvalWiFiGround eval(map, Settings::wifiEachOptParPos_multimodel, settings);
//EvalWiFiGround eval(map, Settings::wifiEachOptParPos_perBBox, settings);
//EvalWiFiGround eval(map, Settings::wifiEachOptPar, settings);
//EvalWiFiGround eval(map, Settings::wifiEachOptParPos, settings);
//eval.show(Settings::path1a);
eval.show(Settings::path2a);
//eval.show(Settings::path_toni_inst_2b, Settings::GroundTruth::path_toni_inst_2);
eval.show(Settings::path_toni_inst_3a, Settings::GroundTruth::path_toni_inst_3);
int i = 0; (void) i;
}
// walks
if (1 == 0) {
if (1 == 1) {
Floorplan::IndoorMap* map = Floorplan::Reader::readFromFile(Settings::fMap);;
EvalWalk walk(map);
walk.walk1();
//EvalWalk walk(map);
//walk.walk1();
EvalWalk::walkEverything(map);
EvalWalk::walkEverythingBuildStats(map);
return 0;
}
@@ -1069,21 +1109,24 @@ int main(void) {
std::cout << "num scans: " << numScans << std::endl;
if (1 == 1) {
EvalWiFiPaths ewp(Settings::fMap);
ewp.loadModel(Settings::wifiAllFixed, "\\noOptEmpiric{}");
ewp.walks(files, gtIndices);
EvalWiFiPaths ewp(Settings::fMap);
ewp.loadModel(Settings::wifiAllFixed, "\\noOptEmpiric{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos, "\\optParamsPosEachAP{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos, "\\optParamsPosEachAP{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos_multimodel, "\\optPerFloor{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos_multimodel, "\\optPerFloor{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos_perBBox, "\\optPerRegion{}");
ewp.walks(files, gtIndices);
ewp.loadModel(Settings::wifiEachOptParPos_perBBox, "\\optPerRegion{}");
ewp.walks(files, gtIndices);
ewp.writeGP(Settings::fPathGFX, "modelPerformance");
ewp.writeGP(Settings::fPathGFX, "modelPerformance");
}
// examine various modifications
if (1 == 0) {
@@ -1114,27 +1157,27 @@ int main(void) {
}
// compare wifi opt methods
if (1 == 0) {
// // compare wifi opt methods
// if (1 == 0) {
const bool ignoreStaircases = false;
const bool ignoreOutdoor = false;
const bool ignoreIndoor = false;
EvalCompareOpt opt(Settings::fMap, Settings::fCalib, ignoreStaircases, ignoreOutdoor, ignoreIndoor);
// const bool ignoreStaircases = false;
// const bool ignoreOutdoor = false;
// const bool ignoreIndoor = false;
// EvalCompareOpt opt(Settings::fMap, Settings::fCalib, ignoreStaircases, ignoreOutdoor, ignoreIndoor);
EvalCompareOpt::Result s1 = opt.fixedPosFixedParamsForAll(); //BREAK;
EvalCompareOpt::Result s2 = opt.fixedPosOptParamsForAll(); //BREAK;
EvalCompareOpt::Result s3 = opt.fixedPosOptParamsForEach(); //BREAK;
EvalCompareOpt::Result s4 = opt.optPosOptParamsForEach(); //BREAK;
// EvalCompareOpt::Result s1 = opt.fixedPosFixedParamsForAll(); //BREAK;
// EvalCompareOpt::Result s2 = opt.fixedPosOptParamsForAll(); //BREAK;
// EvalCompareOpt::Result s3 = opt.fixedPosOptParamsForEach(); //BREAK;
// EvalCompareOpt::Result s4 = opt.optPosOptParamsForEach(); //BREAK;
PlotErrFunc pef("error (dB)", "fingerprints (%)");
pef.add("empiric", &s1.errAbs);
pef.add("real pos, opt params [same for all]", &s2.errAbs);
pef.add("real pos, opt params [for each]", &s3.errAbs);
pef.add("opt pos, opt params [for each]", &s4.errAbs);
pef.plot();
// PlotErrFunc pef("error (dB)", "fingerprints (%)");
// pef.add("empiric", &s1.errAbs);
// pef.add("real pos, opt params [same for all]", &s2.errAbs);
// pef.add("real pos, opt params [for each]", &s3.errAbs);
// pef.add("opt pos, opt params [for each]", &s4.errAbs);
// pef.plot();
}
// }
// compare leaving out fingerprints
if (1 == 0) {