Question

In: Economics

You want to evaluate your savings of 2.500.000 $. If you deposit your money in the...

You want to evaluate your savings of 2.500.000 $. If you deposit your money in the A bank, you get 9% interest income in every three years. The B bank provides 4% interest income per year. The B bank also provides 6% annual income to the 4-year private account and 6% annual income to the 7-year private account. Also, if you invest your money in a 4-year government bond, 7.5% interest income per year. However, the government deducts 15% tax in every two years from the interest income you get from the bank and you have to pay 200.000 $ (rising 4% in every two years) every three years for the installment of the house you buy. How should you invest 2.500.000 $ to maximize the earnings at the end of 9 years.

(Create only the LP model, do not solve the problem)

Solutions

Expert Solution

Thank u, please like this answer and support us please,

and please dont give us any hate, this is the best answer for your question,

Answer::

Introduction

Optimization is the way of life. We all have finite resources and time and we want to make the most of them. From using your time productively to solving supply chain problems for your company – everything uses optimization. It’s an especially interesting and relevant topic in data science.

It is also a very interesting topic – it starts with simple problems, but it can get very complex. For example, sharing a bar of chocolate between siblings is a simple optimization problem. We don’t think in mathematical terms while solving it. On the other hand, devising inventory and warehousing strategy for an e-tailer can be very complex. Millions of SKUs with different popularity in different regions to be delivered in defined time and resources – you see what I mean!

Linear programming (LP) is one of the simplest ways to perform optimization. It helps you solve some very complex optimization problems by making a few simplifying assumptions. As an analyst, you are bound to come across applications and problems to be solved by Linear Programming.

For some reason, LP doesn’t get as much attention as it deserves while learning data science. So, I thought let me do justice to this awesome technique. I decided to write an article that explains Linear programming in simple English. I have kept the content as simple as possible. The idea is to get you started and excited about Linear Programming.

Note- If you want to learn this in a course format, we have curated this free course for you- Linear Programming for Data Science Professionals

Table of Content

  1. What is Linear Programming?
    • Basic Terminologies
    • The process to define an LP problem
  2. Solve Linear Program by Graphical Method
  3. Solve Linear Program using R
  4. Solve Linear Program using OpenSolver
  5. Simplex Method
  6. Northwest Corner Method and Least Cost Method
  7. Applications of Linear programming

1. What is Linear Programming?

Now, what is linear programming? Linear programming is a simple technique where we depict complex relationships through linear functions and then find the optimum points. The important word in the previous sentence is depicted. The real relationships might be much more complex – but we can simplify them to linear relationships.

Applications of linear programming are everywhere around you. You use linear programming at personal and professional fronts. You are using linear programming when you are driving from home to work and want to take the shortest route. Or when you have a project delivery you make strategies to make your team work efficiently for on-time delivery.

Example of a linear programming problem

Let’s say a FedEx delivery man has 6 packages to deliver in a day. The warehouse is located at point A. The 6 delivery destinations are given by U, V, W, X, Y, and Z. The numbers on the lines indicate the distance between the cities. To save on fuel and time the delivery person wants to take the shortest route.

So, the delivery person will calculate different routes for going to all the 6 destinations and then come up with the shortest route. This technique of choosing the shortest route is called linear programming.

In this case, the objective of the delivery person is to deliver the parcel on time at all 6 destinations. The process of choosing the best route is called Operation Research. Operation research is an approach to decision-making, which involves a set of methods to operate a system. In the above example, my system was the Delivery model.

Linear programming is used for obtaining the most optimal solution for a problem with given constraints. In linear programming, we formulate our real-life problem into a mathematical model. It involves an objective function, linear inequalities with subject to constraints.

Is the linear representation of the 6 points above representative of the real-world? Yes and No. It is an oversimplification as the real route would not be a straight line. It would likely have multiple turns, U-turns, signals and traffic jams. But with a simple assumption, we have reduced the complexity of the problem drastically and are creating a solution that should work in most scenarios.

Formulating a problem – Let’s manufacture some chocolates

Example: Consider a chocolate manufacturing company that produces only two types of chocolate – A and B. Both the chocolates require Milk and Choco only. To manufacture each unit of A and B, the following quantities are required:

  • Each unit of A requires 1 unit of Milk and 3 units of Choco
  • Each unit of B requires 1 unit of Milk and 2 units of Choco

