September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -9,10 +9,10 @@ var demand = :(A => 30, B => 20, C => 70, D => 30, E => 60)
|
|||
var supply = :(W => 50, X => 60, Y => 50, Z => 50)
|
||||
|
||||
var cols = demand.keys.sort
|
||||
var res = :(); costs.each {|k| res{k} = :() }
|
||||
var g = :(); supply.each {|x| g{x} = costs{x}.keys.sort_by{|g| costs{x}{g} }}
|
||||
|
||||
demand.each {|x| g{x} = costs.keys.sort_by{|g| costs{g}{x} }}
|
||||
var (:res, :g)
|
||||
supply.each {|x| g{x} = costs{x}.keys.sort_by{|g| costs{x}{g} }}
|
||||
demand.each {|x| g{x} = costs .keys.sort_by{|g| costs{g}{x} }}
|
||||
|
||||
while (g) {
|
||||
var d = demand.collect {|x|
|
||||
|
|
@ -23,13 +23,8 @@ while (g) {
|
|||
[x, var z = costs{x}{g{x}[0]}, g{x}[1] ? costs{x}{g{x}[1]}-z : z]
|
||||
}
|
||||
|
||||
with (d.max_by { .[2] }) { |dmax|
|
||||
d.grep! { .[2] == dmax[2] }.min_by! { .[1] }
|
||||
}
|
||||
|
||||
with (s.max_by { .[2] }) { |dmax|
|
||||
s.grep! { .[2] == dmax[2] }.min_by! { .[1] }
|
||||
}
|
||||
d.grep! { .[2] == d.max_by{ .[2] }[2] }.min_by! { .[1] }
|
||||
s.grep! { .[2] == s.max_by{ .[2] }[2] }.min_by! { .[1] }
|
||||
|
||||
var (t,f) = (d[2] == s[2] ? ((s[1], d[1])) : ((d[2], s[2])))
|
||||
(d,s) = (t > f ? ((d[0], g{d[0]}[0])) : ((g{s[0]}[0],s[0])))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue