LinkScheduleEstimator.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2005-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 }

Generated on Sat Sep 8 08:36:17 2007 for DTN Reference Implementation by  doxygen 1.5.3