I have a line object and each line object has an array of tasks associated with it.Each task has a start time and an end time.Each task also has a list of tasks which are its predecessors.
So if all the tasks were independent (no predecessors) I would just calculate the end time of the last task on each line which would be the end time of this line.The time taken by the production would be the maximum of the end time of all lines.
The problem is a task could be dependent on a task (which could be on the same or a different line). So if a task's predecessor is on the different line and its start time is greater than this task's start time,then this task's start time should be updated accordingly.
How can I calculate the correct production time given these predecessor tasks on different lines?
EDIT: This is what I have come up with so far.
Cluster {
func* func[n]
};
func {
int executiontime;
int starttime;
int endtime;
func* pred[k]
};
int main {
/Cluster objects were initialized up somewhere.
Cluster cl[4];//An array of four clusters
for(int i=0;i<4;i++) {
cl[i].func[0].starttime = 0;
cl[i].func[0].endtime = cl[i].func[0].starttime + cl[i].func[0].executiontime;
for(int j=1;j<n;j++) {
cl[i].func[j].starttime = cl[i].func[j-1].endtime;
cl[i].func[j].endtime = cl[i].func[j].starttime + cl[i].func[j].executiontime;
}
}
int productiontime=Max(cl[0].func[n].endtime,cl[1].func[n].endtime,cl[2].func[n].endtime,cl[3].func[n].endtime);
return productiontime;
}
This is what I have done so far.I am stuck at how to modify the code to account for the task predecessors.
EDIT:After the above loop,I would update the start and end times of each task whose predecessor task is on another line.If the predecessor task's start time is greater than this task's start time then this task's start and end time both would be updated.How should I do this when the problem is that predecessor task's start time might also need to be updated depending on its own predecessor tasks.