# Optimization of storages capacity

Consider a series of storages where different goods are added into daily. I would like to optimize the distribution of these goods between the storages in a way which takes into account some conditions, which are expressed in function of some parameters and limits related to each storage. Of course, the storages are filled in a non uniform zero condition and the entry rate of the goods is different for each storage. Here it is my code attempt:

c = {one, two, three, four, five, six};(*name of containers/storages*)
p = {1, 1, 2, 1, 2, 2};(*storages parameters*)
kg = {3, 1.5, 1, 2, 1.5, 1};(*filling start*)
step = {0.2, 0, 0.05, 0.25, 0, 0};(*filling increment: note that goods increase is in one, three, four only*)
l = Flatten[{4, Times[#, 5] & /@ p[[2 ;;]]}];(*limits*)
data = DateObject[{2020, 2}];
Do[If[CurrentDate["Month"] > data, kg[[i]] = kg[[i]] + step[[i]],None], {i, 1,Length[kg]}]
(*Day or Month increment step processing: not strong (wrong) condition, which doesn't take into
account day by day/month by month increment. How to iterate it day by day, month by month?*)


The conditions which have to be respected are the following:

1. kg[[1]] <= l[[1]]
2. kg[[1]] + kg[[2]] <= l[[2]]
3. kg[[3]] <= l[[3]]
4. kg[[4]] <= l[[4]]
5. kg[[5]] <= l[[5]]
6. kg[[6]] <= l[[6]]


If even one of the above showed is not respected I would like to implement an automatic redistribution in the warehouses based on the greatest availability of these, considered as "the difference between the limit imposed and the current stock of goods" (the "" part is the ... code part which I cannot write).

Do[If[kg[[1]] <= l[[1]],
If[kg[[1]] + kg[[2]] <= l[[2]], None,
If[kg[[i]] <= l[[i]], None, ...], ...]], {i, 3,
Length[c]}] (*how to find the unrespected condition and automatically readdress the surplus
of kg within the container whose availability is the most one taking into account
availability[[i]]=limit[[i]]-kg[[i]] vector?*)