Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- execute {
- for (var t=1;t<=nTasks;t++) {
- num_of_threads = 0;
- for (var h=1;h<=nThreads;h++)
- num_of_threads += TH[t][h];
- num_threads_of_task[t] = num_of_threads;
- writeln("Task " + t + " has " + num_threads_of_task[t] + "threads");
- }
- };
- execute {
- for (var c=1;c<=nCPUs;c++) {
- num_of_cores = 0;
- for (var k=1;k<=nCores;k++)
- num_of_cores += CK[c][k];
- num_cores_of_cpu[c] = num_of_cores;
- writeln("CPU " + c + " has " + num_cores_of_cpu[c] + "cores");
- }
- };
- // Objective
- minimize z;
- subject to{
- // Constraint 1, todos hilos han de ser ejecutado en 1 solo core
- forall(h in H)
- sum(k in K) x_hk[h,k] == 1;
- // Constraint 2, todos hilos de una tarea han de ser asignados a los cores de un solo cpu
- forall(t in T)
- forall(c in C)
- sum(h in H) sum(k in K) TH[t,h] * CK[c, k] * x_hk[h, k] == num_threads_of_task[t] * x_tc[t,c];
- // Constraint 3, la carga de un core no puede superar a rc
- forall(c in C, k in K)
- if (CK[c, k] == 1)
- sum(h in H) rh[h] * x_hk[h,k] <= rc[c];
- // Constraint 4
- forall(c in C)
- z >= (1/(rc[c] * num_cores_of_cpu[c])) * sum(h in H) sum(k in K) rh[h] * CK[c, k] * x_hk[h,k];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement