00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <vector>
00018 #include <oasys/util/IntUtils.h>
00019 #include <oasys/debug/Log.h>
00020
00021 #define CONTACT(s, d) { s, d }
00022 #define absdiff(x,y) ((x<y)?((y)-(x)):((x)-(y)))
00023
00024 #define WARPING_WINDOW .02
00025 #define PERIOD_TOLERANCE .02
00026 #define MAX_DIST 1<<30
00027
00028 namespace dtn {
00029
00046 class LinkScheduleEstimator : public oasys::Logger {
00047 public:
00048 typedef struct {
00049 unsigned int start;
00050 unsigned int duration;
00051 } LogEntry;
00052
00053 typedef std::vector<LogEntry> Log;
00054
00055 static Log* find_schedule(Log* log);
00056
00057 LinkScheduleEstimator();
00058 private:
00059 unsigned int entry_dist(Log &a, unsigned int a_index, unsigned int a_offset,
00060 Log &b, unsigned int b_index, unsigned int b_offset,
00061 unsigned int warping_window);
00062
00063 unsigned int log_dist_r(Log &a, unsigned int a_index, unsigned int a_offset,
00064 Log &b, unsigned int b_index, unsigned int b_offset,
00065 unsigned int warping_window);
00066
00067
00068 unsigned int log_dist(Log &a, unsigned int a_offset,
00069 Log &b, unsigned int b_offset,
00070 unsigned int warping_window, int print_table);
00071
00072 unsigned int autocorrelation(Log &log, unsigned int phase, int print_table);
00073 void print_log(Log &log, int relative_dates);
00074
00075 Log* generate_samples(Log &schedule,
00076 unsigned int log_size,
00077 unsigned int start_jitter,
00078 double duration_jitter);
00079
00080 unsigned int estimate_period(Log &log);
00081 unsigned int seek_to_before_date(Log &log, unsigned int date);
00082 unsigned int closest_entry_to_date(Log &log, unsigned int date);
00083 Log* clone_subsequence(Log &log, unsigned int start, unsigned int len);
00084
00085 unsigned int badness_of_match(Log &pattern,
00086 Log &log,
00087 unsigned int warping_window,
00088 unsigned int period);
00089
00090 Log* extract_schedule(Log &log, unsigned int period_estimate);
00091 unsigned int refine_period(Log &log, unsigned int period_estimate);
00092 Log* find_schedule(Log &log);
00093 };
00094
00095
00096 }