#ifndef GRAF #define GRAF #include #include #include using namespace std; /** * class implementing a general node of a graph */ class Nod { public: /** * the node's id */ int id; /** * the node's corresponding cost */ double cost; /** * the number of predecessors */ int nr_pred; /** * the number of successors */ int nr_succ; /** * the list of predecesors */ void ** predecesori; /** * the list of successors */ void ** succesori; public: /** * the constructor * * @param i the id * @param c the cost */ Nod(int i = 0, double c = 0); /** * Method printing the node's information */ void print(); /** * Method adding a predecessor * * @param p the new predecessor */ void addPredecesor(void *p); /** * Method adding a successor * * @param s the new successor */ void addSuccesor(void * s); }; /** * class implementing a node of a tasks graph */ class Task:public Nod { public: /** * the minimum topological level */ int niv_topo_min; /** * the maximum topological level */ int niv_topo_max; /** * the current topological level */ int niv_topo; /** * the id of the associated processor */ int procesor_id; /** * the start moment for the current task */ int start; /** * the stop moment for the current task */ int stop; public: /** * the constructor * * @param i the id * @param c the cost */ Task(int i = 0, double c = 0); /** * Method that assocites to the current task a processor scheduling it to be executed between "st" and "fin" * * @param id the id of the associated processor * @param st the start moment * @param fin the stop moment */ void setProcesor(int id,int st, int fin); /** * the default initialization */ void init(); /** * method printing the task's information */ void print(); }; /** * class implementing a node of a processors graph */ class Procesor:public Nod { public: /** * the total number of tasks we want to schedule */ int nr_tasks; /** * the total number of processors we can use */ int nr_procs; /** * the queue of associated tasks */ int * queue; /** * current time used in the fitness computation */ int time; /** * the list containing the communication costs with neighbours */ int * cost_comm; public: /** * the constructor * * @param i the processor's index * @param c the processor's cost */ Procesor(int i = 0, int c = 0); /** * Method adding a task in the tasks queue * * @param task_id the index of the task we add in the list */ void addTask(int task_id); /** * Method initializing a processor to the default values */ void init(); /** * method adding the communication costs for the specified number of processors * * @param v the list of communication costs * @param n the number of processors */ void addCosts(int v[], int n); /** * Method printing the processor's information */ void print(); }; /** * class implementing a graph edge */ class Muchie { public: /** * the predecessor node */ Nod * predecesor; /** * the successor node */ Nod * succesor; /** * the edge's communication cost */ double cost; public: /** * the constructor * * @param p the predecessor node * @param s the successor node * @param c the edge's communication cost */ Muchie(Nod * p = NULL, Nod * s = NULL, double c = 0); /** * Method printing the edge's information */ void print(); }; /** * class implementing a graph */ class Graf { public: /** * the nodes list */ Nod * noduri; /** * the edges list */ Muchie * muchii; /** * the number of nodes */ int nr_noduri; /** * the number of edges */ int nr_muchii; public: /** * the constructor * * @param n the number of nodes * @param m the number of edges */ Graf(int n = 0, int m = 0); /** * the constructor * * @param filename the input filename */ Graf(char * filename); /** * method printing the graph's information */ void print(); /** * copy operator */ Graf& operator=(const Graf& clone); }; /** * class implementing a graph of tasks */ class TaskGraf: public Graf { public: /** * the list of nodes (tasks) */ Task * noduri; /** * the maximum topological level */ int max_level; /** * the list of floating nodes */ vector f_nodes; public: /** * method initializing a graph of tasks to the structure specified in the file * * @param filename the input filename containing the configuration */ void init(char * filename); /** * the constructor * * @param n the number of tasks * @param m the number of communication links */ TaskGraf(int n = 0, int m = 0); /** * method that computes the topological sort * * @return the maximum topological level */ int sortare_topologica(); /** * method that computes the reverse topological sort */ void sortare_topologica_inversa(); /** * method that computes the list of free floating nodes */ void computeFreeFloatingNodes(); /** * method that initializes the structure with the default configuration */ void init(); /** * method that computes the topological sort */ void sort_topo(); /** * method that prints the information about the graph of tasks */ void print(); /** * the copy operator */ TaskGraf& operator=(const TaskGraf& clone); }; /** * class implementing a graph of processors */ class ProcesorGraf: public Graf { public: /** * the list of processors */ Procesor * noduri; public: /** * method initializing a graph of processors to the structure specified in the file * * @param filename the input filename containing the configuration */ void init(char * filename); /** * the constructor * * @param n the number of processors * @param m the number of communication links */ ProcesorGraf(int n = 0, int m = 0); /** * method that initializes the structure with the default configuration */ void init(); /** * method that prints the information about the graph of processors */ void print(); /** * the copy operator */ ProcesorGraf& operator=(const ProcesorGraf& clone); }; #endif