The company kitchen has a total of 5 units of Milk and 12 units of Choco. On each sale, the company makes a profit of

  • Rs 6 per unit A sold
  • Rs 5 per unit B sold.

Now, the company wishes to maximize its profit. How many units of A and B should it produce respectively?

Solution: The first thing I’m gonna do is represent the problem in a tabular form for better understanding.

Milk Choco Profit per unit
A 1 3 Rs 6
B 1 2 Rs 5
Total 5 12

Let the total number of units produced by A be = X

Let the total number of units produced by B be = Y

Now, the total profit is represented by Z

The total profit the company makes is given by the total number of units of A and B produced multiplied by its per-unit profit of Rs 6 and Rs 5 respectively.

Profit: Max Z = 6X+5Y

which means we have to maximize Z.

The company will try to produce as many units of A and B to maximize the profit. But the resources Milk and Choco are available in a limited amount.

As per the above table, each unit of A and B requires 1 unit of Milk. The total amount of Milk available is 5 units. To represent this mathematically,

X+Y ≤ 5

Also, each unit of A and B requires 3 units & 2 units of Choco respectively. The total amount of Choco available is 12 units. To represent this mathematically,

3X+2Y ≤ 12

Also, the values for units of A can only be integers.

So we have two more constraints, X ≥ 0 & Y ≥ 0

For the company to make maximum profit, the above inequalities have to be satisfied.

This is called formulating a real-world problem into a mathematical model.

Common terminologies used in Linear Programming

Let us define some terminologies used in Linear Programming using the above example.

  • Decision Variables: The decision variables are the variables that will decide my output. They represent my ultimate solution. To solve any problem, we first need to identify the decision variables. For the above example, the total number of units for A and B denoted by X & Y respectively are my decision variables.
  • Objective Function: It is defined as the objective of making decisions. In the above example, the company wishes to increase the total profit represented by Z. So, profit is my objective function.
  • Constraints: The constraints are the restrictions or limitations on the decision variables. They usually limit the value of the decision variables. In the above example, the limit on the availability of resources Milk and Choco are my constraints.
  • Non-negativity restriction: For all linear programs, the decision variables should always take non-negative values. This means the values for decision variables should be greater than or equal to 0.

The process to formulate a Linear Programming problem

Let us look at the steps of defining a Linear Programming problem generically:

  1. Identify the decision variables
  2. Write the objective function
  3. Mention the constraints
  4. Explicitly state the non-negativity restriction

For a problem to be a linear programming problem, the decision variables, objective function and constraints all have to be linear functions.

If all the three conditions are satisfied, it is called a Linear Programming Problem.

2. Solve Linear Programs by Graphical Method

A linear program can be solved by multiple methods. In this section, we are going to look at the Graphical method for solving a linear program. This method is used to solve a two-variable linear program. If you have only two decision variables, you should use the graphical method to find the optimal solution.

A graphical method involves formulating a set of linear inequalities subject to the constraints. Then the inequalities are plotted on an X-Y plane. Once we have plotted all the inequalities on a graph the intersecting region gives us a feasible region. The feasible region explains what all values our model can take. And it also gives us the optimal solution.

Let’s understand this with the help of an example.

Example: A farmer has recently acquired a 110 hectares piece of land. He has decided to grow Wheat and barley on that land. Due to the quality of the sun and the region’s excellent climate, the entire production of Wheat and Barley can be sold. He wants to know how to plant each variety in the 110 hectares, given the costs, net profits and labor requirements according to the data shown below:

Variety Cost (Price/Hec) Net Profit (Price/Hec) Man-days/Hec
Wheat 100 50 10
Barley 200 120 30

The farmer has a budget of US$10,000 and availability of 1,200 man-days during the planning horizon. Find the optimal solution and the optimal value.

Solution: To solve this problem, first we gonna formulate our linear program.

Formulation of Linear Problem

Step 1: Identify the decision variables

The total area for growing Wheat = X (in hectares)

The total area for growing Barley = Y (in hectares)

X and Y are my decision variables.

Step 2: Write the objective function

Since the production from the entire land can be sold in the market. The farmer would want to maximize the profit for his total produce. We are given net profit for both Wheat and Barley. The farmer earns a net profit of US$50 for each hectare of Wheat and US$120 for each Barley.

