How to solve this very complicated assignment problem
I don't see a way to solve this using standard algorithms for the assignment problem.

If you want an exact solution (i.e., the optimal solution), I would recommend integer linear programming (ILP).  You can introduce zero-or-one variables $x_{i,j,k}$, where $x_{i,j,k}=1$ means that item $i$ is placed in stack $j$ position $k$, and continuous variables $w_j$, where $w_j$ represents the width of stack $j$.

It's then not too hard to write down linear inequalities that capture all your requirements.  For instance, we have $\sum_{j,k} x_{i,j,k} = 1$ (each item is placed in one location) and $\sum_i x_{i,j,k} = 1$ (two items can't be placed in the same location; every position must be full) and $c_{i,k} - w_j \le M (1-x_{i,j,k})$ where $c_{i,k}$ is the width of item $i$ if placed in position $k$ and $M$ is a sufficiently large constant (this ensures that the $w$'s represent the stack widths correctly).  Then, you can minimize $\sum_j w_j$ with an off-the-shelf ILP solver.

I don't know how efficient it will be, or whether it will be adequate for online realtime calculation, but I suggest you give it a try and find out.

If it is too slow, there are some options.  One option is that some ILP solvers come with a way to impose a time limit; the solver tries to find the best solution it can within the time limit, with no guarantee that it will find the optimal solution.  Another option would be to try to craft some heuristic that doesn't necessarily yield the optimal solution, but is fast; maybe a greedy algorithm or something.  For instance, here is an off-the-cuff idea.  Associate with each item the smallest possible width it could have, among all the possible places it can be placed (out of the positions that remain open).  Pick the item with the largest associated value, and place it in the position that minimizes its width.  Update the associated values for all items, and repeat.  No guarantees about the quality of the solution, but this will be fast.  One could also use the smallest amount that it increases the total cost of the solution, out of all possible placements, rather than the smallest width, as the value associated with a particular item.