Algorithm 我可以使用哪种算法将加权对象平均分布在n个部分?

Algorithm 我可以使用哪种算法将加权对象平均分布在n个部分?,algorithm,Algorithm,我想将x(I)对象(xe{1…n}),其中每个对象都有权重w(I),分配到n部分 分配的方式应确保所有部分的权重之和尽可能相等 干杯! Pratik计算重量的总和,除以n,即分量的数量,以获得所需的分量重量。然后使用a尝试填充此最大大小的n个垃圾箱 请注意,所有重量都必须小于零件重量才能正常工作。否则,您将无法在任何地方放置重量较大的物品。我认为您描述的是问题所在 下面是一个Julia实现: """ Solves the Multiprocessor Scheduling problem usi

我想将
x(I)
对象
(xe{1…n})
,其中每个对象都有权重
w(I)
,分配到
n
部分

分配的方式应确保所有部分的权重之和尽可能相等

干杯!
Pratik

计算重量的总和,除以n,即分量的数量,以获得所需的分量重量。然后使用a尝试填充此最大大小的n个垃圾箱


请注意,所有重量都必须小于零件重量才能正常工作。否则,您将无法在任何地方放置重量较大的物品。

我认为您描述的是问题所在

下面是一个Julia实现:

"""
Solves the Multiprocessor Scheduling problem using the Longest Processing Time algorithm

    PROBLEM: (NP-hard)
        Given:
            - set of jobs, each with a length
            - a number of processors
        Find:
            - divide the jobs among the processors such that none overlap
              which minimizes the total processing time

    ALGORITHM:
        - sort the jobs by processing time
        - assign them to the machine with the earliest end time so far
        Achieves an upper bound of 4/3 - 1/(3m) of optimal

    RETURNS:
        assignments, ith index → machine for the ith job
"""
function multiprocessor_scheduling_longest_processing_time{R<:Real}(
    jobs::AbstractVector{R},
    m::Integer, # number of processors
    )

    durations = zeros(R, m)
    assignments = Array(Int, length(jobs))

    for i in sortperm(jobs, rev=true) # p[1] is the index of the longest job in `jobs`
        best_index = indmin(durations)
        durations[best_index] += jobs[i]
        assignments[i] = best_index
    end

    assignments
end
“”“
使用最长处理时间算法解决多处理器调度问题
问题:(NP难)
鉴于:
-作业集,每个作业都有一个长度
-许多处理器
查找:
-在处理器之间划分作业,使其不重叠
这将使总处理时间最小化
算法:
-按处理时间对作业进行排序
-将它们分配到具有迄今为止最早结束时间的机器
实现了4/3-1/(3m)的最优值上限
返回:
作业,第i个索引→ 第i项工作的机器
"""

函数多处理器\u调度\u最长\u处理时间\u{您是否试图最小化任何两部分之间的最大差异、部分之间的平均差异或其他因素?一点预处理将解决这个问题-找到所需的部分重量,移除任何大于部分的重量,并将其放入自己的箱子中,然后运行箱子包装剩余n-k权重和n-k箱的算法。