Skip to content
Snippets Groups Projects
parameter.h 7.54 KiB
#ifndef PARAMETER_H
#define PARAMETER_H

#include <chrono>
#include <map>
#include "templates.h"

///Contains application command line arguments.
class parameter
{
public:
	vtr<std::string> arguments;		///< Contains command line arguments

	//file input/output parameters
	vtr<std::string> inPath;		///< Contains file input paths from which are loaded and parsed analyzed input data (-in)
	vtr<std::string> inQuery;		///< Contains file input paths from which are loaded and parsed analyzed query input data (-query)
	vtr<std::string> inKeyInput;	///< Contains file input paths from which are loaded and parsed analyzed secondary input data (-dist 4, -in2)
	vtr<std::string> inKeyQuery;	///< Contains file input paths from which are loaded and parsed analyzed secondary query input data (-dist 4, -query2)
	std::string inGroundTruthPath;	///< Contains ground truth file path (-gt)
	std::string outputPath;			///< Contains path for output files (-out)
	std::string outDraw;			///< Contains path for graphic output files (-draw)
	bool drawMin;					///< if true: local minimums will be included in graphic visualization of the distance matrix (-dmin)
	bool drawFlex;					///< if true: flexible warping pass will be included in graphic visualization of the distance matrix (-dflex)
	int drawSleep;					///< sleep n milliseconds after picture is written to the disk (-dsleep)
	bool forceSingle;				///< if true: input_data_single is used even if query data are specified (-signle).

	bool out_gdf;                   ///< if true: gdf output will be generated (-gdf)
	bool out_html;					///< if true: html output will be generated (-html)
	
	//print output pararameters
	int precision;					///< Sets floating precision for console outputs (-p)
	bool time;						///< if true: time measurements will be printed (-time)
	bool printOutput;				///< if true: standard outputs will be printed (-pout)
	bool debugInfo;					///< if true: more detailed information will be printed during operation. Used for debug purposes (-debug)
	
	bool shift;						///< if true: during distance matrix generation point dimension are rotated (-shift)
	bool scoreReversed;				///< if true: score should be reversed from 0,1 to 1,0. (-reverse) WARNING: not all scores are compatible with this  
	bool localAlignment;			///< if true: local alignment will be used for warping path search (Kocyan).
	
	
	//experimental options
	int block;						///< Sets size of block for tilting optimization (-block) EXPERIMENTAL
	bool tmp_exp;					///< if true: temporal
	bool experiment;				///< if true: run experimental code (development). EXPERIMENTAL
	bool simd;						///< if true: SIMD instructions are used for distance matrix calculation (-simd) EXPERIMENTAL
	bool memoization;				///< if true: memoization optimization technique will be used for distance matrix calculation (-mem) EXPERIMENTAL
	bool lowerBound;				///< if true: Keogh's lower bound will be used for query operation (-lb) EXPERIMENTAL
	
	std::string method;				///< Specifies used method: dtw, lcss (-m)	
	int operation;					///< Specifies operation type (-op)
	int distance;					///< Specifies distance function type (-dist)
	int scoreType;					///< Specifies score type (-s)
	int ram;						///< Sets maximal RAM used for distance matrix (-ram MBs, default: 5000MB)
	int clusters;					///< Sets number of clusters at which pdtw algorithm stops in the operation 5 (-clu)
	int ve_window;					///< Sets voting experts length per vote (Kocyan) (-velen)
	int ve_smooth;					///< Set smoothing window width when segmenting time series by voting experts algorithm (-smooth)

