1. 程式人生 > >Solving Optimization Problems: Using Excel

Solving Optimization Problems: Using Excel

Solving Linear Optimization Model: Using Excel

When solving Optimization Problems there are many items that need to be identified. To help understand what items need to be identified, refer to the example problem below about Jessie and Patrick trying to decide how many Classic Blue and Royal Red blankets they need to make to maximize their profits. Working through this problem will help you learn how to take the information provided to solve an optimization problem.

Example Problem

Jessie and Patrick set 40 hours aside each week for getting their supplies ready to make the blankets. They have an additional 40 hours that they allocate each week for making their blankets. Lastly, they dedicate 60 hours a week to the finishing touches and boxing up their blankets. Jessie and Patrick sell their classic blue blanket for a $15 profit and their royal red blanket for a $20 profit. How many of each type of blanket should Jessie and Patrick make to maximize their profit?

Setting Up the Problem on Paper

To start, is it helpful to write out your model on paper first so that you will have everything you need in front of you when you go to set up your model in Excel. Therefore, for this first section make sure that you write down everything on paper.

1. Identify the Problem Being Solved

While this may seem like an obvious thing to do, making sure that you are solving for the correct problem is important because this will set the foundation for rest of the problem. Often times this is the goal that is to be achieved.

a. For this example, the problem that needs to be solved is finding “How many of each type of blanket should Jessie and Patrick make to maximize their profit.”

b. On a sheet of paper write down the problem so you have it in front of you for the rest of the problem.

2. Identify the Decision Variables

The Decision Variables are going to be the values that need to be solved for that will help answer the problem. For this problem we have two decision variables: (1) The number of Classic Blue Blankets to make, (2) The number of Royal Red Blankets to make. These are the decision variables because you want to know how many of each blanket should be made to produce maximum profit.

a. To represent each decision variable, you want to let them be equal to a variable to easily use them throughout the problem. For simplicity,

let X1 = The number of Classic Blue Blankets to make, and

let X2 = The number of Royal Red Blankets to make

b. Write down these variables to let it be known that you are “letting” these variables be equal to your decision variables. To do this, write “LET” at the beginning of your decision variables to show that is what the variables are for. Your decision variables should look like this:

LET: X1 = The number of Classic Blue Blankets to make

X2 = The number of Royal Red Blankets to make

3. State the Objective Function

The Objective Function will include your decision variables and their respective coefficients that will be necessary to solve the problem that you are solving, and express if you are trying to maximize or minimize the answer.

a. For this problem the coefficients are going to be the profits gained by selling each of the blankets. Since you are trying to Maximize profits write MAX to identify that is what the goal is and set the equation up with each variable multiplied by its respective profit.

b. Since there are two decision variables (X1 = the number of Classic Blue Blankets to make and X2 = the number of Royal Red Blankets to make) your Object Function will look like this:

MAX: $15X1 + $20X2

4. State the Constraints

The constraints are going to be anything that would limit our ability to make any amount of any decision variable. For this problem there are three time constraints as well as a non-negativity, which states that you cannot produce a negative amount of blankets. The three time constraints are: (1) Amount of time allowed to get supplies ready, (2) Amount of time allowed to make blankets, (3) Amount of time allowed to make finishing touches.

a. For the first constraint, the amount of time to get supplies ready, it takes 30 minutes for the Classic Blue blankets and 45 minutes for the Royal red blankets, and there is 40 hours per week allowed for this task.

b. Set up this constraint by labeling it, so that it is known what the constraint is “subject to”, and then show that for every one Classic Blue blanket that is made it will take 30 minutes plus for every Royal Red blanket that is made it will take 45 minutes, and you can’t spend more than 40 hours (2,400 minutes) making them. Your first constraint should look like this:

Getting supplies ready: 30X1 + 45X2 ≤ 2,400

c. Set up the other two constraints the same way showing how much time would be used per blanket being made. You need to show that you have these constraints “subject to” what is being constrained, so you need to write “S.T.” to show for that. All together the three time constraints should look like this:

S.T.: Getting supplies ready: 30X1 + 45X2 ≤ 2,400

Making Blankets: 60X1 + 30X2 ≤ 2,400

Making Finishing Touches: 30X1 + 60X2 ≤ 3,600

d. It is important to also show that the amount of each blanket made cannot be negative. You can show this by saying that X1 , X2 ≥ 0.

Now that you have everything written out you model should look like the following. If so, you are ready to build your model in Excel.

Graphing Your Constraints on Paper

A great way to comprehend your optimization problem is by graphing it by hand. This link will take you to a page that will walk you through drawing it out.

Building Your Optimization Model in Excel

1. Building Your Model in Excel

Now that you have all the information for your model written down you can refer to in when building your model in excel.

A. Tips for Building a Clear and Clean Model

When building a model, it is helpful to keep it clean and concise as you build it. The following things you should keep in mind when building your model:

· Keep information that is related close together

· Follow the steps as you build your model and input the information generally from top to bottom, left to right.

· Highlighting the Objective Function since that is what will produce the answer to the problem you are solving.

B. How to Add-in Solver if You Don’t Have it

The Add-in solver will be needed to run your optimization model once you have it built. To check if you have it or not go to the Data tab in Excel and check under the Analyze section all the way on the right. If it is not there follow these steps to add it in.

a. Click on the file tab and go down to options

b. Click on options and then find “Add-ins” and click on it

c. Find “Solver Add-in” and then click “Go”

Solver should now be added and will be located under the Analyze section on the Data tab.

