Search the Blog

Tuesday, October 1, 2019

LPP Problem With Python and Jupyter

Linear Programmming (LP) is a widely used mathematical modeling technique developed to help the decisions makers in planning and decision - making according to resource allocation is concerned.
LPP Programming Concept and other documentation for starting learning  Data Science

Structure of LP Model are

1- Decision Variables (Activities)

    We need to evalute various alternative for getting the optimum solution of desired Objective Function.
    The values of certain varibles is not under decision-makers. Then such varibles is called Controllable.
   The values of certain varibles is under decision-makers. Then such varibles is called uncontrollable.

2- Objective function

   This is the funtion which have to either maximized or minimized.
   Otimize ( Minimize or Maximize) 
      Z = C1X1 + C2X2 + C3X3 + ...... + CnXn
     where C1, C2, C3, ..., Cn are constant 
     X1, X2, X3,  .... Xn are varibles.

3- Constraints

There are always certain limitations on the use of resourses, example like lobour, machinery, raw material, space, money , etc . the limit the degree to which objective can be achived. Such constraints must be expressed as linear equalities i terms of decision vatriables.  


Assumptions of an LP Model-

1- Certainty

In all LPP models is assumed that all model parameters contribute to make unit decision.

2- Additivity

   The value of the objective function and the totaln amount of each resourses used muct be eqaul to the sum of the respective indivdual and consumtpion of resourses by a unit of decision varible.

3- Linearity or proportionality

   The amount of each resourse used and ists contibution to the profit in objective function must be proportional to the values of each decision varibles

4- Divisiblity or Continuity

   The solution of each resourses values of decision variables  are allowed to assume continuous values.

Advantages of LPP-

1- Optimum uses of productive Resources.

2- Improve the Quality of decesion making.

3- Fesible and possible Solution. 

4- Identifing the bottlenecks.

5- Re- evalution of decesion by changeing the varibles.


Limitation of LPP-

1- All relationship are considered as Linear.

2- No gaurentee to have integer Solution.

3- No consideration of time and uncertainity.

4- Large - Scale problem solution is very complicated.

5- Parameteres is assumed as constant.

6- Deals with only single objective.


Application Ares of Linear Programming Problem(LPP)

1- Agriculture

2- Military Applications

3- Production Management

    1- Mix Product    

   2- Production Planning    

   3- Assembly Line Balancing    

   4- Trim Loss


4- Financial Management

    1- Portfolio Selection    

    2- Profit Management

5- Marketing Management

    1- Media Selection    

    2- Travellling Salesman Problem    

    3- Physical Distribution


6- Personal Management.

   1- Staffing Problem   

   2- Determination of Equitable Salaries   

   3- Job Evaluation and Selection



A linear programming problem may be defined as the problem for maximizing or minimizing a linear function subject to the linear constraints. The constraints could be in equalities or inequalities.

Here is a simple example: find numbers x1 and x2 that maximizes the sum x1 + x2 subject to the constraints(conditions)

(i)    X1 ≥ 0
(ii)   X2 ≥ 0
(ii)   X1 + 2X2  40
(iii)  4X1 + 2X2  120
(iv)  X1 + X2  1

The first two constraints,X1 ≥ 0 and X2 ≥ 0 are called nonnegativity constraints  and will always be postive in case of maximum and mininum problems becauase in real world if something exist then it could calculted and formulated.


The other constraints shown above are called the main constraints. The function that have to be maximized (or minimized) is called the objective function. Here, the objective function is X+ X2.




We usually denotes this function with Z.
    Z =  X1 +  X2

Lets understand the complete concept with Real Life Example

We want to find the maximum solution of this linear polymer to:
 Constraints are following:
   i       x ≥ 0,   
   ii      ≥ 3,     
   iii     2≤ 20 – x,     
   iv     4≥ 2– 8,
   V       ≤ 2− 10



# LPP Problem Sample Example 1
# LPP Problem Sample Example 1
import numpy as np
import matplotlib.pyplot as plt
% matplotlib inline

# Construct lines
# x > 0
x = np.linspace(0, 20, 2000)
# y >= 3
y1 = (x*0) + 3
# 2y <= 50 - x
y2 = (20-x)/2.0
# 4y >= 2x - 8 
y3 = (2*x-8)/4.0
# y <= 2x - 10 
y4 = 2 * x -10

# Make plot
plt.plot(x, y1, label=r'$y\geq3$')
plt.plot(x, y2, label=r'$2y\leq20-x$')
plt.plot(x, y3, label=r'$4y\geq 2x - 8$')
plt.plot(x, y4, label=r'$y\leq 2x-10$')
plt.xlim((0, 16))
plt.ylim((0, 11))
plt.xlabel(r'$x$')
plt.ylabel(r'$y$')

# Fill feasible region
y5 = np.minimum(y2, y4)
y6 = np.maximum(y1, y3)
plt.fill_between(x, y5, y6, where=y5>y6, color='grey', alpha=0.5)
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)


Our solution lies somewhere in the grey feasible region in the graph below.
LPP Problem With Python and Jupyter with graph


It has been proven that the minima and maxima of linear programming problems are at the vertices of the feasible region. In this, there are 4 corners to our feasible region, So we can find the solutions for putting the value of this corner into the Objective Function each corner to find our maximum.
Four Courner X Y Cordinates Are:
Maximun 
Funtion             X           Y             Value
Z= 5x+ 4y                 8                  6                  64

 
Z= 5x+ 4y                 6.25             3                  43.25  

Z= 5x+ 4y                 10                3                  62                                  
Z= 5x+ 4y                 12                4                  76


So Last Cordinate ( 12 , 4) is giveing us the highest value.
So these are the  best for maximum. 

So Second Cordinate ( 6.25 , 3) is giveing us the lost value.
   iv     4y2x8
   v      
y2x5

No comments:

Post a Comment

Translate