Our objective function (given by Z) is, Max Z = 50X + 120Y

Step 3: Writing the constraints

1. It is given that the farmer has a total budget of US$10,000. The cost of producing Wheat and Barley per hectare is also given to us. We have an upper cap on the total cost spent by the farmer. So our equation becomes:

100X + 200Y ≤ 10,000

2. The next constraint is the upper cap on the availability of the total number of man-days for the planning horizon. The total number of man-days available is 1200. As per the table, we are given the man-days per hectare for Wheat and Barley.

10X + 30Y ≤ 1200

3. The third constraint is the total area present for plantation. The total available area is 110 hectares. So the equation becomes,

X + Y ≤ 110

Step 4: The non-negativity restriction

The values of X and Y will be greater than or equal to 0. This goes without saying.

X ≥ 0, Y ≥ 0

We have formulated our linear program. It’s time to solve it.

Solving an LP through Graphical method

Since we know that X, Y ≥ 0. We will consider only the first quadrant.

To plot for the graph for the above equations, first I will simplify all the equations.

100X + 200Y ≤ 10,000 can be simplified to X + 2Y ≤ 100 by dividing by 100.

10X + 30Y ≤ 1200 can be simplified to X + 3Y ≤ 120 by dividing by 10.

The third equation is in its simplified form, X + Y ≤ 110.

Plot the first 2 lines on a graph in the first quadrant (like shown below)

The optimal feasible solution is achieved at the point of intersection where the budget & man-days constraints are active. This means the point at which the equations X + 2Y ≤ 100 and X + 3Y ≤ 120 intersect gives us the optimal solution.

The values for X and Y which gives the optimal solution is at (60,20).

To maximize profit the farmer should produce Wheat and Barley in 60 hectares and 20 hectares of land respectively.

The maximum profit the company will gain is,

Max Z = 50 * (60) + 120 * (20)

= US$5400

Note: Everything taught here has also been taught in a course format in this free course- Linear Programming for Data Science Professionals

3. Solve Linear Program Using R

R is an open-source tool that is very popular among the data scientists for essential data science tasks. Performing linear programming is very easy and we can attain an optimum solution in very few steps. Come let’s learn.

Example: A toy manufacturing organization manufactures two types of toys A and B. Both the toys are sold at Rs.25 and Rs.20 respectively. There are 2000 resource units available every day from which the toy A requires 20 units while toy B requires 12 units. Both of these toys require a production time of 5 minutes. Total working hours are 9 hours a day. What should be the manufacturing quantity for each of the pipes to maximize the profits?

Here:

The objective function is:
Max.Z=25x+20y

where x are the units of pipe A

y are the units of pipe B

Constraints:
20x+12y<=2000

5x+5y<=540

Let’s see the code part now:

install.packages("lpSolve")
library(lpSolve)
#Setting the coefficients of decision variables
objective.in=c(25,20)
#Constraint Matrix
const.mat=matrix(c(20,12,5,5),nrow = 2,byrow = T)
#defining constraints
const_time=540 #in minutes
const_res=2000
#RHS for constraints
const.rhs=c(const_res,const_time)
#Direction for constraints
const.dir=c("<=","<=")
#Finding the optimum solution
opt=lp(direction = "max",objective.in,const.mat,const.dir,const.rhs)
summary(opt)
#Objective values of x and y
opt$solution
#Value of objective function at optimal point
opt$objval

view rawlpp.R hosted with ❤ by GitHub

Output

summary(opt)

Length Class Mode 
direction 1 -none- numeric 
x.count 1 -none- numeric 
objective 2 -none- numeric 
const.count 1 -none- numeric 
constraints 8 -none- numeric 
int.count 1 -none- numeric 
int.vec 1 -none- numeric 
bin.count 1 -none- numeric 
binary.vec 1 -none- numeric 
num.bin.solns 1 -none- numeric 
objval 1 -none- numeric 
solution 2 -none- numeric 
presolve 1 -none- numeric 
compute.sens 1 -none- numeric 
sens.coef.from 1 -none- numeric 
sens.coef.to 1 -none- numeric 
duals 1 -none- numeric 
duals.from 1 -none- numeric 
duals.to 1 -none- numeric 
scale 1 -none- numeric 
use.dense 1 -none- numeric 
dense.col 1 -none- numeric 
dense.val 1 -none- numeric 
dense.const.nrow 1 -none- numeric 
dense.ctr 1 -none- numeric 
use.rw 1 -none- numeric 
tmp 1 -none- character
status 1 -none- numeric 

