Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

SPeval.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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       //buffers go in here
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;  //for the O(nlogn) algo
00063       vector<unsigned> _reverseSeq2; //only for O(nlog n) algo
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       //fast are for the O(nlog n) algo
00095       double _findBST(unsigned index); //see the paper for definitions
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       //following are for evaluating with the O(nlog n) scheme
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       //miscelleneous functions
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 //using namespace parquetfp;
00160 
00161 #endif

Generated on Mon Apr 25 01:09:25 2005 for Parquete by doxygen 1.3.2