批处理作业调度问题(分支限界法)

代码:

#include 

using namespace std;
const int MAX=100;
const int MACHINE=2;
int n;
int M[MAX][MACHINE];
int b[MAX][MACHINE];
int a[MAX][MACHINE];
int y[MAX][MACHINE];
int bestx[MAX];
int bestc;
struct Node
{
    int s;
    int f1;
    int f2;
    int sf2;
    int bb;
    int *x;
    bool operator < (const Node &node) const
    {
        return bb > node.bb;
    }
};
priority_queue pq;
void initNode(Node &node, int n)
{
    node.x = new int[n];
    int i;
    for(i=0; ii; k--)
                if(b[k][j]E.f2)?f1:E.f2) + M[E.x[E.s]][1];
    int sf2 = E.sf2 + f2;
    int s1 = 0, s2 = 0;
    int k1 = n - E.s,  k2 = n - E.s;
    int f3 = f2;
    for(j=0; jf1+b[j][0])?f2:f1+b[j][0];
            s1 += f1 + k1 * b[j][0];
        }
    for(j=0; js2?s1:s2);
}
int flowShop()
{
    sort();
    Node E;
    initNode(E, n);
    bestc = 1e6;
    while(E.s<=n)
    {
        if(E.s==n)
        {
            if(E.sf2 < bestc)
            {
                bestc = E.sf2;
                int i;
                for(i=0; i>n1;
    for(int i=0;i>M1[i][j];
    init(n1, M1);
    int best = flowShop();
    printf("最少完成时间和:%d\n", best);
    printf("最优调度:\n");
    for(int i=0; i


你可能感兴趣的