+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.1.0, 2017-09-20T18:32:25. -->
-<qtcreator>
- <data>
- <variable>EnvironmentId</variable>
- <value type="QByteArray">{0d0dac41-b5d4-48ba-8b55-2eef6c8f9c37}</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.ActiveTarget</variable>
- <value type="int">0</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.EditorSettings</variable>
- <valuemap type="QVariantMap">
- <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
- <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
- <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
- <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
- <value type="QString" key="language">Cpp</value>
- <valuemap type="QVariantMap" key="value">
- <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
- </valuemap>
- </valuemap>
- <value type="int" key="EditorConfiguration.CodeStyle.Count">1</value>
- <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
- <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
- <value type="int" key="EditorConfiguration.IndentSize">4</value>
- <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
- <value type="int" key="EditorConfiguration.MarginColumn">80</value>
- <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
- <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
- <value type="int" key="EditorConfiguration.PaddingMode">1</value>
- <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
- <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
- <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
- <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
- <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
- <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
- <value type="int" key="EditorConfiguration.TabSize">8</value>
- <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
- <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
- <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
- <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
- <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
- <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.PluginSettings</variable>
- <valuemap type="QVariantMap"/>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Target.0</variable>
- <valuemap type="QVariantMap">
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{02771194-e57d-45d0-a1ce-cf0336f8bb4f}</value>
- <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
- <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
- <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
- <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
- <valuelist type="QVariantList" key="CMake.Configuration">
- <value type="QString">CMAKE_BUILD_TYPE:STRING=Debug</value>
- </valuelist>
- <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Debug</value>
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
- <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
- <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
- <value type="QString">all</value>
- </valuelist>
- <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
- </valuemap>
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
- <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
- <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
- <value type="QString">clean</value>
- </valuelist>
- <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
- <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
- <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
- </valuemap>
- <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
- <valuelist type="QVariantList" key="CMake.Configuration">
- <value type="QString">CMAKE_BUILD_TYPE:STRING=Release</value>
- <value type="QString">CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++</value>
- </valuelist>
- <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Release</value>
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
- <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
- <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
- <value type="QString">all</value>
- </valuelist>
- <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
- </valuemap>
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
- <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
- <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
- <value type="QString">clean</value>
- </valuelist>
- <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
- <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
- <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
- <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
- <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
- <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
- <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
- <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
- <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
- <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
- <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
- <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
- <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
- <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
- <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
- <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
- <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
- <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
- <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
- <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
- <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
- <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
- <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
- <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
- <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
- <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
- <value type="int">0</value>
- <value type="int">1</value>
- <value type="int">2</value>
- <value type="int">3</value>
- <value type="int">4</value>
- <value type="int">5</value>
- <value type="int">6</value>
- <value type="int">7</value>
- <value type="int">8</value>
- <value type="int">9</value>
- <value type="int">10</value>
- <value type="int">11</value>
- <value type="int">12</value>
- <value type="int">13</value>
- <value type="int">14</value>
- </valuelist>
- <value type="QString" key="CMakeProjectManager.CMakeRunConfiguation.Title">STMS_GrayLevelFiltering</value>
- <value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.Arguments"></value>
- <value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"></value>
- <value type="QString" key="CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory.default">/opt/MasterGrenier/bin/Creatis_GIT/STMS/STMS-Release/Src</value>
- <value type="int" key="PE.EnvironmentAspect.Base">2</value>
- <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">STMS_GrayLevelFiltering</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.STMS_GrayLevelFiltering</value>
- <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
- <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
- <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
- <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
- <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
- <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
- </valuemap>
- <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.TargetCount</variable>
- <value type="int">1</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
- <value type="int">18</value>
- </data>
- <data>
- <variable>Version</variable>
- <value type="int">18</value>
- </data>
-</qtcreator>
--- /dev/null
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+#include <fstream>
+
+#include <omp.h>
+
+typedef std::vector< float > TimeSerieType;
+typedef std::pair< unsigned int , float> DistanceIndexType;
+
+#pragma omp declare simd
+float distsq(float x, float y)
+{
+ return (x-y) * (x-y);
+}
+
+#pragma omp declare simd
+bool DistancePairComp (const DistanceIndexType &x, const DistanceIndexType &y)
+{
+ return x.second < y.second;
+}
+
+float EuclidianDistanceTimeSerie( const TimeSerieType &a, const TimeSerieType &b)
+{
+ float dist = 0;
+ unsigned int n = a.size();
+ #pragma omp parallel for simd reduction(+:dist) schedule(simd:static, 5)
+ for (unsigned int i=0; i<n ; i++)
+ dist += distsq( a[i], b[i]) ;
+
+ return std::sqrt(dist);
+}
+
+
+int main(int argc, char *argv[])
+{
+std::vector< TimeSerieType > ClassSeries;
+std::vector< unsigned int > ClassLabels;
+std::vector< unsigned int > ClassEffectif;
+
+unsigned int K = 5;
+unsigned int N = 2;
+std::cout << "argv[1] : csv filemane " << std::endl;
+std::cout << "argv[2] : K the number of neigboors" << std::endl;
+std::cout << "argv[3] : N the minimum effectif of classes "<< std::endl;
+
+///////////////////////////////////////////////////////////////
+/// \brief reading csv file
+///////////////////////////////////////////////////////////////
+std::ifstream ifs;
+ifs.open (argv[1], std::ifstream::in);
+std::cout << "argv[1] : csv filemane = " << argv[1] << std::endl;
+
+
+std::string ID_str, Effectif_str, Value_str;
+
+std::string::size_type sz = 0; // use to identify the endline
+while( ifs.good() )
+{
+ if(sz == 0) std::getline(ifs, ID_str, ',');
+// std::cout << ID_str << " " ;
+ ClassLabels.push_back( std::stof(ID_str) );
+
+ std::getline(ifs, Effectif_str, ',');
+ // std::cout << Effectif_str << " " ;
+ ClassEffectif.push_back( std::stof(Effectif_str) );
+
+ TimeSerieType tmpSerie;
+ int a;
+ do
+ {
+ std::getline(ifs, Value_str, ',');
+// std::cout << Value_str << " " ;
+ a= Value_str.find('\n');
+ tmpSerie.push_back( std::stof(Value_str, &sz) );
+ } while( a == -1 );
+// std::cout << std::endl;
+ ClassSeries.push_back( tmpSerie );
+ ID_str = Value_str.substr(sz+1); // " 2\n12" -> "12"
+}
+ifs.close();
+///////////////////////////////////////////////////////////////
+
+
+std::cout << " starting analysis " << std::endl;
+///////////////////////////////////////////////////////////////
+/// \brief compute k nearest neigboor of each entry (effectif > N)
+///////////////////////////////////////////////////////////////
+for(unsigned int i=0; i<ClassSeries.size(); i++)
+{
+
+ if( ClassEffectif[i] > N ) // if class's cardinal is > to N
+ {
+ std::vector< DistanceIndexType > DistanceToSeries(ClassSeries.size()) ; // we will use the current sample to validate (so sizes are the same)
+ unsigned int n= ClassSeries.size();
+ #pragma omp parallel for shared(DistanceToSeries)
+ for(unsigned int j=0; j<n; j++) // compute each distance
+ {
+ DistanceIndexType tmp;
+ tmp.first = ClassLabels[j];
+ tmp.second = EuclidianDistanceTimeSerie( ClassSeries[i], ClassSeries[j]);
+ DistanceToSeries[j] = tmp;
+ }
+
+ // now sort the vector DistanceToSeries according to ::second
+ std::sort(DistanceToSeries.begin(), DistanceToSeries.end(), DistancePairComp);
+
+ // copy 2 to K in a file
+ std::cout << " [" << ClassLabels[i] << "] : ";
+ for( unsigned int j=0 ; j<K; j++)
+ std::cout << DistanceToSeries[j].first << " - ";
+ std::cout << std::endl;
+ //std::cin.get();
+ }
+ else { std::cout << " [" << ClassLabels[i] << "] : X " << std::endl; }
+
+}
+
+return 0;
+}