Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the implementation of HEFT correct? #30

Open
peerdavid opened this issue Jun 6, 2019 · 1 comment
Open

Is the implementation of HEFT correct? #30

peerdavid opened this issue Jun 6, 2019 · 1 comment

Comments

@peerdavid
Copy link

Hello,

I think there are two problems with the current implementation of HEFT (findFinishTime):

        while (j >= 0) {
            Event current = sched.get(i);
            Event previous = sched.get(j);

            if (readyTime > previous.finish) {
                if (readyTime + computationCost <= current.start) {
                    start = readyTime;
                    finish = readyTime + computationCost;
                }

                break;
            }
            if (previous.finish + computationCost <= current.start) {
                start = previous.finish;
                finish = previous.finish + computationCost;
                pos = i;
            }
            i--;
            j--;
        }

(1) This loop assumes that sched is sorted by the start time right? But in this function we simply call sched.add such that a sorted list is no more guaranteed.
(2) In the code above we set the start time to the readyTime in one case. Shouldn't it be the previous.finish time? Otherwise it could. i.e. be that two tasks get the same start time...

Thank you, David

@peerdavid peerdavid changed the title Problem with HEFT Is the implementation of HEFT correct? Jun 6, 2019
@BrokenPen
Copy link

BrokenPen commented Apr 5, 2021

  1. The list is still in order by calling sched.add
  2. No two tasks get the same start time..

However... I found out if use in Random schedule algorithm this loop will have two tasks get the same start time....

so you have to make a little change.. like the follow

        for(int i = 0; i < sched.size() -1; i++) {
            Event current = sched.get(i);
            Event previous = sched.get(i+1);

            // case of between two task
            if (previous.finish <= readyTime) {
                if (readyTime + computationCost <= current.start) {
                    start = readyTime;
                    finish = readyTime + computationCost;
                    pos = i;
                    break;
                }
            }

            // the case of delay readyTime
            if (previous.finish + computationCost <= current.start) {
                if (readyTime <= previous.finish) {
                    start = previous.finish;
                    finish = previous.finish + computationCost;
                    pos = i;
                    break;
                }
            }
        }

if (readyTime >= sched.get(0).finish)
if (readyTime > previous.finish) {

I wonder why these two conditions are greater equal and another is greater
the condition become inconsistent
So I change these as always >= or <=


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants