3
$\begingroup$

The Record-a-Song Company has contracted with a rising star to record eight songs. The durations of the songs are 8, 3, 5, 5, 9, 6, 7, and 12 minutes, respectively. Record-a-Song uses a two-sided cassette tape for the recording. Each side has a capacity of 30 minutes. The company would like to distribute the songs between the two sides so that the total length of the songs on each side is about the same. Formulate this problem as an integer programming problem. Clearly define your variables, objective and constraints.

I have labelled each side of the casssette X1 and X2 respectively and made them less than or equal to 30. And have also made it a minimisation problem. After this I am stuck. Please could someone help me

$\endgroup$
0
$\begingroup$

Perhaps something like this?

Let the songs be $1 ... 8$ and their lengths be $L_i$.

Let $a_i$ be $1,0$ if the $i$-th song is (is not) on side $A$.

Let $b_i$ be $1,0$ if the $i$-th song is (is not) on side $B$.

Then you can minimize

$$\left|\sum_{j=1}^8 L_j a_j - \sum_{j=1}^8 L_j b_j\right|$$

subject to the constraints

$$\sum_{j=1}^8 L_j a_j \leq 30,$$

$$\sum_{j=1}^8 L_j b_j \leq 30,$$

$$a_j, b_j = 0 \text{ or } 1, j = 1 ... 8$$

$$a_j + b_j = 1, j = 1 ... 8$$

The last constraint, along with the one right above it, says that a song must be on exactly one of side $A$ or side $B$ (not neither, not both).

If the absolute value is too cumbersome then you can make it go away by demanding that the time on side $A$ is longer than the total time on side $B$ (so the quantity must be non-negative). This is a matter of taste and convenience because you can specify which side is allowed to be longer without loss of generality.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.