How to solve these optimization problems?

82 Views Asked by At

Hey I seem to have trouble solving optimization problems and I'm stuck on these two. I was wondering if anyone can help point me to the right direction. Also, are any resources or advice to help improve optimization problems in general?

  1. Arnold has n items arranged in a row. Each items has one of 100 different ids (0 to 99). He wants to mix all these items together. At each step, he mixes two items that stand next to each other, and puts the resulting item in their place. When mixing two items a and b, the resulting item will have $id\equiv (a+b)\pmod n$ st n = 100. Also, the amount of broken code generated when mixing two items of a and b is $a*b$. Find out what is the minimum amount of error that Arnold can get when mixing all the items together.

  2. Dan made a processor on which n tasks are to be run. As soon as one task finishes running, the next one can start. Each task j has a length $l_j$ giving the amount of time that the task takes to run and a weight $w_j$ giving the importance of the task. Define the completion time $c_j$ of a task j as the total time that elapses before task j finishes running. For example, if we run task 1 that has length 3 and then task 2 that has length 5, then the completion time of task 1 is 3, and the completion time of task 2 is 3+5=8. The goal is to minimize: $\sum_{j=0}^n$ $w_j*c_j$.

Note: I didn't know if this was supposed to be posted on math or cs se. I posted it here since I couldn't find a way to even solve it with a mathematical approach and I thought it was more appropriate here but if it doesn't belong here, just tell me and I will remove it.