2. Setting Up Your Model in Excel

Starting out the model, you want to remember to build your model in Excel like you wrote it out on paper.

A. Adding in Decision Variables

a. In cells B2 and C2 add the two names of the blankets that are being made (Classic Blue Blankets in B2 and Royal Red Blankets in C2).

b. Right below in cells B3 and C3, leave these cells blank and have these cells be designated for the number of each that should be made (The values will be generated later when using solver).

c. Type in “Number to Make” in A3 to make it known that cells B3 and C3 will say the number of Classic Blue Blankets to Make (cell B3) and the number of Royal Red Blankets to make (C3).

B. Adding Objective Function

a. Skipping a row, add in the coefficients for each of the Decision Variables, lining each up with its respective variable. Therefore, in cell B5 type in $15 and in cell C5 type $20. To identify what these values are, type in Unit Profits to their left in cell A5 since each is the amount of profit that would be received for each product sold.

b. To fully have the objective function built into Excel, you want to have a cell to the right of the objective function that will eventually provide the answer you are solving for. Let this cell be D5. This cell will have a function that will multiply the amount of each blanket that should be made by the unit profit received from each. The function that will do this is called “SumProduct”.

c. Type in cell D5 “=SumProduct(B3:C3, B5:C5)”. This function will take the values in cells B3 through C3 and multiply them by their respective cells B5 through C5.

d. Type in Total Profit directly above D5 to properly label what the output from your Objective Function is.

C. Adding Your Constraints

Similar to how you set up the objective function so that it was right below and lined up with the decision variables, you are going to want to line up the values from each constraint with the variables for which they belong to. To label that you are about to start your constraints, skip a row between the Objective Function and then type “Constraints” in cell A7.

a. Type the first constraint (Getting supplies ready) under the Constraint header you just typed in A7.

b. Add the values to the right that state the amount of time that each blanket will take to get the supplies ready. (30 for B8, 45 for C8).

c. To the right you need to write a formula that will state how much of a certain constraint you have used to make sure that you either use enough (≥), not more than you have(≤), or an exact amount (=). You can use the same SumProduct formula as used above to find how much time you will need to spend if you were to make some given number of blankets. Type in cell D8 “=SumProduct(B3:C3, B8:C8)” to get the total amount of time that would be spent getting supplies ready for the total amount of blankets that should be made.

d. Another row over in cell E8 add in the equality that you have for the given constraint, so that it is easy to see when adding into solver and looking back. For this constraint you want to use less than or up to the amount available, so you will type in ≤.

e. Lastly, another row over un cell F8 type in the amount of the constraint that you have available to be used. For the about of time allowed to get supplies ready there is 2,400 minutes.

For each of the other constraints that you have (except for the non-negativity constraint) follow the same steps (a through e) to fully set up all your constraints. Once you have all your constraints, in cell D7 type in Used to indicate that is how much of the constraint you have used and type Available in cell F7 to indicate how much of each constraint you have available to use.

After completing the steps above your model should look similar to the one in Figure 1 below.

3. Using Solver

Now that you have all of your information typed into Excel and necessary functions setup, you can go to solver to solve for the optimal solution to the problem.

a. Go to the Data tab and click on solver.

b. In the “Set Objective” box, click or type in the cell that is designated for the Objective Function output. For this problem, the cell is D5.

c. Next click on either Max or Min depending on whether the problem is asking to minimize or maximize the output. Since the problem to be solved is to Maximize profit, click on Max.

d. In the “By Changing Variable Cells” box click or type in the cells that are designated for the decision variables, which are cells B3:C3.

e. Next, click on “Add” to add a constraint. (Though the constraints are already on the worksheet, you need to now let solver know that you want certain cells to be greater than, less than, or equal to other cells.)

f. First to show that you want the values that are used to be less than the values that are available, in the “Cell Reference” box select the cells D8:D10, have the sign be ≤ , and in the “Constraint” box select the cells F8:F10.

g. Click “Add” to add the next constraint.

h. Now you need to add in the constraint for non-negativity. Adding this will keep the values for the number of units to produce (blankets) from being an impossible negative number.

i. Similar to the other constraints, for the “Cell Reference” box highlight the cells that are designated for the decision variables, add in the appropriate sign, which is ≥, and then say what the values must be greater than. For this you can type in the value that the number of blankets you make must be greater than, which is 0.

j. Click “OK” now that you have added you last constraint.

k. Check that all the constraints that you wrote down are now accounted for in solver.

l. After you have selected “Simplex LP” for the Solving Method, click Solve.

You should see your decision variables and any value connected to your decision variables (your Objective Function output and the amount of your constraints that should be used) change.

4. Checking Answer and Cleaning Up Model

Now that you have ran your model check to make sure that your answer makes sense. For this problem if you followed along closely your finished model should look like the one below in Figure 2. However, there may be some problems that are more difficult, and you get an output that is not actually the answer you are looking for. There could be issues with how you set up your constraints, the values you typed into Excel, or how you set up solver. So, even though you got an answer, make sure to check that it is the right answer.

If you are confident that your answer is correct, make sure that you model is clean and can easily be read. Make sure that your Objective Function calculation is highlighted or distinguishable from other information. Make sure that values that are dollars have dollar signs and values that are above 1,000 have commas to make the values easier to read. There are many different fonts or styles that you can add, especially with bigger more complex models to make sure that your model is clear and easy to read. Make sure emphasizing enough information but not too much such that nothing is emphasized.

If you have comments or questions let me know at [email protected]