Path: blob/main/Homework/Lesson 03 HW - LP3/Homework_03.ipynb
871 views
Homework 3
When asking questions about homework in Piazza please use a tag in the subject line like HW1.3 to refer to Homework 1, Question 3. So the subject line might be HW1.3 question. Note there are no spaces in "HW1.3". This really helps keep Piazza easily searchable for everyone!
For full credit, all code in this notebook must be both executed in this notebook and copied to the Canvas quiz where indicated.
Hints for 1-3
This is an unbalanced transportation problem. Don't address the imbalance by adding "dummies", instead adjust the constraints as discussed in the lesson.Questions 1-3
This problem is related to the self-assessment question in the lesson titled "Unbalanced Transportation Problem" and is modeled after a problem found in Practical Management Science by Wayne L. Winston and S. Christian Albright.
International Textile Company, Ltd, Kong–based firm that distributes textiles world- wide. They have mills for weaving bolts of cotton fabric in the Bahamas, Hong Kong, Korea, Nigeria, and Venezuela. The mills ship bolts of cotton to distribution eight distribution centers (listed below).
The company is owned by the Lao family. Present plans are to remain in Hong Kong through the transition in governments. Should the People’s Republic of China continue its economic renaissance, the company hopes to use its current base to expand operations to the mainland. International Textile has mills in the Bahamas, Hong Kong, Korea, Nigeria, and Venezuela, each weaving fabrics out of two or more raw fibers: cotton, polyester, and/or silk. The mills service eight company distribution centers. Cotton supplies and demands at the distribution center are shown below. Shipping costs depend on both distances and other factors and are in the cell below.
Additionally, the company is switching to a different shipping method with a limit of 500 cotton bolts on each route. Moreover, shipments from Venezuela to the United States will no longer be possible (no shipments to Los Angeles, Chicago, and New York). Note that you'll have to set up this constraint yourself. We haven't provided data or code for it.
Question 1 (8 points, manual)
This transportation problem is unbalanced. Write Pyomo code to find the minimum shipping cost. Solve the problem without introducing any dummy mills or distribution centers. Include your complete, abstract, Pyomo code in the cell below and in your CoCalc notebook. Your code should output a data frame that displays the shipping amounts. Here is some problem data to get you started:
Question 2 (1 point, auto)
What is the minimum total shipping cost? Enter your answer to the nearest dollar.
Question 3 (1 point, auto)
To achieve the minimum total shipping cost, how many bolts should be shipped from Korea to Manila?
Hints for 4-7
This problem is both unbalanced and needs route capacity constraints. Additionally, you'll need three indices for your decision variables;Something like this: `model.transp = Var(products, warehouses, stores, domain=NonNegativeReals)`
You'll also need to adjust the loops to construct the objective function and the constraints to account for the additional index.
Make sure to study the section in Lesson 3 named "Transporting Multiple Products"
Questions 4-6
Each of three warehouses has two products, pA and pB, in stock to send to five different stores. Each route from a warehouse to a store has a limited capacity of 700 products (total of pA and pB) or there is no shipping available on that route. The unit shipping cost on each route doesn't depend on the product. For example, it costs $14/unit to ship product pA or pB from warehouse wA to store sA. Supply, demand, costs, and capacities, are loaded into data frames below for your convenience. To access values in the data frame: cost.loc['wA','sC']
gives 12.
Review the material in the lesson about multiple products as needed.
Here is the problem data to get you started (you'll need to import pandas as pd):
Question 4 (10 points, manual)
Include your Pyomo code for minimizing the total shipping cost below. Your code should also be complete and executed in your CoCalc notebook.
Question 5 (1 point, auto)
What is the minimum total shipping cost? Enter your answer to the nearest dollar.
Question 6 (1 point, auto)
To achieve the minimum total shipping cost how many of product A should be shipped from warehouse C to store C?
Hints for 7-9
This is an unbalanced assignment problem. You can either use a "dummy" stroke similar to how a "dummy" machinewas used in the lesson or you can change one of the supply or demand constraints from "=" to "<=" or ">=" appropriately.
Questions 7-9
The coach of an age group swim team needs to assign swimmers to a 200-yard medley relay team to send to the Junior Olympics. Since most of his best swimmers are very fast in more than one stroke, it is not clear which swimmer should be assigned to each of the four strokes. The five fastest swimmers and the best times (in seconds) they have achieved in each of the strokes (for 50 yards) are
The coach wishes to determine how to assign four swimmers to the four different strokes to minimize the sum of the corresponding best times.
Question 7 (8 points, manual)
Treat this as an assignment problem and use Pyomo to find the optimal solution. For full credit you must use an abstract approach to the solution code and display nicely formatted output. Include complete, executed code in your CoCalc notebook.
Question 8 (1 point, auto)
What is the minimum total race time? Enter your answer to the nearest tenth of a second.
Question 9 (1 point, auto)
Which swimmer is assigned to swim backstroke?
Hints for 10-12
It's important to understand that the way the precedence constraints are laid out is the oppositeof how they're displayed in the lesson. You can either reverse the precendents
to align with the lesson example or you can leave use the precedents as they're laid out below
and reverse the "before" and "after" in the lesson code.
Questions 10-12
Reliable Construction wants to determine when each activity should start in a construction schedule in order to minimize the overall time it takes to construct a large commercial building. The tasks, order of tasks, and their durations in days are specified in the table below.
Remember that we need to append a final task that has all other tasks as immediate predecessors and an estimated duration of zero days.
Activity | Description | Immediate Predecessors | Estimated Duration |
---|---|---|---|
A | Excavate | -- | 14 |
B | Lay the Foundation | A | 21 |
C | Put up the rough wall | B | 63 |
D | Put up the roof | C | 35 |
E | Install the exterior plumbing | C | 42 |
F | Install the interior plumbing | E | 56 |
G | Put up the exterior siding | D | 49 |
H | Do the exterior painting | E,G | 63 |
I | Do the electrical work | C | 28 |
J | Put up the wallboard | F,I | 35 |
K | Install the flooring | J | 14 |
L | Do the interior painting | J | 35 |
M | Install the exterior fixtures | H | 14 |
N | Install the interior fixtures | K,L | 35 |
Note that the precedent constraints specified in the table are presented a bit differently in the lesson, so you'll need to adjust for that somehow.
Question 10 (8 points, manual)
Write abstract, generalizable Pyomo code to solve this scheduling problem
Include your code below. Note that the order of the tasks is organized differently than it was in the lesson. You can either reorganize the tasks or you can alter the loops where the precedence constraints are constructed.
Question 11 (1 point, auto)
What is the minimum total construction time? Enter your answer to the nearest day.
Question 12 (1 point, auto)
On what day should Interior Plumbing start to achieve the minimum construction time?
Hints for 13
You should reach the same answer for the minimized labor cost as we did with the concrete approach in Homework 1.This problem is essentially a transportation problem where the workers are "suppliers",
the days of the week each "demand" a certain amount of labor,
the hours assigned to each worker on each day are the transported amounts,
and the maximum hours for each worker on each day are the same as the route constraints in Lessson 3.
Finally, it's possible to get different answers for the number of hours assigned to each worker on each day
depending on how you set this up, but the minimum labor cost should be the same!
Question 13 (8 points, manual)
For the following we are redoing the worker-day scheduling problem from Homework 1, but this time your code must use an abstract approach similar to that in the Wyndor example in the lesson. Your data and model should be completely separated so that none of the parameters are typed directly into the model. You should use dictionaries to store the coefficients and right-sides of constraints. The problem setup is included again below for convenience.
Oxbridge University maintains a powerful mainframe computer for research use by its faculty, Ph.D. students, and research associates. During all working hours, an operator must be available to operate and maintain the computer, as well as to perform some programming services. Beryl Ingram, the director of the computer facility, oversees the operation.
It is now the beginning of the fall semester, and Beryl is confronted with the problem of assigning different working hours to her operators. Because all the operators are currently enrolled in the university, they are available to work only a limited number of hours each day, as shown in the following table:

There are six operators (four undergraduate students and two graduate students). They all have different wage rates because of differences in their experience with computers and in their pro- gramming ability. The above table shows their wage rates, along with the maximum number of hours that each can work each day.
Each operator is guaranteed a certain minimum number of hours per week that will maintain an adequate knowledge of the operation. This level is set arbitrarily at 8 hours per week for the undergraduate students (K. C., D. H., H. B., and S. C.) and 7 hours per week for the graduate students (K. S. and N. K.).
The computer facility is to be open for operation from 8 A.M. to 10 P.M. Monday through Friday with exactly one operator on duty during these hours. On Saturdays and Sundays, the computer is to be operated by other staff. Because of a tight budget, Beryl has to minimize cost. She wishes to determine the number of hours she should assign to each operator on each day.
Because of a tight budget, Beryl has to minimize cost. She wishes to determine the number of hours she should assign to each operator on each day.
Use Pyomo to solve this problem. Your solution should include all necessary code and inputs and it should produce formatted output. Note: be sure to use real variables, but your answers will work out to be integers. The code must be in abstract (generalizable) form for full credit.