// \****************************************************** // Copyright 1998 University of Paderborn // // FILE : SA_Problem.h // // includes : mpi.h, iostream.h // is included by : user // // Headerfile template of an interface to the parSA-Library // Has to be changed by the user. See SA_Problem.cc for more // detailed information about the methods. // // authors: // Georg Kliewer, Peter Unruh // contact: // parsa@uni-paderborn.de // last update: // 11.11.1998 // // \****************************************************** #ifndef SA_Problem_H #define SA_Problem_H //#include #include #ifdef MPI #include #endif class SA_Problem; // forward declaration // \****************************************************** // class SA_Solution : // - contains a SA_Solution // - can copy a SA_Solution in itsself // // class MUST be implemented by the user // \****************************************************** class SA_Solution { friend class SA_Problem; public: // ----- BASIC functions ------------------------------- void Copy(SA_Solution & source); }; std::ostream & operator <<(std::ostream &, SA_Solution &); // \****************************************************** // class SA_Move : // - contains a move // // class CAN be implemented by the user // \****************************************************** class SA_Move { public: //----- constructor --------------------------------- SA_Move(); ~SA_Move(); SA_Move(SA_Problem &); friend class SA_Problem; }; // std::ostream & operator << (std::ostream &, SA_Move &); // \****************************************************** // class SA_Problem : // - representation of the SA_Problem // - generates initial SA_Solution // - neighborhood operation // - cost function // // class MUST be implemented by user // \****************************************************** class SA_Problem { public: // ----- constructor / destructor ---------------------- SA_Problem(); ~SA_Problem(); // method recieved the command line parameters, without -cfg and MPI Options // is called after Solver instanciation from SA_Initializer void EvaluateOptions(int *argc,char ***argv); // ----- methods for SEQUENTIAL SA --------------------- int ReadProblemData(char *); SA_Solution * CreateSolution(); void GetInitialSolution(SA_Solution &); void GetRandomSolution(SA_Solution &); float GetCost(SA_Solution &); void GetNeighbor(SA_Solution &, float rel_temp); void ResetSolution(SA_Solution &); void UpdateSolution(SA_Solution &); float GetLocalN(); float GetGlobalN(); void Copy(SA_Solution & source, SA_Solution & dest); // ----- methods for PARRALLEL SA ---------------------- // ----- stream based communication -------------- void OutputSolution(std::ostream&, SA_Solution &); int InputSolution(std::istream &,SA_Solution &); // ----- MPI based communication ----------------- #ifdef MPI int BcastSolution(SA_Solution &sol, int root, MPI_Comm comm, int me_comm); #endif // ----- ADDITIONAL methods ---------------------------- // ----- for using moves ... ------------------------- SA_Move * CreateMove(); int ExtractMove(SA_Solution &, SA_Move &); int ApplyMove(SA_Solution &, SA_Move &); // ----- ...with stream based communication --------- void OutputMove(std::ostream &, SA_Move &); int InputApplyMoves(std::istream &, SA_Solution &); // ----- ... with MPI based communication ----------- #ifdef MPI int BcastApplyMove(SA_Solution &sol, int root, MPI_Comm comm, int me_comm); #endif // ----- file-IO methods ------------------------------- int OutputSolution(char * filename,SA_Solution & sol); int InputSolution(char * filename,SA_Solution & sol); // Liefert Anzahl der Durchgefuehrten Schritten oder 0, falls Fehler // ----- service methods for more complex applications - void Postprocessing(SA_Solution &); int Reoptimize(SA_Solution &); void ControlOutput(std::ostream & out = std::cout); }; #endif