00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef SPEVAL_H
00038 #define SPEVAL_H
00039
00040 #include <fstream>
00041 #include <iostream>
00042 #include <vector>
00043 #include <map>
00044 #include <algorithm>
00045 #include <math.h>
00046 #include <stdlib.h>
00047 using namespace std;
00048
00049 namespace parquetfp
00050 {
00051 class SPeval
00052 {
00053 private:
00054
00055 vector<unsigned> _match;
00056 vector<double> _LL;
00057 vector<unsigned> _reverseSeq;
00058 vector<unsigned> _XX;
00059 vector<unsigned> _YY;
00060 vector<double> _heights;
00061 vector<double> _widths;
00062 map<unsigned , double> _BST;
00063 vector<unsigned> _reverseSeq2;
00064
00065 vector< vector<bool> > _TCGMatrixHoriz;
00066 vector< vector<bool> > _TCGMatrixVert;
00067
00068 double _lcsCompute(const vector<unsigned>& X,
00069 const vector<unsigned>& Y,
00070 const vector<double>& weights,
00071 vector<unsigned>& match,
00072 vector<double>& P,
00073 vector<double>& L
00074 );
00075
00076 double _lcsReverseCompute(const vector<unsigned>& X,
00077 const vector<unsigned>& Y,
00078 const vector<double>& weights,
00079 vector<unsigned>& match,
00080 vector<double>& P,
00081 vector<double>& L
00082 );
00083
00084 double _lcsComputeCompact(const vector<unsigned>& X,
00085 const vector<unsigned>& Y,
00086 const vector<double>& weights,
00087 vector<unsigned>& match,
00088 vector<double>& P,
00089 vector<double>& L,
00090 vector<double>& oppLocs,
00091 vector<double>& oppWeights
00092 );
00093
00094
00095 double _findBST(unsigned index);
00096 void _discardNodesBST(unsigned index, double length);
00097
00098 double _lcsComputeFast(const vector<unsigned>& X,
00099 const vector<unsigned>& Y,
00100 const vector<double>& weights,
00101 vector<unsigned>& match,
00102 vector<double>& P,
00103 vector<double>& L
00104 );
00105
00106
00107 bool _TCGMatrixInitialized;
00108 void _initializeTCGMatrix(unsigned size);
00109 bool _paramUseFastSP;
00110
00111 public:
00112 vector<double> xloc;
00113 vector<double> yloc;
00114 double xSize;
00115 double ySize;
00116 vector<double> xSlacks;
00117 vector<double> ySlacks;
00118 vector<double> xlocRev;
00119 vector<double> ylocRev;
00120
00121
00122 SPeval(const vector<double>& heights,
00123 const vector<double>& widths,
00124 bool paramUseFastSP);
00125
00126
00127 void evaluate(const vector<unsigned>& X, const vector<unsigned>& Y);
00128 double xEval();
00129 double yEval();
00130 void evalSlacks(const vector<unsigned>& X, const vector<unsigned>& Y);
00131 double xEvalRev();
00132 double yEvalRev();
00133
00134 void evaluateCompact(const vector<unsigned>& X,
00135 const vector<unsigned>& Y,
00136 bool whichDir);
00137 double xEvalCompact();
00138 double yEvalCompact();
00139 void computeConstraintGraphs();
00140 void removeRedundantConstraints(bool knownDir);
00141 void computeSPFromCG();
00142
00143
00144 void evaluateFast(const vector<unsigned>& X, const vector<unsigned>& Y);
00145 double xEvalFast();
00146 double yEvalFast();
00147 void evalSlacksFast(const vector<unsigned>& X, const vector<unsigned>& Y);
00148 double xEvalRevFast();
00149 double yEvalRevFast();
00150
00151
00152 void changeWidths(const vector<double>& widths);
00153 void changeHeights(const vector<double>& heights);
00154 void changeNodeWidth(const unsigned index, double width);
00155 void changeNodeHeight(const unsigned index, double height);
00156 void changeOrient(unsigned index);
00157 };
00158 }
00159
00160
00161 #endif