1 Sets

advertisement
Sets, Summations, For statements
1
SA305: Spring 2013
Sets
• A set is a collections of elements/objects, e.g.
S = {1, 2, 3, 4, 5}
CandleTypes = {Santa, Tree, House}
(1)
• “in” symbol:
i∈N
⇔
“element i is in the set N ”
• For example:
2
Summations
• Summation symbol over sets:
X
⇔
“sum over all elements of N ”
i∈N
• For example:
• Common shorthand: if N = {1, 2, . . . , n}, then
X
X
is the same as
i∈N
i∈{1,2,...,n}
as well as
n
X
i=1
Problem 1. Let S, CandleTypes be defined as above in (1). Write each of the following as compactly as possible
using summation notation:
a. xSanta + xTree + xHouse
b. 1y1 + 2y2 + 3y3 + 4y4 + 5y5
X
X
xi
iyi
i∈S
i∈Candle
3
For statements
• “for” statements over sets:
for i ∈ N
⇔
for j ∈ CandleTypes
⇔
“repeat for each element of N ”
• For example:
c j x 1 + d j x 2 ≤ bj
1
• Common shorthand: if N = {1, 2, . . . , n}, then
“for i ∈ N ”
4
is the same as
“for i ∈ {1, 2, . . . , n}”
as well as
“for i = 1, 2, . . . , n”
Multiple indices
• Sometimes it may be useful to use decision variables with multiple indices
• Example:
– Set of hat types: H = {A, B, C}
– Set of factories: F = {1, 2}
– Each hat type can be be produced at each factory
– Define decision variables:
xi,j = number of type i hats produced at factory j
for i ∈ H and j ∈ F
(2)
– What decision variables have we just defined? How many are there?
xA1 , xA2 , xB1 , xB2 , xC1 , xC2 . There are six variables.
Problem 2. Using the decision variables defined in (2), write expressions for
a. Total number of type C hats produced
b. Total number of hats produced at facility 2
Use summation notation if possible.
X
X
xCj ,
xi2
j∈F
i∈H
• Suppose
ci,j = cost of producing one type i hat at factory j
for i ∈ H and j ∈ F
• If we produce xi,j hats of type i at factory j (for i ∈ H and j ∈ F ), the total cost is
XX
cij xij
i∈H j∈F
Problem 3. Let M = {1, 2, 3} and N = {1, 2, 3, 4}. Write following as compactly as possible using summation and
“for all” index notation.
Let y1 = amount of product 1 produced
y2 = amount of product 2 produced
y3 = amount of product 3 produced
y4 = amount of product 4 produced
a1,1 y1 + a1,2 y2 + a1,3 y3 + a1,4 y4 = b1
a2,1 y1 + a2,2 y2 + a2,3 y3 + a2,4 y4 = b2
a3,1 y1 + a3,2 y2 + a3,3 y3 + a3,4 y4 = b3
Let yj denote the amount of product j produced for j ∈ N . Let aij and bi be defined for i ∈ M and j ∈ N .
X
aij xj = bi , for i ∈ M .
j∈N
2
Problem 4. Recall the Farmer Brown cake linear program using the variables C and V for the chocolate and vanilla
cakes made.
max 3C + 5V
(profit)
s.t.
20C + 40V ≤ 260 (baking time)
4C + 2V ≤ 32
(eggs)
4C + 5V ≤ 40
(flour)
C, V ≥ 0
Reformulate this problem as compactly as possible using what you have learned.
Let C denote the set of cake types and R the set of resources used to make cakes. So C = {Chocolate,Vanilla} and
R = {time,eggs,flour}. Let pj denote the profit margin from cake type j for j ∈ C and ui denote the amount of
resource i available for i ∈ R. Let aij denote the amount of ingredient i used to make one cake of type j for i ∈ R
and j ∈ C. Finally, let xj denote the decision variable corresponding to the amount of cake type j for j ∈ C. Farmer
Brown makes. The formulation is then
max pj xj
j∈C
subject to
P
j∈C aij xj ≤ ui
xj ≥ 0
for i ∈ R
for j ∈ C.
Note that we can consider pj and ui as components of vectors p and u respectively (for j ∈ C and i ∈ R). We can also
consider aij as entries of a matrix A. These vectors and matrix are


20 40
p = (3, 5), u = (260, 32, 40), A =  4 2  .
4 5
What would change about your formulation if Farmer Brown decided to make 202 different kinds of cakes that used
up 738 different resources?
The set, C, would have 202 elements and the set R would have 738 elements. The p, u, and A would all have to
updated accordingly.
3
Download