Say I have two orders ABCDE and EDCBA, and I want to change from one to the other. But I can only exchange two groups of orders at one time, with associated cost per group.
So in this case, I can go from (A)(BCDE) to (BCDE)(A) to (B)(CDE)A to (CDE)(B)(A) to (C)(DE)BA to (DE)(C)(B)(A) to EDCBA, and the cost would be cost(A)*cost(BCDE) + cost(B)*cost(CDE) + cost(C)*cost(DE) + cost(D)*cost(E)
In other case, if I want to go from ABCD to CDBA, I could have (AB)(CD) to (CD)(BA) in one step with cost(AB)*cost(CD).
I want to ask what algorithms can I use to (1) minimize the steps it take to transform one order to the other and (2) what if I also want to minimize the cost? (minimized cost not necessarily implies minimized steps)