Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
vam=:1 :0
|
||||
:
|
||||
exceeding=. 0 <. -&(+/)
|
||||
D=. x,y exceeding x NB. x: demands
|
||||
S=. y,x exceeding y NB. y: sources
|
||||
C=. (m,.0),0 NB. m: costs
|
||||
B=. 1+>./,C NB. bigger than biggest cost
|
||||
mincost=. <./@-.&0 NB. smallest non-zero cost
|
||||
penalty=. |@(B * 2 -/@{. /:~ -. 0:)"1 - mincost"1
|
||||
R=. C*0
|
||||
while. 0 < +/D,S do.
|
||||
pS=. penalty C
|
||||
pD=. penalty |:C
|
||||
if. pS >&(>./) pD do.
|
||||
row=. (i. >./) pS
|
||||
col=. (i. mincost) row { C
|
||||
else.
|
||||
col=. (i. >./) pD
|
||||
row=. (i. mincost) col {"1 C
|
||||
end.
|
||||
n=. (row{S) <. col{D
|
||||
S=. (n-~row{S) row} S
|
||||
D=. (n-~col{D) col} D
|
||||
C=. C * S *&*/ D
|
||||
R=. n (<row,col)} R
|
||||
end.
|
||||
_1 _1 }. R
|
||||
)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
demand=: 30 20 70 30 60
|
||||
src=: 50 60 50 50
|
||||
cost=: 16 16 13 22 17,14 14 13 19 15,19 19 20 23 50,:50 12 50 15 11
|
||||
|
||||
demand cost vam src
|
||||
0 0 50 0 0
|
||||
30 0 20 0 10
|
||||
0 20 0 30 0
|
||||
0 0 0 0 50
|
||||
Loading…
Add table
Add a link
Reference in a new issue