确定如何调度才能使m台机器上运行指定的n个作业的时间最短。
采用一个称为最长处理时间优先(Longest Processing Time first ,LPT)的调度策略,在LPT算法中,作业按他们所需处理时间的递减顺序排列。
由于在分配一个作业的时候,总要将其分配给最先变为空闲的机器,因此机器也按空闲的到来时刻生成一个递增序列。
//文件minheap.h
#include <iostream>
using namespace std;
struct MachineNode
{
int ID; //机器号
int Valid; //机器空闲时时间
};
struct JobNoe
{
int ID; //作业编号
int time; //作业持续时间
};
bool operator < (const JobNoe &a,const JobNoe &b)
{
return (a.time<b.time);
}
bool operator < (const MachineNode &a,const MachineNode &b)
{
return (a.Valid<b.Valid);
}
bool operator > (const JobNoe &a,const JobNoe &b)
{
return (a.time>b.time);
}
bool operator > (const MachineNode &a,const MachineNode &b)
{
return (a.Valid>b.Valid);
}
template <class T>
class MinHeap
{
private:
T *heap;
int CurSize;
int MaxSize;
public:
MinHeap(int maxsize=10)
{
MaxSize=maxsize;
CurS