> opt$solution
[1] 88 20

> opt$objval
[1] 2600

Therefore from the output, we see that the organization should produce 88 units of toy A and 20 units of toy B and the maximum profit for the organization will be Rs.2600.


Related Solutions

You want to evaluate your savings of 1.000.000 TL. If you deposit your money in the...
You want to evaluate your savings of 1.000.000 TL. If you deposit your money in the bank, you get 10% interest income in every two years. The Bank also provides 7% annual income to the 4-year private account and 9% annual income to the 6-year private account. Also, if you invest your money in a 6-year government bond, 7.5% per year; if you invest in a 8-year municipal bond, you can get 9.5% interest income per year. However, the government...
Suppose you need to deposit money in a savings account. Bank X offers a rate of...
Suppose you need to deposit money in a savings account. Bank X offers a rate of 10.200% compounded monthly; Bank Y offers a rate of 10.150% compounded quarterly; Bank Z offers a rate of 10.400% compounded annually. Which bank is best for you? Group of answer choices Bank X Bank Y Not enough information to answer Bank Z
You are at your local bank intending to deposit your savings. Explain why you would not...
You are at your local bank intending to deposit your savings. Explain why you would not offer a loan, at an interest rate that is higher than the rate the bank pays on your deposits (but lower than the rate the bank charges for car loans), to the next individual who enters the bank to apply for a car loan.
You are considering investing your money in a bank certificate of deposit (that is, lending money...
You are considering investing your money in a bank certificate of deposit (that is, lending money to a bank). You have received the following quotations from four banks. Which bank should you select? Bank A: APR of 3.48 percent compounded annually Bank B: APR of 3.44 compounded semi-annually Bank C: APR of 3.36 compounded monthly Bank D: APR of 3.38 percent compounded daily Bank E: APR of 3.41 compounded continuously Group of answer choices Bank C Bank E Bank D...
You plan to deposit $5,500 into a savings account. There are five great banks in your...
You plan to deposit $5,500 into a savings account. There are five great banks in your town offering terrific interest rates. If your goal is to earn the greatest amount of interest, which bank should you choose? Please explain why. Bank KLM: 3.66% compounded continuously Bank HIJ: 3.71% compounded semi-annually Bank DEF: 3.70%, compounded monthly Bank XYZ; 3.64% compounded quarterly Bank ABC: 3.74%, compounded annually
Suppose that you deposit $1,467 in a savings account at FirstFederal Savings of Stanton at...
Suppose that you deposit $1,467 in a savings account at First Federal Savings of Stanton at the startof each of year for the next 7 years, which is your holding period. You plan to leave these contributions and any interest in the account until the end of your holding period. You forecast an annual interest rate of 6.59%, compounded annually.What is the forecast value of your account at the end of your holding period?Round your answer to the nearest dollar.
Suppose that you deposit $858 in a savings account at FirstFederal Savings of Stanton at...
Suppose that you deposit $858 in a savings account at First Federal Savings of Stanton at the start of each of year for the next 8 years, which is your holding period. You plan to leave these contributions and any interest in the account until the end of your holding period. You forecast an annual interest rate of 3.79%, compounded annually.What is the forecast value of your account at the end of your holding period?Round your answer to the nearest...
Suppose that you deposit your money in a bank that pays interest at a rate of...
Suppose that you deposit your money in a bank that pays interest at a rate of 18% per year. How long will it take for your money to triple if the interest is compounded weekly? (1year= 52 weeks) compounded continuously? compounded quarterly?
Diana is saving for her education. She will deposit some money into a savings account today...
Diana is saving for her education. She will deposit some money into a savings account today and in addition, deposit $500 per month for the next 2 years (24 deposits) starting one month from now. Her goal is to have enough money in the account so that she can withdraw $3,000 per month for 4 years (48 withdrawals) while she attends college and still have $8,000 left at the end for a trip to South America to celebrate her graduation....
Suppose you deposit $20,000 in a savings account. After 210 days, you withdraw your funds. If...
Suppose you deposit $20,000 in a savings account. After 210 days, you withdraw your funds. If the bank paid you $340 in interest for the 210-day period, what is your APY?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT