Anda di halaman 1dari 16

Example of Using Solver in Excel

You may want to solve a system of nonlinear equations in your homework. You can do
this in a wide variety of ways, but a simple way to find a solution is to use Microsoft
Excel's Solver tool. Be warned that Solver is NOT a very robust tool and may fail to find
solutions! In general, finding roots to nonlinear functions is a very difficult problem.
Excel does a poor job compared to more powerful programs such as Matlab, but it will
suffice for simple problems.

As a very simple example, let's suppose you want to solve a system of linear equations
using Solver. (This is a bad idea, because there are exact methods for linear equations,
but this is just an example.) Consider

3x + y + 2 = 0
x + 2y + 5 = 0
We can use linear algebra to find the solution, which is x = 0.2, y = -2.6. You can use the
Solver tool in Excel to find the solution to the above equations.

Example:

There is person who has 4 investment options as under:


Option1: Interest rate 15% per year
Option2: Interest rate 12.5% per year
Option3: Interest rate 11.8% per year
Option4: Interest rate 13% per year

He has a total sum of Rs. 2000000 (Twenty Lakhs) available for investment for this year.
But these options have some limitations or rules which need to be followed:

Options Minimum investment which Maximum Investment


needs to be done which can be done
Option1 50000 500000
Option2 200000 1000000
Option3 500000 1000000
Option4 300000 1250000

How much amount should he invest for the year in each option to maximize his returns?

Solution:

This is a typical optimization problem in which there is an aim and some constraints and
some values which u need to find.
One way is hit & trial : Other is use Linear Programming technique
Mathematically there is a manual Linear programming technique called simplex method
by which this can be solved. But since we already have so many software tools where this
logic is already built there is no need to do it manually—we can use excel’s solver tool to
solve this.

First understand the solution logic:

Objective Function:
Maximize Total Return R = (R1+R2+R3+R4)

Where R1 = return from Option 1 investment


Assume he invested X1 amount in option1
So return would be R1 = 0.15*X1 (15% multiplied by X1, 15% means 15/100 = 0.15)

Similarly,
R2 = return from Option 1 investment
Assume he invested X2 amount in option2
return would be R2 = 0.125*X2 (12.5% multiplied by X2)

Similarly,
R3 = return from Option 3 investment
Assume we invested X3 amount in option3
return would be R3 = 0.118*X3 (11.8% multiplied by X3)

Similarly,
R4 = return from Option 4 investment
Assume he invested X4 amount in option4
return would be R4 = 0.13*X4 (13% multiplied by X4)

So mathematically Objective function is


Max R = 0.15*X1 + 0.125*X2 + 0.118*X3 + 0.13*X4

Constraints:

1. Total invested amount cannot be more than Twenty Lakhs (which he has)
Mathematically this means: X1+X2+X3+X4 <= 2000000

2. Then there are constraints on maximum & minimum amounts to be invested


under each option (as told in the table shown in the problem) which can be
mathematically summarized as under:
a. 50000 =< X1 <= 500000
b. 200000 =< X2 <= 1000000
c. 500000 =< X3 <= 1000000
d. 300000 =< X4 <= 1250000

3. Since X1,X2,X3 & X4 are already between lower bound & upper bound we need
n’t define non-negativity constraints i.e.( X1>=0,X2>=0,X3>=0 and X4>=0)
Now we need to simply put this model in Excel Solver like the process shown below &
get the results:

Please find attached the excel sheet at the end

After this go to Tools select solver as shown:


To get a screen like this:
Select target cell as your objective function formula cell i.e Cell number C10 and also
and click on MAX field (since u want to maximize returns)
As under:
Then select all the changing cells – cells for which you want the values to be
calculated i.e. the X1,X2,X3,X4 values cells which are : C4, C5, C6, C7 (NOTE:
changing cells will never have any formula) as shown under:
Then go in the field: ‘Subject To Constraints’ and click on the ‘Add’ button for
adding the constraints we defined as shown:
Put constraint value for cell C4. As you know that Investment 1 (X1) should be <=
500000 and greater than 50000 so put those values as shown under:
Then again press the add button to add all constraints similarly. You can change the
inequality sign by clicking on the arrow key provided in that field & selecting
appropriate inequality as under:
similarly put all constraints and after putting the last constraint, click on OK as under:
click ok to get the following screen:
Now click on options to get the following screen
Check the “Assume Non-Negative” box and click on OK(in this problem there is no
need as told earlier). As u do this u again reach the following screen automatically:
Now click on SOLVE button and you get to see something like this:
You can see that Solver has found the values for X1,X2,X3 & X4 and accordingly
your objective function is also maximized to value of Rs. 480500

Click on OK and you get the following screen:


Solver

***********************************************************************
*

Anda mungkin juga menyukai