BAPS/partitioning/TV/BAPTVPartitioner.h

00001 #include "def.h"
00002 #include "BAPPackage.h"
00003 #include "BAPPartitioner.h"
00004 #include "BAPTVSection.h"
00005 #include "BAPTVVessel.h"
00006 #include <LEDA/core/list.h>
00007 #include <LEDA/core/random_source.h>
00008 #include <sys/time.h>
00009 #include </usr/include/time.h>
00010 
00011 using leda::random_source;
00012 
00013 // Using LEDA's random source type
00014 typedef random_source Random;
00015 
00016 
00017 class BAPTVPartitioner : public BAPPartitioner
00018 {
00019 public:
00020    BAPTVPartitioner(BAPPackage& aPackage);
00021    ~BAPTVPartitioner();
00022 
00023    void Solve();
00024    // Debugging facility
00025    void Print(const int& aWidth = 1, const int& aDetail = 0) const;
00026 
00027 
00028 private:
00029    // I/O methods
00030    string Date() const;
00031    void PrintSummary() const;
00032    void ReadParameterFile();
00033    void WriteSolutionFile() const;
00034    void WriteTraceFile(string aStr) const;
00035    void WriteTraceFile(long aLong) const;
00036    void WriteTraceFile(long double aDouble) const;
00037 
00038    // Command-line methods
00039    // Initial solution generation methods
00040 
00041    // Abstractions
00042    void Assign(TVVessel& v, TVSection& s);
00043    void AssignVesselToRandomSection(TVVessel& v);
00044    void CalcInitialObjVal();
00045    unsigned long CalcObjVal() const;
00046    void ComputeObjVal(unsigned long& aTrans, unsigned long& aPenalty) const;
00047    void GenerateInitialSolution();
00048    void GenSolnRandom();
00049    inline bool GotMoreMoves() const;
00050    void InitSolution();
00051    void ResetVesselDestinations();
00052    void UpdatePackage() const;
00053 
00054    unsigned int TotalFlow(const int& v1, const int& v2) const;
00055    unsigned int TotalFlow(const TVVessel& v1, const TVVessel& v2) const;
00056    unsigned int D(const int& s1, const int& s2) const;
00057    unsigned int D(const TVSection& s1, const TVSection& s2) const;
00058 
00059    // Constants
00060    static const unsigned int  LONGDISTANCE = INFINITY;
00061    static const int           UNASSIGNED = -1;
00062 
00063    // Debug control
00064    unsigned int   mOutput;
00065    unsigned int   mPrintBucket;
00066    unsigned int   mPrintSections;
00067    unsigned int   mPrintVessels;
00068    unsigned int   mRuntimeAnalyzer;
00069    unsigned int   mSummary;
00070    string         mTraceFile;
00071 
00072    // Algorithm control
00073    timeval        mStartTime, mEndTime;
00074    int            mRandomSeed;
00075    unsigned int   mMaxPasses;
00076    unsigned int   mInitialSolnGenerator;
00077    bool           mSolnExists;
00078 
00079    // Information
00080    unsigned long  mTranshipment;
00081    unsigned long  mPenalty;
00082 
00083    // Data structures
00084    const int      mNumVes;
00085    const int      mNumSect;
00086    array<TVVessel>  mVes;
00087    array<TVSection> mSect;
00088    array2<int>    mTrans;
00089    array2<int>    mDist;
00090    set<int>       mUnallocVes;
00091    Random         mRandom;
00092 };
00093 

Generated on Tue Sep 9 15:40:10 2008 for BAP by  doxygen 1.5.3