$30
Instructions: (Please read carefully!)
In this session, we will learn to use Pyomo modeling language and software. We will start with very simple exercises in order to gain familiarity with the syntax of the language. Since we will be using Pyomo in the next few labs as well, it is important to understand and learn its correct usage. Instructions for Setting up Pyomo and Google Colab: Pyomo is a Python based modelling language that we will use to write and solve optimisation problems. We will write the code in Google colab notebook. The steps to use Pyomo in Google Colab have been provided in the videos posted earlier. Use those instructions to perform the following steps:
• Sign in to Google colab using your e-mail id of the form rollnumber@iitb.ac.in
• You will be redirected to a Single Sign On (SSO) page. Please provide the proper credentials and the authenticator code and sign in.
• Now you are redirected to the Google Colab page which is displayed as shown in Figure 1.
Figure 1: Screenshot of Goole Colab upon sign in
• Now click on NEW NOTEBOOK and you will be redirected to a new Colab notebook where you need to type your code for the exercise problems.
• Please note that you can use the same notebook for solving all the problems.
• If you need to open the sample file IE507 lab0.ipynb shared with you earlier, you can click File, then click New Notebook and once a new notebook opens in a new tab, again click File and then click Open. You can now open the file. You can use the file as your reference. These steps have been posted in a different video.
• Rename your notebook as YOURROLLNUMBER IE507 Lab1.ipynb. The steps to rename a file have also been posted in the video.
• Please post your doubts in MS Teams or Moodle so that TAs can clarify.
For more details on pyomo, please consult https://pyomo.readthedocs.io/en/stable/index. html.
You are now ready to solve this lab’s Exercise problems. Try to answer all the questions in this Exercise. Only the questions marked [R] need to be answered in the notebook. You can either print the answers using print command in your code or you can write the text in a separate text tab. To add text in your notebook, click +Text.
After completing this lab’s exercises, click File → Download .ipynb and save your file to your local laptop/desktop. Then upload the file in Moodle. These instructions are also provided in the video.
The deadline for today’s lab is 11:59 PM, tomorrow.
All questions must be solved. There are only 3 exercise problems. 2 extra marks will be awarded for following the systematic procedures described above.
Exercise 1: A Simple Linear Program. [6 Marks] Consider the optimization problem.
,
1. Solve this optimisation problem.
2. Verify whether the solution obtained satisfies all the constraints and has the correct objective function value.
3. [R] Report the objective function value, the values of all variables at the optimal point.
4. [R] Report the constraint activities (the value of left hand side (LHS) in a constraint and if the constraint is satisfied) for first four constraints.
Exercise 2: LP Reformulation. [6 Marks] Consider the following optimisation problem:
max0.043x1 + 0.027x2 + 0.025x3 + 0.022x4 + 0.045x5− 0.0275y
s.t.
1. [R] Rewrite this optimisation problem as a linear program, and include it in your notebook.
2. Solve the optimization problem.
3. [R] Report the optimal solution value, the values of variables at the optimal solution and the activities of all constraints of the LP model.
Exercise 3: Your (possibly) first LP modeling problem. [10 Marks] Keshar Industries produces two products that are sold as raw materials to companies manufacturing automobile parts and kitchen utilities. Based on an analysis of current inventory level and potential demand for the month of September 2020, the management of Keshar Industries has specified that the combined production for products P and Q should be at least 160 Kgs. Additionally, a major customer has placed an order for 45 Kgs of product P and 29 Kgs of product Q. Product P requires 1.25 hours of manufacturing time per Kg and product Q requires 45 minutes of manufacturing time per Kg. For the month of September 2020, 350 hours of manufacturing time are available. Keshar Industries aims at satisfying these requirements at a minimum total production cost. Production costs are |45 per Kg for product P and |80 per Kg for product Q.
1. [R] Formulate the problem as a linear program. Explain your formulation (the variables used, objective function and constraints).
2. Solve your optimization problem using pyomo.
3. [R] Report the optimal solution value, the values of variables at the optimal solution and the activities of all constraints of the LP model.
4. [R] Suppose a different customer has placed an order of 95 Kgs of product P and 75 Kgs of product Q. Introduce this new requirement into your formulation and explain how your linear program formulation will change.
5. Solve your new optimization problem using pyomo.
6. [R] Report the optimal solution value, the values of variables at the optimal solution and the activities of all constraints of the LP model. Explain your observations about the results obtained. Based on the results obtained, what would you advise Keshar Industries about the new requirement?