Current location - Training Enrollment Network - Mathematics courses - C language programming in mathematical modeling
C language programming in mathematical modeling
The prerequisite of this question is not clear, so I try to give a description of the method, and the answer is based on the following assumptions:

1 and n workpieces arrive at the same time;

2. Any workpiece can be processed on any machine;

3. The processing time of the workpiece is known;

Basic idea:

The short work priority algorithm is adopted to minimize the total processing time.

For a detailed description of this algorithm, please refer to any book on operating system principles.

Solution steps:

1, sort the workpieces according to the processing time, and the one that needs the least time ranks first;

2. Set an array U with the size of m to represent the elapsed time of each machine;

3. Set an array n with the size of m, indicating the time required for each machine to process the current workpiece;

4. Set an array r with the size of m to represent the running time of each machine;

4. Set all elements of the array u, r and n to 0;

5. Do the following for each element in the workpiece data:

Find the element x with the smallest value from the array n;

Taking the value of each element in the array n minus the value of the element x as its new value;

Adding the value of each element in the array R and the value of the element X as its new value;

Setting the value of element X as the processing time required by the workpiece;

Modify the values in the array u: U[x]+=R[x]+N[x];

6. Sum the values of the elements in the array U to get the shortest total time.

Good luck!

-

The program is written in JAVA language, and the sorting operation is omitted, assuming that the number of machines is 3.

The public static void main(String[] arg) throws an exception.

{

int[] W=new int[]{ 1,2,3,55,56,77,77,88,99, 100 }; //Working time required for the workpiece

int[] U=new int[]{0,0,0 }; //The total time taken by each machine to process workpieces, including waiting time.

int[] R=new int[]{0,0,0 }; //Running time of each machine

int[] N=new int[]{0,0,0 }; //Time required for each machine to complete the current work.

for(int I = 0; I<w. Length; i++)

{

/* * Find the earliest available machine in the current machine, where m is the machine code and x is the time required for the machine to complete the current work */

int m = 0;

for(int j = 1; J<n. Length; j++)if(N[j]& lt; n[m])m = j;

int x = N[m];

//Take the value of each element in array N minus the value of element X as its new value;

//Add the value of each element in the array R with the value of element X as its new value;

for(int j = 0; J<n. Length; j++)

{

n[j]-= x;

r[j]+= x;

}

//Set the value of element X (that is, M machine) as the processing time required by the workpiece;

n[m]= W[I];

u[m]+=(R[m]+N[m]);

}

int total = 0;

for(int I = 0; I<u. Length; i++)total+= U[I];

System.out.println ("total time equals:"+total ");

}