	//result options
	double w;						///< Sets warping windows width for dtw method (-w size) 
	int fw;							///< Sets flexible warping pass width (Kocyan) (-fw size)
	int fd;							///< Sets flexibility parameter for flexible warping pass (Kocyan) (-fd size)
	double delta;					///< Sets delta paramter for lcss method (-d size)
	double epsilon;					///< Sets epsilon parameter for lcss method (-e size)
	double subsequence;				///< Sets minimal time series length difference (ratio) for subsequence to be used (-sub size) 
	double treshold_csi;			///< threshold: minimal tone value in chroma distance (-d 3, -tcsi size)
	double treshold_t;				///< threshold: maximal allowed threshold warping path value (Kocyan) (-tt size)
	double treshold_a;				///< threshold: maximal allowed average warping path value (Kocyan) (-ta size)
	double treshold_e;				///< threshold: maximal allowed warping path point value (Kocyan) (-te size)
	double treshold_l;				///< threshold: maximal allowed warping path length (Kocyan custom) (-tl size)
	//int recall;					///< first top x
	int relax;						///< Specifies relaxation for dtw method: how much can start/end of alignment move from first/last cell of distance matrix (-relax size)
	
	//data preprocessing options	
	int pre_paa;					///< if set: input time series will be reduced by piecewise aggregate approximation (-paa "width")
	int pre_reduce;					///< if set: input time series will be reduced by skipping elements for length reductions (-r skip, 2: every 2. element is taken, 3: every 3. el. is taken, ...)
	int pre_sax;					///< if set: input time series will be preprocessed by symbolic approximation (-sax levels) 
	int pre_prolong;				///< if set: input time series will be prolonged by interlacing (-pr times)
	int pre_smooth;					///< if set: input time series will be smoothed by moving window averages (-smooth size) 
	bool pre_interpolate;			///< if true: input time series will be interpolated to the same length (-i)
	bool pre_normalizeZ;			///< if true: input time series will be z-normalized (-nz)
	int pre_normalizeBy;			///< if set: input time series will be 01-normalized (-nby value)

	//parallelization options  
	int omp;						///< sets number of threads used for similarity matrix parallelization.

	parameter() :
		arguments(),
		inPath(), inQuery(), inKeyInput(), inKeyQuery(), inGroundTruthPath(), outputPath(), outDraw(),
		drawMin(false), drawFlex(false), drawSleep(0), forceSingle(false),
		out_gdf(false), out_html(false),
		precision(3), time(false), printOutput(false), debugInfo(false),
		shift(false), scoreReversed(false), localAlignment(false),
		block(0), tmp_exp(false), experiment(false), simd(false), memoization(false), lowerBound(false),
		method("dtw"), operation(1), distance (1), scoreType(0), ram(5000), clusters(1), ve_window(0), ve_smooth(0),
		w(1), fw(0), fd(1), delta(100000), epsilon(1), subsequence(0), treshold_csi(0.07), treshold_t(10), treshold_a(10), treshold_e(10), treshold_l(3),
		/*recall(10),*/	relax(0),
		pre_paa(1), pre_reduce(0), pre_sax(0), pre_prolong(0), pre_smooth(0), pre_interpolate(), pre_normalizeZ(), pre_normalizeBy(-1),
		omp(1)
		{};

	void setParameters(vtr<std::string> const &args);
	std::map<std::string, std::string> mapParameters(vtr<std::string> const &args);
	void useParameters(std::map<std::string, std::string> &mapSetting);
	//static std::string mapOptionalParameter(vtr<std::string> const &args, size_t idx, std::string param_default);
	//static std::string mapMultiParameter(vtr<std::string> const &args, int idx);
	void checkUnknownParameters();
	void checkParameters(std::map<std::string, std::string> const &mapSetting);
	static vtr<std::string> applyParameter(vtr<std::string> &args, vtr<std::string> const &argsPriority);
	static void printHelp();

	bool isGroundTruth() const;	
	bool isWriteOutput() const;	 
	bool isQuery() const;		 
	bool isReduce() const;		 
	bool isPaa() const;			 
	bool isOmp() const;			 
	bool isSubsequence() const;	 
	bool isSax() const;			 
	bool isSecondaryInput() const; 
	bool isPassFlexible() const; 
	bool isNormalizeBy() const;		
};

#endif //PARAMETER_H