0

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.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • Do you want an optimal scheduling scheme? or is the task schedule already given and you just have to implement it? – Abhishek Bansal Dec 19 '13 at 11:33
  • No I dont have to implement an optimal scheduling scheme.I just need to measure the time taken by this scheme when tasks are dependent on tasks on other lines. – user111972 Dec 19 '13 at 11:36
  • First calculate the start/finish times of 'independent' tasks. Then according to these time stamps, determine the times for dependent times. – Abhishek Bansal Dec 19 '13 at 11:38
  • Do you need to calculate it once to find a bottleneck, or every time? If only once then I would suggest profiling. Consult your linker's manual how to enable profiling and how to interpret the gathered data. – tebe Dec 19 '13 at 11:41
  • I dont want to profile.I wrote the code for when the tasks are independent.I need to modify it to include the scenario if a task depends on another task on a different line. – user111972 Dec 19 '13 at 11:43
  • I need to calculate many times – user111972 Dec 19 '13 at 11:48
  • A pretty naive approach, calculating the production time without considering throughput times (accumulating times for each task) . –  Dec 19 '13 at 11:51
  • @DieterLücking What do you mean by throughput time? Do you mean the sume of all the tasks' times on one line? If so,I am already doing this(if you see the code.)The ending time of the last or nth task on a line is actually the sum of all the tasks on that line. – user111972 Dec 19 '13 at 12:04
  • @user111972 There is a limit a task/line can handle (surly not an infinite number of jobs) –  Dec 19 '13 at 12:08
  • @DieterLücking limit on what? limit on the total predecessors of a task? or the total tasks assigned to a line? – user111972 Dec 19 '13 at 12:16
  • I have updated my question to include more details.Can you guys help me now? – user111972 Dec 19 '13 at 13:34
  • **Calculate Execution Time of a Code** http://stackoverflow.com/questions/1861294/how-to-calculate-execution-time-of-a-code-snippet-in-c – Hammad Dec 19 '13 at 13:45
  • @Hammad This is not what I am looking for.I need to calculate the max value from these lines. – user111972 Dec 19 '13 at 14:24

0 Answers0